aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc/kernel
diff options
context:
space:
mode:
authorStephen Rothwell <sfr@canb.auug.org.au>2007-04-24 03:57:33 -0400
committerStephen Rothwell <sfr@canb.auug.org.au>2007-07-19 23:39:06 -0400
commit1ef4d4242d9c494c49ae1ae66dc938fce0272816 (patch)
tree74c64ec940b306b5d1e7bb93a980041ad670468d /arch/sparc/kernel
parentd1cd355a5e44dfe993efc0c0458ca9f99a28a9a3 (diff)
Consolidate of_find_node_by routines
This consolidates the routines of_find_node_by_path, of_find_node_by_name, of_find_node_by_type and of_find_compatible_device. Again, the comparison of strings are done differently by Sparc and PowerPC and also these add read_locks around the iterations. 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 'arch/sparc/kernel')
-rw-r--r--arch/sparc/kernel/prom.c61
1 files changed, 1 insertions, 60 deletions
diff --git a/arch/sparc/kernel/prom.c b/arch/sparc/kernel/prom.c
index 3f8ccfad2e01..012f98346bcd 100644
--- a/arch/sparc/kernel/prom.c
+++ b/arch/sparc/kernel/prom.c
@@ -25,23 +25,10 @@
25#include <asm/prom.h> 25#include <asm/prom.h>
26#include <asm/oplib.h> 26#include <asm/oplib.h>
27 27
28static struct device_node *allnodes; 28extern struct device_node *allnodes; /* temporary while merging */
29 29
30extern rwlock_t devtree_lock; /* temporary while merging */ 30extern rwlock_t devtree_lock; /* temporary while merging */
31 31
32struct device_node *of_find_node_by_path(const char *path)
33{
34 struct device_node *np = allnodes;
35
36 for (; np != 0; np = np->allnext) {
37 if (np->full_name != 0 && strcmp(np->full_name, path) == 0)
38 break;
39 }
40
41 return np;
42}
43EXPORT_SYMBOL(of_find_node_by_path);
44
45struct device_node *of_find_node_by_phandle(phandle handle) 32struct device_node *of_find_node_by_phandle(phandle handle)
46{ 33{
47 struct device_node *np; 34 struct device_node *np;
@@ -54,52 +41,6 @@ struct device_node *of_find_node_by_phandle(phandle handle)
54} 41}
55EXPORT_SYMBOL(of_find_node_by_phandle); 42EXPORT_SYMBOL(of_find_node_by_phandle);
56 43
57struct device_node *of_find_node_by_name(struct device_node *from,
58 const char *name)
59{
60 struct device_node *np;
61
62 np = from ? from->allnext : allnodes;
63 for (; np != NULL; np = np->allnext)
64 if (np->name != NULL && strcmp(np->name, name) == 0)
65 break;
66
67 return np;
68}
69EXPORT_SYMBOL(of_find_node_by_name);
70
71struct device_node *of_find_node_by_type(struct device_node *from,
72 const char *type)
73{
74 struct device_node *np;
75
76 np = from ? from->allnext : allnodes;
77 for (; np != 0; np = np->allnext)
78 if (np->type != 0 && strcmp(np->type, type) == 0)
79 break;
80
81 return np;
82}
83EXPORT_SYMBOL(of_find_node_by_type);
84
85struct device_node *of_find_compatible_node(struct device_node *from,
86 const char *type, const char *compatible)
87{
88 struct device_node *np;
89
90 np = from ? from->allnext : allnodes;
91 for (; np != 0; np = np->allnext) {
92 if (type != NULL
93 && !(np->type != 0 && strcmp(np->type, type) == 0))
94 continue;
95 if (of_device_is_compatible(np, compatible))
96 break;
97 }
98
99 return np;
100}
101EXPORT_SYMBOL(of_find_compatible_node);
102
103int of_getintprop_default(struct device_node *np, const char *name, int def) 44int of_getintprop_default(struct device_node *np, const char *name, int def)
104{ 45{
105 struct property *prop; 46 struct property *prop;