]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Consolidate of_get_next_child
authorStephen Rothwell <sfr@canb.auug.org.au>
Tue, 24 Apr 2007 07:21:29 +0000 (17:21 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Fri, 20 Jul 2007 03:34:26 +0000 (13:34 +1000)
This adds a read_lock around the child/next accesses on Sparc.

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Acked-by: Paul Mackerras <paulus@samba.org>
Acked-by: David S. Miller <davem@davemloft.net>
arch/powerpc/kernel/prom.c
arch/sparc/kernel/prom.c
arch/sparc64/kernel/prom.c
drivers/of/base.c

index 1ad56d3c6061cd18353c94b73358411d2956fb18..5fa221ce87148ae385b3787b0fc076d998eafe6d 100644 (file)
@@ -1240,30 +1240,6 @@ struct device_node *of_find_all_nodes(struct device_node *prev)
 }
 EXPORT_SYMBOL(of_find_all_nodes);
 
-/**
- *     of_get_next_child - Iterate a node childs
- *     @node:  parent node
- *     @prev:  previous child of the parent node, or NULL to get first
- *
- *     Returns a node pointer with refcount incremented, use
- *     of_node_put() on it when done.
- */
-struct device_node *of_get_next_child(const struct device_node *node,
-       struct device_node *prev)
-{
-       struct device_node *next;
-
-       read_lock(&devtree_lock);
-       next = prev ? prev->sibling : node->child;
-       for (; next != 0; next = next->sibling)
-               if (of_node_get(next))
-                       break;
-       of_node_put(prev);
-       read_unlock(&devtree_lock);
-       return next;
-}
-EXPORT_SYMBOL(of_get_next_child);
-
 /**
  *     of_node_get - Increment refcount of a node
  *     @node:  Node to inc refcount, NULL is supported to
index b3787157808775a663eecea69a2226deece33dee..3f8ccfad2e013252dc1dc1cdf4abe07bb0184185 100644 (file)
@@ -29,20 +29,6 @@ static struct device_node *allnodes;
 
 extern rwlock_t devtree_lock;  /* temporary while merging */
 
-struct device_node *of_get_next_child(const struct device_node *node,
-       struct device_node *prev)
-{
-       struct device_node *next;
-
-       next = prev ? prev->sibling : node->child;
-       for (; next != 0; next = next->sibling) {
-               break;
-       }
-
-       return next;
-}
-EXPORT_SYMBOL(of_get_next_child);
-
 struct device_node *of_find_node_by_path(const char *path)
 {
        struct device_node *np = allnodes;
index 2462731ac1a3efec4b006ff0484eee9451e9ed3e..ee96ef61bc997cac31dc6dd4bae860599550774d 100644 (file)
@@ -34,20 +34,6 @@ static struct device_node *allnodes;
 
 extern rwlock_t devtree_lock;  /* temporary while merging */
 
-struct device_node *of_get_next_child(const struct device_node *node,
-       struct device_node *prev)
-{
-       struct device_node *next;
-
-       next = prev ? prev->sibling : node->child;
-       for (; next != 0; next = next->sibling) {
-               break;
-       }
-
-       return next;
-}
-EXPORT_SYMBOL(of_get_next_child);
-
 struct device_node *of_find_node_by_path(const char *path)
 {
        struct device_node *np = allnodes;
index 82bb78680ff6ca73117898d5f2354dd497f6d37f..6b6dfcc56522122ff4e5f99af3d227318cef8b40 100644 (file)
@@ -134,3 +134,27 @@ struct device_node *of_get_parent(const struct device_node *node)
        return np;
 }
 EXPORT_SYMBOL(of_get_parent);
+
+/**
+ *     of_get_next_child - Iterate a node childs
+ *     @node:  parent node
+ *     @prev:  previous child of the parent node, or NULL to get first
+ *
+ *     Returns a node pointer with refcount incremented, use
+ *     of_node_put() on it when done.
+ */
+struct device_node *of_get_next_child(const struct device_node *node,
+       struct device_node *prev)
+{
+       struct device_node *next;
+
+       read_lock(&devtree_lock);
+       next = prev ? prev->sibling : node->child;
+       for (; next; next = next->sibling)
+               if (of_node_get(next))
+                       break;
+       of_node_put(prev);
+       read_unlock(&devtree_lock);
+       return next;
+}
+EXPORT_SYMBOL(of_get_next_child);