Skip to contentSkip to conversation

PPC: add for_each_node_child() macro

RFC New Cyrill Gorcunov 1 participant 1 message Nov 16, 2007 Device tree

lore
Share & tools
lore
#0 lore raw

RFC 1/1 PPC: add for_each_node_child() macro

This patch adds usefull macro to iterate over a node childs.

---
TODO: convert all for(...) cycles to this macro.

 include/linux/of.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
include/linux/of.h +2 -0
index 5c39b92..a93e2aa 100644
@@ -46,6 +46,8 @@ 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_node_child(dn, child) \
+	for (child = NULL; (child = of_get_next_child(dn, child)); )
 extern struct property *of_find_property(const struct device_node *np,
 					 const char *name,
					 int *lenp);