]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Consolidate of_find_property
authorStephen Rothwell <sfr@canb.auug.org.au>
Tue, 24 Apr 2007 06:46:53 +0000 (16:46 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Fri, 20 Jul 2007 03:32:24 +0000 (13:32 +1000)
The only change here is that a readlock is taken while the property list
is being traversed on Sparc where it was not taken previously.

Also, Sparc uses strcasecmp to compare property names while PowerPC
uses strcmp.

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
include/asm-powerpc/prom.h
include/asm-sparc/prom.h
include/asm-sparc64/prom.h

index c009d2155f9cd590241fb2cdf8a77b0d7f21eaec..3f6238d96a5d4eba65284e46dc4ddd49ac82fde1 100644 (file)
@@ -80,10 +80,7 @@ struct boot_param_header *initial_boot_params;
 
 static struct device_node *allnodes = NULL;
 
 
 static struct device_node *allnodes = NULL;
 
-/* use when traversing tree through the allnext, child, sibling,
- * or parent members of struct device_node.
- */
-static DEFINE_RWLOCK(devtree_lock);
+extern rwlock_t devtree_lock;  /* temporary while merging */
 
 /* export that to outside world */
 struct device_node *of_chosen;
 
 /* export that to outside world */
 struct device_node *of_chosen;
@@ -1489,25 +1486,6 @@ static int __init prom_reconfig_setup(void)
 __initcall(prom_reconfig_setup);
 #endif
 
 __initcall(prom_reconfig_setup);
 #endif
 
-struct property *of_find_property(const struct device_node *np,
-                                 const char *name,
-                                 int *lenp)
-{
-       struct property *pp;
-
-       read_lock(&devtree_lock);
-       for (pp = np->properties; pp != 0; pp = pp->next)
-               if (strcmp(pp->name, name) == 0) {
-                       if (lenp != 0)
-                               *lenp = pp->length;
-                       break;
-               }
-       read_unlock(&devtree_lock);
-
-       return pp;
-}
-EXPORT_SYMBOL(of_find_property);
-
 /*
  * Add a property to a node
  */
 /*
  * Add a property to a node
  */
index f2ce0d48e102dca8f03ee723fef17d5537a0eb20..0f5aab4326b3e7bf1d6f995e1a90d7d53079bc27 100644 (file)
 
 static struct device_node *allnodes;
 
 
 static struct device_node *allnodes;
 
-/* use when traversing tree through the allnext, child, sibling,
- * or parent members of struct device_node.
- */
-static DEFINE_RWLOCK(devtree_lock);
+extern rwlock_t devtree_lock;  /* temporary while merging */
 
 struct device_node *of_get_parent(const struct device_node *node)
 {
 
 struct device_node *of_get_parent(const struct device_node *node)
 {
@@ -130,23 +127,6 @@ struct device_node *of_find_compatible_node(struct device_node *from,
 }
 EXPORT_SYMBOL(of_find_compatible_node);
 
 }
 EXPORT_SYMBOL(of_find_compatible_node);
 
-struct property *of_find_property(const struct device_node *np,
-                                 const char *name,
-                                 int *lenp)
-{
-       struct property *pp;
-
-       for (pp = np->properties; pp != 0; pp = pp->next) {
-               if (strcasecmp(pp->name, name) == 0) {
-                       if (lenp != 0)
-                               *lenp = pp->length;
-                       break;
-               }
-       }
-       return pp;
-}
-EXPORT_SYMBOL(of_find_property);
-
 int of_getintprop_default(struct device_node *np, const char *name, int def)
 {
        struct property *prop;
 int of_getintprop_default(struct device_node *np, const char *name, int def)
 {
        struct property *prop;
index 4d6fb07f047fd43019587452d0d32981fb28b2f6..a1ccc00c7958d350905cfd8dfbf1d0c646040b67 100644 (file)
 
 static struct device_node *allnodes;
 
 
 static struct device_node *allnodes;
 
-/* use when traversing tree through the allnext, child, sibling,
- * or parent members of struct device_node.
- */
-static DEFINE_RWLOCK(devtree_lock);
+extern rwlock_t devtree_lock;  /* temporary while merging */
 
 struct device_node *of_get_parent(const struct device_node *node)
 {
 
 struct device_node *of_get_parent(const struct device_node *node)
 {
@@ -135,23 +132,6 @@ struct device_node *of_find_compatible_node(struct device_node *from,
 }
 EXPORT_SYMBOL(of_find_compatible_node);
 
 }
 EXPORT_SYMBOL(of_find_compatible_node);
 
-struct property *of_find_property(const struct device_node *np,
-                                 const char *name,
-                                 int *lenp)
-{
-       struct property *pp;
-
-       for (pp = np->properties; pp != 0; pp = pp->next) {
-               if (strcasecmp(pp->name, name) == 0) {
-                       if (lenp != 0)
-                               *lenp = pp->length;
-                       break;
-               }
-       }
-       return pp;
-}
-EXPORT_SYMBOL(of_find_property);
-
 int of_getintprop_default(struct device_node *np, const char *name, int def)
 {
        struct property *prop;
 int of_getintprop_default(struct device_node *np, const char *name, int def)
 {
        struct property *prop;
index d6dc5e74c27c213b814337826342605c58a748cf..70b60845140e9168db718be0cf540a0337f3c17e 100644 (file)
  */
 #include <linux/module.h>
 #include <linux/of.h>
  */
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/spinlock.h>
+
+/* use when traversing tree through the allnext, child, sibling,
+ * or parent members of struct device_node.
+ */
+DEFINE_RWLOCK(devtree_lock);
 
 int of_n_addr_cells(struct device_node *np)
 {
 
 int of_n_addr_cells(struct device_node *np)
 {
@@ -51,6 +57,26 @@ int of_n_size_cells(struct device_node *np)
 }
 EXPORT_SYMBOL(of_n_size_cells);
 
 }
 EXPORT_SYMBOL(of_n_size_cells);
 
+struct property *of_find_property(const struct device_node *np,
+                                 const char *name,
+                                 int *lenp)
+{
+       struct property *pp;
+
+       read_lock(&devtree_lock);
+       for (pp = np->properties; pp != 0; pp = pp->next) {
+               if (of_prop_cmp(pp->name, name) == 0) {
+                       if (lenp != 0)
+                               *lenp = pp->length;
+                       break;
+               }
+       }
+       read_unlock(&devtree_lock);
+
+       return pp;
+}
+EXPORT_SYMBOL(of_find_property);
+
 /*
  * Find a property with a given name for a given node
  * and return the value.
 /*
  * Find a property with a given name for a given node
  * and return the value.
index b05f8f26940a50f6fe6f64f9e014ab1c318dbe1c..75b1144ca580abade65b0887efac6f8ce41420cb 100644 (file)
@@ -25,6 +25,7 @@
 #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT        1
 
 #define of_compat_cmp(s1, s2, l)       strncasecmp((s1), (s2), (l))
 #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT        1
 
 #define of_compat_cmp(s1, s2, l)       strncasecmp((s1), (s2), (l))
+#define of_prop_cmp(s1, s2)            strcmp((s1), (s2))
 
 /* Definitions used by the flattened device tree */
 #define OF_DT_HEADER           0xd00dfeed      /* marker */
 
 /* Definitions used by the flattened device tree */
 #define OF_DT_HEADER           0xd00dfeed      /* marker */
index c755c69404f721c96b68c67d2738a2249252ee70..57f86c84293b39d0c8eb523fec01ea8a4fdfa528 100644 (file)
@@ -24,6 +24,7 @@
 #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT        1
 
 #define of_compat_cmp(s1, s2, l)       strncmp((s1), (s2), (l))
 #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT        1
 
 #define of_compat_cmp(s1, s2, l)       strncmp((s1), (s2), (l))
+#define of_prop_cmp(s1, s2)            strcasecmp((s1), (s2))
 
 typedef u32 phandle;
 typedef u32 ihandle;
 
 typedef u32 phandle;
 typedef u32 ihandle;
index 040d198ee8427623baf846338043e1c90c0ebb1a..6a5e2405cbf4e87c12ebb2f3bd1ba3e5e5c5b7be 100644 (file)
@@ -24,6 +24,7 @@
 #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT        1
 
 #define of_compat_cmp(s1, s2, l)       strncmp((s1), (s2), (l))
 #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT        1
 
 #define of_compat_cmp(s1, s2, l)       strncmp((s1), (s2), (l))
+#define of_prop_cmp(s1, s2)            strcasecmp((s1), (s2))
 
 typedef u32 phandle;
 typedef u32 ihandle;
 
 typedef u32 phandle;
 typedef u32 ihandle;