diff options
Diffstat (limited to 'arch/sparc64/kernel/prom.c')
-rw-r--r-- | arch/sparc64/kernel/prom.c | 173 |
1 files changed, 2 insertions, 171 deletions
diff --git a/arch/sparc64/kernel/prom.c b/arch/sparc64/kernel/prom.c index 5d220302cd50..2b2017ce2267 100644 --- a/arch/sparc64/kernel/prom.c +++ b/arch/sparc64/kernel/prom.c | |||
@@ -30,73 +30,9 @@ | |||
30 | #include <asm/upa.h> | 30 | #include <asm/upa.h> |
31 | #include <asm/smp.h> | 31 | #include <asm/smp.h> |
32 | 32 | ||
33 | static struct device_node *allnodes; | 33 | extern struct device_node *allnodes; /* temporary while merging */ |
34 | 34 | ||
35 | /* use when traversing tree through the allnext, child, sibling, | 35 | extern rwlock_t devtree_lock; /* temporary while merging */ |
36 | * or parent members of struct device_node. | ||
37 | */ | ||
38 | static DEFINE_RWLOCK(devtree_lock); | ||
39 | |||
40 | int of_device_is_compatible(const struct device_node *device, | ||
41 | const char *compat) | ||
42 | { | ||
43 | const char* cp; | ||
44 | int cplen, l; | ||
45 | |||
46 | cp = of_get_property(device, "compatible", &cplen); | ||
47 | if (cp == NULL) | ||
48 | return 0; | ||
49 | while (cplen > 0) { | ||
50 | if (strncmp(cp, compat, strlen(compat)) == 0) | ||
51 | return 1; | ||
52 | l = strlen(cp) + 1; | ||
53 | cp += l; | ||
54 | cplen -= l; | ||
55 | } | ||
56 | |||
57 | return 0; | ||
58 | } | ||
59 | EXPORT_SYMBOL(of_device_is_compatible); | ||
60 | |||
61 | struct device_node *of_get_parent(const struct device_node *node) | ||
62 | { | ||
63 | struct device_node *np; | ||
64 | |||
65 | if (!node) | ||
66 | return NULL; | ||
67 | |||
68 | np = node->parent; | ||
69 | |||
70 | return np; | ||
71 | } | ||
72 | EXPORT_SYMBOL(of_get_parent); | ||
73 | |||
74 | struct device_node *of_get_next_child(const struct device_node *node, | ||
75 | struct device_node *prev) | ||
76 | { | ||
77 | struct device_node *next; | ||
78 | |||
79 | next = prev ? prev->sibling : node->child; | ||
80 | for (; next != 0; next = next->sibling) { | ||
81 | break; | ||
82 | } | ||
83 | |||
84 | return next; | ||
85 | } | ||
86 | EXPORT_SYMBOL(of_get_next_child); | ||
87 | |||
88 | struct device_node *of_find_node_by_path(const char *path) | ||
89 | { | ||
90 | struct device_node *np = allnodes; | ||
91 | |||
92 | for (; np != 0; np = np->allnext) { | ||
93 | if (np->full_name != 0 && strcmp(np->full_name, path) == 0) | ||
94 | break; | ||
95 | } | ||
96 | |||
97 | return np; | ||
98 | } | ||
99 | EXPORT_SYMBOL(of_find_node_by_path); | ||
100 | 36 | ||
101 | struct device_node *of_find_node_by_phandle(phandle handle) | 37 | struct device_node *of_find_node_by_phandle(phandle handle) |
102 | { | 38 | { |
@@ -110,81 +46,6 @@ struct device_node *of_find_node_by_phandle(phandle handle) | |||
110 | } | 46 | } |
111 | EXPORT_SYMBOL(of_find_node_by_phandle); | 47 | EXPORT_SYMBOL(of_find_node_by_phandle); |
112 | 48 | ||
113 | struct device_node *of_find_node_by_name(struct device_node *from, | ||
114 | const char *name) | ||
115 | { | ||
116 | struct device_node *np; | ||
117 | |||
118 | np = from ? from->allnext : allnodes; | ||
119 | for (; np != NULL; np = np->allnext) | ||
120 | if (np->name != NULL && strcmp(np->name, name) == 0) | ||
121 | break; | ||
122 | |||
123 | return np; | ||
124 | } | ||
125 | EXPORT_SYMBOL(of_find_node_by_name); | ||
126 | |||
127 | struct device_node *of_find_node_by_type(struct device_node *from, | ||
128 | const char *type) | ||
129 | { | ||
130 | struct device_node *np; | ||
131 | |||
132 | np = from ? from->allnext : allnodes; | ||
133 | for (; np != 0; np = np->allnext) | ||
134 | if (np->type != 0 && strcmp(np->type, type) == 0) | ||
135 | break; | ||
136 | |||
137 | return np; | ||
138 | } | ||
139 | EXPORT_SYMBOL(of_find_node_by_type); | ||
140 | |||
141 | struct device_node *of_find_compatible_node(struct device_node *from, | ||
142 | const char *type, const char *compatible) | ||
143 | { | ||
144 | struct device_node *np; | ||
145 | |||
146 | np = from ? from->allnext : allnodes; | ||
147 | for (; np != 0; np = np->allnext) { | ||
148 | if (type != NULL | ||
149 | && !(np->type != 0 && strcmp(np->type, type) == 0)) | ||
150 | continue; | ||
151 | if (of_device_is_compatible(np, compatible)) | ||
152 | break; | ||
153 | } | ||
154 | |||
155 | return np; | ||
156 | } | ||
157 | EXPORT_SYMBOL(of_find_compatible_node); | ||
158 | |||
159 | struct property *of_find_property(const struct device_node *np, | ||
160 | const char *name, | ||
161 | int *lenp) | ||
162 | { | ||
163 | struct property *pp; | ||
164 | |||
165 | for (pp = np->properties; pp != 0; pp = pp->next) { | ||
166 | if (strcasecmp(pp->name, name) == 0) { | ||
167 | if (lenp != 0) | ||
168 | *lenp = pp->length; | ||
169 | break; | ||
170 | } | ||
171 | } | ||
172 | return pp; | ||
173 | } | ||
174 | EXPORT_SYMBOL(of_find_property); | ||
175 | |||
176 | /* | ||
177 | * Find a property with a given name for a given node | ||
178 | * and return the value. | ||
179 | */ | ||
180 | const void *of_get_property(const struct device_node *np, const char *name, | ||
181 | int *lenp) | ||
182 | { | ||
183 | struct property *pp = of_find_property(np,name,lenp); | ||
184 | return pp ? pp->value : NULL; | ||
185 | } | ||
186 | EXPORT_SYMBOL(of_get_property); | ||
187 | |||
188 | int of_getintprop_default(struct device_node *np, const char *name, int def) | 49 | int of_getintprop_default(struct device_node *np, const char *name, int def) |
189 | { | 50 | { |
190 | struct property *prop; | 51 | struct property *prop; |
@@ -198,36 +59,6 @@ int of_getintprop_default(struct device_node *np, const char *name, int def) | |||
198 | } | 59 | } |
199 | EXPORT_SYMBOL(of_getintprop_default); | 60 | EXPORT_SYMBOL(of_getintprop_default); |
200 | 61 | ||
201 | int of_n_addr_cells(struct device_node *np) | ||
202 | { | ||
203 | const int* ip; | ||
204 | do { | ||
205 | if (np->parent) | ||
206 | np = np->parent; | ||
207 | ip = of_get_property(np, "#address-cells", NULL); | ||
208 | if (ip != NULL) | ||
209 | return *ip; | ||
210 | } while (np->parent); | ||
211 | /* No #address-cells property for the root node, default to 2 */ | ||
212 | return 2; | ||
213 | } | ||
214 | EXPORT_SYMBOL(of_n_addr_cells); | ||
215 | |||
216 | int of_n_size_cells(struct device_node *np) | ||
217 | { | ||
218 | const int* ip; | ||
219 | do { | ||
220 | if (np->parent) | ||
221 | np = np->parent; | ||
222 | ip = of_get_property(np, "#size-cells", NULL); | ||
223 | if (ip != NULL) | ||
224 | return *ip; | ||
225 | } while (np->parent); | ||
226 | /* No #size-cells property for the root node, default to 1 */ | ||
227 | return 1; | ||
228 | } | ||
229 | EXPORT_SYMBOL(of_n_size_cells); | ||
230 | |||
231 | int of_set_property(struct device_node *dp, const char *name, void *val, int len) | 62 | int of_set_property(struct device_node *dp, const char *name, void *val, int len) |
232 | { | 63 | { |
233 | struct property **prevp; | 64 | struct property **prevp; |