summaryrefslogtreecommitdiffstats
path: root/sys/dev/fdt/fdt_common.c
diff options
context:
space:
mode:
authorgonzo <gonzo@FreeBSD.org>2015-05-22 02:00:44 +0000
committergonzo <gonzo@FreeBSD.org>2015-05-22 02:00:44 +0000
commit721376a5c9d5d2b8efdd1a396039113b3030ba73 (patch)
tree050a14614b2fdd1fe90a09d2053c6fcbf1a33cfb /sys/dev/fdt/fdt_common.c
parentd4a944133dd8aae5171fd708f5251632d6b5dc5b (diff)
downloadFreeBSD-src-721376a5c9d5d2b8efdd1a396039113b3030ba73.zip
FreeBSD-src-721376a5c9d5d2b8efdd1a396039113b3030ba73.tar.gz
Add helper method fdt_find_child to make access to child nodes easier.
Some FDT nodes have complex properties organized as a child sub-nodes (e.g. timing for LCD panel) we need easy way to obtain handles for these sub-nodes
Diffstat (limited to 'sys/dev/fdt/fdt_common.c')
-rw-r--r--sys/dev/fdt/fdt_common.c17
1 files changed, 17 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;
OpenPOWER on IntegriCloud