aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc64
diff options
context:
space:
mode:
authorDavid S. Miller <davem@sunset.davemloft.net>2006-06-23 01:08:58 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2006-06-24 02:15:41 -0400
commit8cd24ed4f8031636fb5dacb04adee9e02556ecd5 (patch)
tree8a58e54a4181adf91d0ee2c4af6a92be7427f7cb /arch/sparc64
parent92c4e22593c22eb0943b232c61c98b517081637d (diff)
[SPARC64]: Expand of_*() interfaces some more.
Import some more stuff from powerpc. Add of_device_is_compatible(), and of_find_compatible_node(). Export some more of the other routines to modules. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc64')
-rw-r--r--arch/sparc64/kernel/prom.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/arch/sparc64/kernel/prom.c b/arch/sparc64/kernel/prom.c
index 7809100034b0..e9d703eea806 100644
--- a/arch/sparc64/kernel/prom.c
+++ b/arch/sparc64/kernel/prom.c
@@ -27,6 +27,26 @@
27 27
28static struct device_node *allnodes; 28static struct device_node *allnodes;
29 29
30int of_device_is_compatible(struct device_node *device, const char *compat)
31{
32 const char* cp;
33 int cplen, l;
34
35 cp = (char *) of_get_property(device, "compatible", &cplen);
36 if (cp == NULL)
37 return 0;
38 while (cplen > 0) {
39 if (strncmp(cp, compat, strlen(compat)) == 0)
40 return 1;
41 l = strlen(cp) + 1;
42 cp += l;
43 cplen -= l;
44 }
45
46 return 0;
47}
48EXPORT_SYMBOL(of_device_is_compatible);
49
30struct device_node *of_get_parent(const struct device_node *node) 50struct device_node *of_get_parent(const struct device_node *node)
31{ 51{
32 struct device_node *np; 52 struct device_node *np;
@@ -38,6 +58,7 @@ struct device_node *of_get_parent(const struct device_node *node)
38 58
39 return np; 59 return np;
40} 60}
61EXPORT_SYMBOL(of_get_parent);
41 62
42struct device_node *of_get_next_child(const struct device_node *node, 63struct device_node *of_get_next_child(const struct device_node *node,
43 struct device_node *prev) 64 struct device_node *prev)
@@ -51,6 +72,7 @@ struct device_node *of_get_next_child(const struct device_node *node,
51 72
52 return next; 73 return next;
53} 74}
75EXPORT_SYMBOL(of_get_next_child);
54 76
55struct device_node *of_find_node_by_path(const char *path) 77struct device_node *of_find_node_by_path(const char *path)
56{ 78{
@@ -75,6 +97,7 @@ struct device_node *of_find_node_by_phandle(phandle handle)
75 97
76 return np; 98 return np;
77} 99}
100EXPORT_SYMBOL(of_find_node_by_phandle);
78 101
79struct device_node *of_find_node_by_name(struct device_node *from, 102struct device_node *of_find_node_by_name(struct device_node *from,
80 const char *name) 103 const char *name)
@@ -88,6 +111,7 @@ struct device_node *of_find_node_by_name(struct device_node *from,
88 111
89 return np; 112 return np;
90} 113}
114EXPORT_SYMBOL(of_find_node_by_name);
91 115
92struct device_node *of_find_node_by_type(struct device_node *from, 116struct device_node *of_find_node_by_type(struct device_node *from,
93 const char *type) 117 const char *type)
@@ -101,6 +125,25 @@ struct device_node *of_find_node_by_type(struct device_node *from,
101 125
102 return np; 126 return np;
103} 127}
128EXPORT_SYMBOL(of_find_node_by_type);
129
130struct device_node *of_find_compatible_node(struct device_node *from,
131 const char *type, const char *compatible)
132{
133 struct device_node *np;
134
135 np = from ? from->allnext : allnodes;
136 for (; np != 0; np = np->allnext) {
137 if (type != NULL
138 && !(np->type != 0 && strcmp(np->type, type) == 0))
139 continue;
140 if (of_device_is_compatible(np, compatible))
141 break;
142 }
143
144 return np;
145}
146EXPORT_SYMBOL(of_find_compatible_node);
104 147
105struct property *of_find_property(struct device_node *np, const char *name, 148struct property *of_find_property(struct device_node *np, const char *name,
106 int *lenp) 149 int *lenp)