summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/dev/fdt/fdt_common.c17
-rw-r--r--sys/dev/fdt/fdt_common.h1
2 files changed, 18 insertions, 0 deletions
diff --git a/sys/dev/fdt/fdt_common.c b/sys/dev/fdt/fdt_common.c
index f00519e..0198d55 100644
--- a/sys/dev/fdt/fdt_common.c
+++ b/sys/dev/fdt/fdt_common.c
@@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$");
#define FDT_COMPAT_LEN 255
#define FDT_TYPE_LEN 64
+#define FDT_NAME_LEN 32
#define FDT_REG_CELLS 4
@@ -310,6 +311,22 @@ fdt_find_compatible(phandle_t start, const char *compat, int strict)
}
phandle_t
+fdt_find_child(phandle_t start, const char *child_name)
+{
+ char name[FDT_NAME_LEN];
+ phandle_t child;
+
+ for (child = OF_child(start); child != 0; child = OF_peer(child)) {
+ if (OF_getprop(child, "name", name, sizeof(name)) <= 0)
+ continue;
+ if (strcmp(name, child_name) == 0)
+ return (child);
+ }
+
+ return (0);
+}
+
+phandle_t
fdt_depth_search_compatible(phandle_t start, const char *compat, int strict)
{
phandle_t child, node;
diff --git a/sys/dev/fdt/fdt_common.h b/sys/dev/fdt/fdt_common.h
index 3d05341..6801297 100644
--- a/sys/dev/fdt/fdt_common.h
+++ b/sys/dev/fdt/fdt_common.h
@@ -81,6 +81,7 @@ u_long fdt_data_get(void *, int);
int fdt_data_to_res(pcell_t *, int, int, u_long *, u_long *);
phandle_t fdt_find_compatible(phandle_t, const char *, int);
phandle_t fdt_depth_search_compatible(phandle_t, const char *, int);
+phandle_t fdt_find_child(phandle_t, const char *);
int fdt_get_mem_regions(struct mem_region *, int *, uint32_t *);
int fdt_get_reserved_regions(struct mem_region *, int *);
int fdt_get_phyaddr(phandle_t, device_t, int *, void **);
OpenPOWER on IntegriCloud