Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F153378203
D2871.id6336.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D2871.id6336.diff
View Options
Index: sys/dev/gpio/ofw_gpiobus.c
===================================================================
--- sys/dev/gpio/ofw_gpiobus.c
+++ sys/dev/gpio/ofw_gpiobus.c
@@ -56,6 +56,14 @@
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_child_by_phandle(bus, child);
+ if (childdev != NULL)
+ return (childdev);
+
+ /*
* Set up the GPIO child and OFW bus layer devinfo and add it to bus.
*/
childdev = device_add_child(bus, drvname, -1);
Index: sys/dev/ofw/ofw_bus_subr.h
===================================================================
--- sys/dev/ofw/ofw_bus_subr.h
+++ sys/dev/ofw/ofw_bus_subr.h
@@ -107,4 +107,8 @@
/* Helper to search for a child with a given name */
phandle_t ofw_bus_find_child(phandle_t, const char *);
+/* Helper routine to find a device_t child matchig a given phandle_t */
+device_t ofw_bus_find_child_device_by_phandle(device_t bus, phandle_t node);
+
+
#endif /* !_DEV_OFW_OFW_BUS_SUBR_H_ */
Index: sys/dev/ofw/ofw_bus_subr.c
===================================================================
--- sys/dev/ofw/ofw_bus_subr.c
+++ sys/dev/ofw/ofw_bus_subr.c
@@ -551,3 +551,44 @@
}
return (0);
}
+
+/**
+ * @brief Return child of bus whose phandle is node
+ *
+ * A direct child of @p will be returned if it its phandle in the
+ * OFW tree is @p node. Otherwise, NULL is returned.
+ *
+ * @param bus The bus to examine
+ * @param node The phandle_t to look for.
+ */
+device_t
+ofw_bus_find_child_device_by_phandle(device_t bus, phandle_t node)
+{
+ device_t *children, retval, child;
+ int nkid, i;
+
+ /*
+ * Nothing can match the flag value for no node.
+ */
+ if (node == -1)
+ return (NULL);
+
+ /*
+ * Search the children for a match. We microoptimize
+ * a bit by not using ofw_bus_get since we already know
+ * the parent. We do not recurse.
+ */
+ if (device_get_children(bus, &children, &nkid) != 0)
+ return (NULL);
+ retval = NULL;
+ for (i = 0; i < nkid, i++) {
+ child = children[i];
+ if (OFW_BUS_GET_NODE(bus, child) == node) {
+ retval = child;
+ break;
+ }
+ }
+ free(children, M_TEMP);
+
+ return (retval);
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Apr 21, 7:40 PM (14 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31929657
Default Alt Text
D2871.id6336.diff (2 KB)
Attached To
Mode
D2871: Add ofw_bus_find_child_by_phandle, a helper routine to find a device_t child matchig a given phandle_t.
Attached
Detach File
Event Timeline
Log In to Comment