aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc64
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/sparc64
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/sparc64')
-rw-r--r--arch/sparc64/kernel/prom.c61
1 files changed, 1 insertions, 60 deletions
diff --git a/arch/sparc64/kernel/prom.c b/arch/sparc64/kernel/prom.c
index ee96ef61bc99..2b2017ce2267 100644
--- a/arch/sparc64/kernel/prom.c
+++ b/arch/sparc64/kernel/prom.c
@@ -30,23 +30,10 @@
30#include <asm/upa.h> 30#include <asm/upa.h>
31#include <asm/smp.h> 31#include <asm/smp.h>
32 32
33static struct device_node *allnodes; 33extern struct device_node *allnodes; /* temporary while merging */
34 34
35extern rwlock_t devtree_lock; /* temporary while merging */ 35extern rwlock_t devtree_lock; /* temporary while merging */
36 36
37struct device_node *of_find_node_by_path(const char *path)
38{
39 struct device_node *np = allnodes;
40
41 for (; np != 0; np = np->allnext) {
42 if (np->full_name != 0 && strcmp(np->full_name, path) == 0)
43 break;
44 }
45
46 return np;
47}
48EXPORT_SYMBOL(of_find_node_by_path);
49
50struct device_node *of_find_node_by_phandle(phandle handle) 37struct device_node *of_find_node_by_phandle(phandle handle)
51{ 38{
52 struct device_node *np; 39 struct device_node *np;
@@ -59,52 +46,6 @@ struct device_node *of_find_node_by_phandle(phandle handle)
59} 46}
60EXPORT_SYMBOL(of_find_node_by_phandle); 47EXPORT_SYMBOL(of_find_node_by_phandle);
61 48
62struct device_node *of_find_node_by_name(struct device_node *from,
63 const char *name)
64{
65 struct device_node *np;
66
67 np = from ? from->allnext : allnodes;
68 for (; np != NULL; np = np->allnext)
69 if (np->name != NULL && strcmp(np->name, name) == 0)
70 break;
71
72 return np;
73}
74EXPORT_SYMBOL(of_find_node_by_name);
75
76struct device_node *of_find_node_by_type(struct device_node *from,
77 const char *type)
78{
79 struct device_node *np;
80
81 np = from ? from->allnext : allnodes;
82 for (; np != 0; np = np->allnext)
83 if (np->type != 0 && strcmp(np->type, type) == 0)
84 break;
85
86 return np;
87}
88EXPORT_SYMBOL(of_find_node_by_type);
89
90struct device_node *of_find_compatible_node(struct device_node *from,
91 const char *type, const char *compatible)
92{
93 struct device_node *np;
94
95 np = from ? from->allnext : allnodes;
96 for (; np != 0; np = np->allnext) {
97 if (type != NULL
98 && !(np->type != 0 && strcmp(np->type, type) == 0))
99 continue;
100 if (of_device_is_compatible(np, compatible))
101 break;
102 }
103
104 return np;
105}
106EXPORT_SYMBOL(of_find_compatible_node);
107
108int of_getintprop_default(struct device_node *np, const char *name, int def) 49int of_getintprop_default(struct device_node *np, const char *name, int def)
109{ 50{
110 struct property *prop; 51 struct property *prop;