diff options
author | Trent Piepho <tpiepho@kymetacorp.com> | 2015-12-19 00:13:59 +0000 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2016-01-08 08:30:56 +0100 |
commit | 3a51749e2e7572d5b145bb110298372a82b16e41 (patch) | |
tree | 4b819ecd4922635409d51894ecd2020f556bafad /include | |
parent | 76b059f311a3e79afea055618f692591c618e6d6 (diff) | |
download | barebox-3a51749e2e7572d5b145bb110298372a82b16e41.tar.gz barebox-3a51749e2e7572d5b145bb110298372a82b16e41.tar.xz |
of: Add for_each_compatible_node_from iterator
The existing iterator for_each_compatible_node() searches for each
compatible node starting from the root of the loaded device tree.
This means it only works on the barebox device tree and not the tree
to be passed to the Linux kernel, which is what an of_fixup would
probably want to use.
This adds for_each_compatible_node_from(), which takes an additional
parameter of a root to search from. This could be the device tree to
be used for the kernel. It could also be used to search just a
subtree.
Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include')
-rw-r--r-- | include/of.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/include/of.h b/include/of.h index e60fe89825..82faf25d62 100644 --- a/include/of.h +++ b/include/of.h @@ -641,9 +641,13 @@ static inline struct device_node *of_find_node_by_path_or_alias( #define for_each_node_by_name_from(dn, root, name) \ for (dn = of_find_node_by_name(root, name); dn; \ dn = of_find_node_by_name(dn, name)) -#define for_each_compatible_node(dn, type, compatible) \ - for (dn = of_find_compatible_node(NULL, type, compatible); dn; \ +/* Iterate over compatible nodes starting from given root */ +#define for_each_compatible_node_from(dn, root, type, compatible) \ + for (dn = of_find_compatible_node(root, type, compatible); dn; \ dn = of_find_compatible_node(dn, type, compatible)) +/* Iterate over compatible nodes in default device tree */ +#define for_each_compatible_node(dn, type, compatible) \ + for_each_compatible_node_from(dn, NULL, type, compatible) static inline struct device_node *of_find_matching_node( struct device_node *from, const struct of_device_id *matches) |