Use ofw_bus_find_child_device_by_phandle to see if the child we're

adding already exists and if so just return that. The typical use case
is from identify routines, which shouldn't be adding multiple copies
of the same phandle_t to the gpiobus. Only one per phandle_t is needed
(or expected by the current code).

Differential Revision: https://reviews.freebsd.org/D2871
This commit is contained in:
Warner Losh 2015-06-20 04:48:53 +00:00
parent bb39ff4c36
commit 3dede9f354

View File

@ -55,6 +55,14 @@ ofw_gpiobus_add_fdt_child(device_t bus, const char *drvname, phandle_t child)
struct gpiobus_ivar *devi;
struct ofw_gpiobus_devinfo *dinfo;
/*
* Check to see if we already have a child for @p child, and if so
* return it.
*/
childdev = ofw_bus_find_child_device_by_phandle(bus, child);
if (childdev != NULL)
return (childdev);
/*
* Set up the GPIO child and OFW bus layer devinfo and add it to bus.
*/