diff options
author | ian <ian@FreeBSD.org> | 2014-02-16 03:00:59 +0000 |
---|---|---|
committer | ian <ian@FreeBSD.org> | 2014-02-16 03:00:59 +0000 |
commit | 30ad8ad3f38c02e4e093fe423d7d1dbc4e9a82a5 (patch) | |
tree | 3a9ed840dc211366e13bd5de66192a3b2ab9a684 /sys/dev/fdt/fdt_common.c | |
parent | 0b53b054d5c1e7aaeb76ec14066ec9aca71fa933 (diff) | |
download | FreeBSD-src-30ad8ad3f38c02e4e093fe423d7d1dbc4e9a82a5.zip FreeBSD-src-30ad8ad3f38c02e4e093fe423d7d1dbc4e9a82a5.tar.gz |
Add a helper routine to depth-search the device tree for a node with a
matching 'compatible' property. This probably has a short half-life (as
do most of the fdt_ functions), but it helps solve some near-term needs
until we work out the larger problems of device instantiation order
versus the order of things in the fdt data.
Diffstat (limited to 'sys/dev/fdt/fdt_common.c')
-rw-r--r-- | sys/dev/fdt/fdt_common.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/sys/dev/fdt/fdt_common.c b/sys/dev/fdt/fdt_common.c index 33a137b..64c28db 100644 --- a/sys/dev/fdt/fdt_common.c +++ b/sys/dev/fdt/fdt_common.c @@ -223,6 +223,27 @@ fdt_find_compatible(phandle_t start, const char *compat, int strict) return (0); } +phandle_t +fdt_depth_search_compatible(phandle_t start, const char *compat, int strict) +{ + phandle_t child, node; + + /* + * Depth-search all descendants of 'start' node, and find first with + * matching 'compatible' property. + */ + for (node = OF_child(start); node != 0; node = OF_peer(node)) { + if (fdt_is_compatible(node, compat) && + (strict == 0 || fdt_is_compatible_strict(node, compat))) { + return (node); + } + child = fdt_search_compatible(node, compat, strict); + if (child != 0) + return (child); + } + return (0); +} + int fdt_is_enabled(phandle_t node) { |