[PATCH] Add for_each_child_of_node() helper for iterating over child nodes
Michael Ellerman
michael at ellerman.id.au
Mon Nov 26 19:03:45 EST 2007
Add for_each_child_of_node() to encapsulate the common idiom of
iterating over the children of a device_node.
Signed-off-by: Michael Ellerman <michael at ellerman.id.au>
---
After conducting a straw pole of powerpc hackers, this seems to be the
preferred name for such a beast.
include/linux/of.h | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/include/linux/of.h b/include/linux/of.h
index 5c39b92..c65af7b 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -46,6 +46,10 @@ extern struct device_node *of_find_node_by_phandle(phandle handle);
extern struct device_node *of_get_parent(const struct device_node *node);
extern struct device_node *of_get_next_child(const struct device_node *node,
struct device_node *prev);
+#define for_each_child_of_node(parent, child) \
+ for (child = of_get_next_child(parent, NULL); child != NULL; \
+ child = of_get_next_child(parent, child))
+
extern struct property *of_find_property(const struct device_node *np,
const char *name,
int *lenp);
--
1.5.2.rc1.1884.g59b20
More information about the Linuxppc-dev
mailing list