summaryrefslogtreecommitdiff
path: root/drivers/of
diff options
context:
space:
mode:
authorStephen Rothwell <sfr@canb.auug.org.au>2007-04-24 16:46:53 +1000
committerStephen Rothwell <sfr@canb.auug.org.au>2007-07-20 13:32:24 +1000
commit581b605a83ec241a2aff8ef780e08b9414c8dfd8 (patch)
tree809640a0dc3a1bd0b5afba795cf9f6357f6e3a81 /drivers/of
parent0081cbc3731de8ad4744ba433af51f17bf27eb9c (diff)
downloadkernel-common-581b605a83ec241a2aff8ef780e08b9414c8dfd8.tar.gz
kernel-common-581b605a83ec241a2aff8ef780e08b9414c8dfd8.tar.bz2
kernel-common-581b605a83ec241a2aff8ef780e08b9414c8dfd8.zip
Consolidate of_find_property
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>
Diffstat (limited to 'drivers/of')
-rw-r--r--drivers/of/base.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c
index d6dc5e74c27c..70b60845140e 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -18,6 +18,12 @@
*/
#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)
{
@@ -51,6 +57,26 @@ int of_n_size_cells(struct device_node *np)
}
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.