summaryrefslogtreecommitdiffstats
path: root/sys/dev/ofw
diff options
context:
space:
mode:
authorgonzo <gonzo@FreeBSD.org>2015-05-24 23:53:10 +0000
committergonzo <gonzo@FreeBSD.org>2015-05-24 23:53:10 +0000
commit81e58ddcdd0272078011c41745e6d60eedd418f7 (patch)
treeaf4324f9fe1f053baaab46e0520bfabf611c4e9b /sys/dev/ofw
parent4342741d9a4cecf5d5415becc7e5e2e58b22ce6c (diff)
downloadFreeBSD-src-81e58ddcdd0272078011c41745e6d60eedd418f7.zip
FreeBSD-src-81e58ddcdd0272078011c41745e6d60eedd418f7.tar.gz
Rename fdt_find_child to ofw_bus_find_child. There is nothing FDT-specific
in this function. Suggested by: andrew@
Diffstat (limited to 'sys/dev/ofw')
-rw-r--r--sys/dev/ofw/ofw_bus_subr.c22
-rw-r--r--sys/dev/ofw/ofw_bus_subr.h3
2 files changed, 25 insertions, 0 deletions
diff --git a/sys/dev/ofw/ofw_bus_subr.c b/sys/dev/ofw/ofw_bus_subr.c
index 5063930..a9261ce 100644
--- a/sys/dev/ofw/ofw_bus_subr.c
+++ b/sys/dev/ofw/ofw_bus_subr.c
@@ -503,6 +503,28 @@ ofw_bus_intr_to_rl(device_t dev, phandle_t node,
}
phandle_t
+ofw_bus_find_child(phandle_t start, const char *child_name)
+{
+ char *name;
+ int ret;
+ phandle_t child;
+
+ for (child = OF_child(start); child != 0; child = OF_peer(child)) {
+ ret = OF_getencprop_alloc(child, "name", sizeof(*name), (void **)&name);
+ if (ret == -1)
+ continue;
+ if (strcmp(name, child_name) == 0) {
+ free(name, M_OFWPROP);
+ return (child);
+ }
+
+ free(name, M_OFWPROP);
+ }
+
+ return (0);
+}
+
+phandle_t
ofw_bus_find_compatible(phandle_t node, const char *onecompat)
{
phandle_t child, ret;
diff --git a/sys/dev/ofw/ofw_bus_subr.h b/sys/dev/ofw/ofw_bus_subr.h
index be35711..bbeda7f 100644
--- a/sys/dev/ofw/ofw_bus_subr.h
+++ b/sys/dev/ofw/ofw_bus_subr.h
@@ -104,4 +104,7 @@ int ofw_bus_has_prop(device_t, const char *);
/* Helper to search for a child with a given compat prop */
phandle_t ofw_bus_find_compatible(phandle_t, const char *);
+/* Helper to search for a child with a given name */
+phandle_t ofw_bus_find_child(phandle_t, const char *);
+
#endif /* !_DEV_OFW_OFW_BUS_SUBR_H_ */
OpenPOWER on IntegriCloud