[POWERPC] Add for_each_child_of_node() helper for iterating over child nodes
authorMichael Ellerman <michael@ellerman.id.au>
Mon, 26 Nov 2007 08:03:45 +0000 (19:03 +1100)
committerPaul Mackerras <paulus@samba.org>
Tue, 11 Dec 2007 02:34:39 +0000 (13:34 +1100)
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@ellerman.id.au>
Acked-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
include/linux/of.h

index 5c39b9270ff7007b359df90a7cfc407607ddb7ab..c65af7bd1e9c6369757dfaeeecf74feccea83f97 100644 (file)
@@ -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);