Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=d1cd355a5e44dfe993efc0c0458ca9f99a28a9a3
Commit:     d1cd355a5e44dfe993efc0c0458ca9f99a28a9a3
Parent:     e679c5f445fe142940e0962de9c5c82f10d9357c
Author:     Stephen Rothwell <[EMAIL PROTECTED]>
AuthorDate: Tue Apr 24 17:21:29 2007 +1000
Committer:  Stephen Rothwell <[EMAIL PROTECTED]>
CommitDate: Fri Jul 20 13:34:26 2007 +1000

    Consolidate of_get_next_child
    
    This adds a read_lock around the child/next accesses on Sparc.
    
    Signed-off-by: Stephen Rothwell <[EMAIL PROTECTED]>
    Acked-by: Paul Mackerras <[EMAIL PROTECTED]>
    Acked-by: David S. Miller <[EMAIL PROTECTED]>
---
 arch/powerpc/kernel/prom.c |   24 ------------------------
 arch/sparc/kernel/prom.c   |   14 --------------
 arch/sparc64/kernel/prom.c |   14 --------------
 drivers/of/base.c          |   24 ++++++++++++++++++++++++
 4 files changed, 24 insertions(+), 52 deletions(-)

diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 1ad56d3..5fa221c 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -1241,30 +1241,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
  *             simplify writing of callers
diff --git a/arch/sparc/kernel/prom.c b/arch/sparc/kernel/prom.c
index b378715..3f8ccfa 100644
--- a/arch/sparc/kernel/prom.c
+++ b/arch/sparc/kernel/prom.c
@@ -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;
diff --git a/arch/sparc64/kernel/prom.c b/arch/sparc64/kernel/prom.c
index 2462731..ee96ef6 100644
--- a/arch/sparc64/kernel/prom.c
+++ b/arch/sparc64/kernel/prom.c
@@ -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;
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 82bb786..6b6dfcc 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -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);
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to