]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Consolidate of_device_is_compatible
authorStephen Rothwell <sfr@canb.auug.org.au>
Tue, 1 May 2007 06:29:19 +0000 (16:29 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Fri, 20 Jul 2007 03:29:51 +0000 (13:29 +1000)
The only difference here is that Sparc uses strncmp to match compatibility
names while PowerPC uses strncasecmp.

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 6c9419a4d70ad531ad37e7e5062cf3b226728bac..c009d2155f9cd590241fb2cdf8a77b0d7f21eaec 100644 (file)
@@ -1057,31 +1057,6 @@ void __init early_init_devtree(void *params)
 }
 
 
 }
 
 
-/** Checks if the given "compat" string matches one of the strings in
- * the device's "compatible" property
- */
-int of_device_is_compatible(const struct device_node *device,
-               const char *compat)
-{
-       const char* cp;
-       int cplen, l;
-
-       cp = of_get_property(device, "compatible", &cplen);
-       if (cp == NULL)
-               return 0;
-       while (cplen > 0) {
-               if (strncasecmp(cp, compat, strlen(compat)) == 0)
-                       return 1;
-               l = strlen(cp) + 1;
-               cp += l;
-               cplen -= l;
-       }
-
-       return 0;
-}
-EXPORT_SYMBOL(of_device_is_compatible);
-
-
 /**
  * Indicates whether the root node has a given value in its
  * compatible property.
 /**
  * Indicates whether the root node has a given value in its
  * compatible property.
index ac3f3c29b174c9b6c654f98a34d94211f1c7459d..f2ce0d48e102dca8f03ee723fef17d5537a0eb20 100644 (file)
@@ -32,27 +32,6 @@ static struct device_node *allnodes;
  */
 static DEFINE_RWLOCK(devtree_lock);
 
  */
 static DEFINE_RWLOCK(devtree_lock);
 
-int of_device_is_compatible(const struct device_node *device,
-                           const char *compat)
-{
-       const char* cp;
-       int cplen, l;
-
-       cp = of_get_property(device, "compatible", &cplen);
-       if (cp == NULL)
-               return 0;
-       while (cplen > 0) {
-               if (strncmp(cp, compat, strlen(compat)) == 0)
-                       return 1;
-               l = strlen(cp) + 1;
-               cp += l;
-               cplen -= l;
-       }
-
-       return 0;
-}
-EXPORT_SYMBOL(of_device_is_compatible);
-
 struct device_node *of_get_parent(const struct device_node *node)
 {
        struct device_node *np;
 struct device_node *of_get_parent(const struct device_node *node)
 {
        struct device_node *np;
index 8f926d439c0fb9e664ea111188e30e32f492b35a..4d6fb07f047fd43019587452d0d32981fb28b2f6 100644 (file)
@@ -37,27 +37,6 @@ static struct device_node *allnodes;
  */
 static DEFINE_RWLOCK(devtree_lock);
 
  */
 static DEFINE_RWLOCK(devtree_lock);
 
-int of_device_is_compatible(const struct device_node *device,
-                           const char *compat)
-{
-       const char* cp;
-       int cplen, l;
-
-       cp = of_get_property(device, "compatible", &cplen);
-       if (cp == NULL)
-               return 0;
-       while (cplen > 0) {
-               if (strncmp(cp, compat, strlen(compat)) == 0)
-                       return 1;
-               l = strlen(cp) + 1;
-               cp += l;
-               cplen -= l;
-       }
-
-       return 0;
-}
-EXPORT_SYMBOL(of_device_is_compatible);
-
 struct device_node *of_get_parent(const struct device_node *node)
 {
        struct device_node *np;
 struct device_node *of_get_parent(const struct device_node *node)
 {
        struct device_node *np;
index 723d80d704e063575d667b031c5251a14f6054e1..d6dc5e74c27c213b814337826342605c58a748cf 100644 (file)
@@ -63,3 +63,27 @@ const void *of_get_property(const struct device_node *np, const char *name,
        return pp ? pp->value : NULL;
 }
 EXPORT_SYMBOL(of_get_property);
        return pp ? pp->value : NULL;
 }
 EXPORT_SYMBOL(of_get_property);
+
+/** Checks if the given "compat" string matches one of the strings in
+ * the device's "compatible" property
+ */
+int of_device_is_compatible(const struct device_node *device,
+               const char *compat)
+{
+       const char* cp;
+       int cplen, l;
+
+       cp = of_get_property(device, "compatible", &cplen);
+       if (cp == NULL)
+               return 0;
+       while (cplen > 0) {
+               if (of_compat_cmp(cp, compat, strlen(compat)) == 0)
+                       return 1;
+               l = strlen(cp) + 1;
+               cp += l;
+               cplen -= l;
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL(of_device_is_compatible);
index 9fe0152ae245a63b8b5535d5a89f125bc7ca5eb9..b05f8f26940a50f6fe6f64f9e014ab1c318dbe1c 100644 (file)
@@ -24,6 +24,8 @@
 #define OF_ROOT_NODE_ADDR_CELLS_DEFAULT        1
 #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT        1
 
 #define OF_ROOT_NODE_ADDR_CELLS_DEFAULT        1
 #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT        1
 
+#define of_compat_cmp(s1, s2, l)       strncasecmp((s1), (s2), (l))
+
 /* Definitions used by the flattened device tree */
 #define OF_DT_HEADER           0xd00dfeed      /* marker */
 #define OF_DT_BEGIN_NODE       0x1             /* Start of node, full name */
 /* Definitions used by the flattened device tree */
 #define OF_DT_HEADER           0xd00dfeed      /* marker */
 #define OF_DT_BEGIN_NODE       0x1             /* Start of node, full name */
index a8a121f6332beff04247b324119177c9538bebb5..c755c69404f721c96b68c67d2738a2249252ee70 100644 (file)
@@ -23,6 +23,8 @@
 #define OF_ROOT_NODE_ADDR_CELLS_DEFAULT        2
 #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT        1
 
 #define OF_ROOT_NODE_ADDR_CELLS_DEFAULT        2
 #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT        1
 
+#define of_compat_cmp(s1, s2, l)       strncmp((s1), (s2), (l))
+
 typedef u32 phandle;
 typedef u32 ihandle;
 
 typedef u32 phandle;
 typedef u32 ihandle;
 
index c98d1545ee8dcfc70824e3138128ed7d88db016a..040d198ee8427623baf846338043e1c90c0ebb1a 100644 (file)
@@ -23,6 +23,8 @@
 #define OF_ROOT_NODE_ADDR_CELLS_DEFAULT        2
 #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT        1
 
 #define OF_ROOT_NODE_ADDR_CELLS_DEFAULT        2
 #define OF_ROOT_NODE_SIZE_CELLS_DEFAULT        1
 
+#define of_compat_cmp(s1, s2, l)       strncmp((s1), (s2), (l))
+
 typedef u32 phandle;
 typedef u32 ihandle;
 
 typedef u32 phandle;
 typedef u32 ihandle;