[PATCH] powerpc: add for_each_node_by_foo helpers

Christoph Hellwig hch at lst.de
Thu Mar 9 02:47:00 EST 2006


Typical use for of_find_node_by_name and of_find_node_by_type is to
iterate over all nodes of a given type/name.  Add a helper macro to
do that (in spirit of the list_for_each* macros).


Signed-off-by: Christoph Hellwig <hch at lst.de>

Index: linux-2.6/include/asm-powerpc/prom.h
===================================================================
--- linux-2.6.orig/include/asm-powerpc/prom.h	2006-02-10 19:45:44.000000000 +0100
+++ linux-2.6/include/asm-powerpc/prom.h	2006-03-08 16:41:46.000000000 +0100
@@ -126,8 +126,14 @@
 /* New style node lookup */
 extern struct device_node *of_find_node_by_name(struct device_node *from,
 	const char *name);
+#define for_each_node_by_name(dn, name) \
+	for (dn = of_find_node_by_name(NULL, name); dn; \
+	     dn = of_find_node_by_name(dn, name))
 extern struct device_node *of_find_node_by_type(struct device_node *from,
 	const char *type);
+#define for_each_node_by_type(dn, type) \
+	for (dn = of_find_node_by_type(NULL, type); dn; \
+	     dn = of_find_node_by_type(dn, type))
 extern struct device_node *of_find_compatible_node(struct device_node *from,
 	const char *type, const char *compat);
 extern struct device_node *of_find_node_by_path(const char *path);



More information about the Linuxppc64-dev mailing list