From: Michael Ellerman Date: Mon, 26 Nov 2007 08:03:45 +0000 (+1100) Subject: [POWERPC] Add for_each_child_of_node() helper for iterating over child nodes X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=aabc08dc662b7acb17ca5706533253ce10c050b1;p=deliverable%2Flinux.git [POWERPC] Add for_each_child_of_node() helper for iterating over child nodes 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 Acked-by: Stephen Rothwell Signed-off-by: Paul Mackerras --- diff --git a/include/linux/of.h b/include/linux/of.h index 5c39b9270ff7..c65af7bd1e9c 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);