aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/of/base.c
diff options
context:
space:
mode:
authorStephen Rothwell <sfr@canb.auug.org.au>2007-04-24 02:46:53 -0400
committerStephen Rothwell <sfr@canb.auug.org.au>2007-07-19 23:32:24 -0400
commit581b605a83ec241a2aff8ef780e08b9414c8dfd8 (patch)
tree809640a0dc3a1bd0b5afba795cf9f6357f6e3a81 /drivers/of/base.c
parent0081cbc3731de8ad4744ba433af51f17bf27eb9c (diff)
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/base.c')
-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 d6dc5e74c27..70b60845140 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -18,6 +18,12 @@
18 */ 18 */
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/of.h> 20#include <linux/of.h>
21#include <linux/spinlock.h>
22
23/* use when traversing tree through the allnext, child, sibling,
24 * or parent members of struct device_node.
25 */
26DEFINE_RWLOCK(devtree_lock);
21 27
22int of_n_addr_cells(struct device_node *np) 28int of_n_addr_cells(struct device_node *np)
23{ 29{
@@ -51,6 +57,26 @@ int of_n_size_cells(struct device_node *np)
51} 57}
52EXPORT_SYMBOL(of_n_size_cells); 58EXPORT_SYMBOL(of_n_size_cells);
53 59
60struct property *of_find_property(const struct device_node *np,
61 const char *name,
62 int *lenp)
63{
64 struct property *pp;
65
66 read_lock(&devtree_lock);
67 for (pp = np->properties; pp != 0; pp = pp->next) {
68 if (of_prop_cmp(pp->name, name) == 0) {
69 if (lenp != 0)
70 *lenp = pp->length;
71 break;
72 }
73 }
74 read_unlock(&devtree_lock);
75
76 return pp;
77}
78EXPORT_SYMBOL(of_find_property);
79
54/* 80/*
55 * Find a property with a given name for a given node 81 * Find a property with a given name for a given node
56 * and return the value. 82 * and return the value.