aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-12-05 04:00:46 -0500
committerDavid S. Miller <davem@davemloft.net>2008-12-05 20:04:22 -0500
commitb9e5567cda6387e0f4061bfceebbc1bd63ee42a6 (patch)
tree0c7cc9f46f65b943fe8065ba2b3af31a3bbf06b1 /arch
parente5ff0fe31d69e716f2599bcfb297ca3757e957c5 (diff)
sparc: Move property building code into prom_common.c
Unfortunately there is some sparc32/sparc64 ifdef'ery in here due to the difference in how the prom_firstprop() and prom_nextprop() routines work. This will be eliminated eventually. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch')
-rw-r--r--arch/sparc/kernel/prom.h2
-rw-r--r--arch/sparc/kernel/prom_32.c66
-rw-r--r--arch/sparc/kernel/prom_64.c60
-rw-r--r--arch/sparc/kernel/prom_common.c81
4 files changed, 83 insertions, 126 deletions
diff --git a/arch/sparc/kernel/prom.h b/arch/sparc/kernel/prom.h
index 2575cdbbed6f..49c25bdaeff3 100644
--- a/arch/sparc/kernel/prom.h
+++ b/arch/sparc/kernel/prom.h
@@ -15,4 +15,6 @@ extern void irq_trans_init(struct device_node *dp);
15 15
16extern unsigned int prom_unique_id; 16extern unsigned int prom_unique_id;
17 17
18extern struct property * __init build_prop_list(phandle node);
19
18#endif /* __PROM_H */ 20#endif /* __PROM_H */
diff --git a/arch/sparc/kernel/prom_32.c b/arch/sparc/kernel/prom_32.c
index c34888a21b2d..a9859d2b2565 100644
--- a/arch/sparc/kernel/prom_32.c
+++ b/arch/sparc/kernel/prom_32.c
@@ -196,72 +196,6 @@ static char * __init build_full_name(struct device_node *dp)
196 return n; 196 return n;
197} 197}
198 198
199static struct property * __init build_one_prop(phandle node, char *prev, char *special_name, void *special_val, int special_len)
200{
201 static struct property *tmp = NULL;
202 struct property *p;
203 int len;
204 const char *name;
205
206 if (tmp) {
207 p = tmp;
208 memset(p, 0, sizeof(*p) + 32);
209 tmp = NULL;
210 } else {
211 p = prom_early_alloc(sizeof(struct property) + 32);
212 p->unique_id = prom_unique_id++;
213 }
214
215 p->name = (char *) (p + 1);
216 if (special_name) {
217 strcpy(p->name, special_name);
218 p->length = special_len;
219 p->value = prom_early_alloc(special_len);
220 memcpy(p->value, special_val, special_len);
221 } else {
222 if (prev == NULL) {
223 name = prom_firstprop(node, NULL);
224 } else {
225 name = prom_nextprop(node, prev, NULL);
226 }
227 if (strlen(name) == 0) {
228 tmp = p;
229 return NULL;
230 }
231 strcpy(p->name, name);
232 p->length = prom_getproplen(node, p->name);
233 if (p->length <= 0) {
234 p->length = 0;
235 } else {
236 p->value = prom_early_alloc(p->length + 1);
237 len = prom_getproperty(node, p->name, p->value,
238 p->length);
239 if (len <= 0)
240 p->length = 0;
241 ((unsigned char *)p->value)[p->length] = '\0';
242 }
243 }
244 return p;
245}
246
247static struct property * __init build_prop_list(phandle node)
248{
249 struct property *head, *tail;
250
251 head = tail = build_one_prop(node, NULL,
252 ".node", &node, sizeof(node));
253
254 tail->next = build_one_prop(node, NULL, NULL, NULL, 0);
255 tail = tail->next;
256 while(tail) {
257 tail->next = build_one_prop(node, tail->name,
258 NULL, NULL, 0);
259 tail = tail->next;
260 }
261
262 return head;
263}
264
265static char * __init get_one_property(phandle node, char *name) 199static char * __init get_one_property(phandle node, char *name)
266{ 200{
267 char *buf = "<NULL>"; 201 char *buf = "<NULL>";
diff --git a/arch/sparc/kernel/prom_64.c b/arch/sparc/kernel/prom_64.c
index 61cc967b149d..e3969db4d58b 100644
--- a/arch/sparc/kernel/prom_64.c
+++ b/arch/sparc/kernel/prom_64.c
@@ -399,66 +399,6 @@ static char * __init build_full_name(struct device_node *dp)
399 return n; 399 return n;
400} 400}
401 401
402static struct property * __init build_one_prop(phandle node, char *prev, char *special_name, void *special_val, int special_len)
403{
404 static struct property *tmp = NULL;
405 struct property *p;
406
407 if (tmp) {
408 p = tmp;
409 memset(p, 0, sizeof(*p) + 32);
410 tmp = NULL;
411 } else {
412 p = prom_early_alloc(sizeof(struct property) + 32);
413 p->unique_id = prom_unique_id++;
414 }
415
416 p->name = (char *) (p + 1);
417 if (special_name) {
418 strcpy(p->name, special_name);
419 p->length = special_len;
420 p->value = prom_early_alloc(special_len);
421 memcpy(p->value, special_val, special_len);
422 } else {
423 if (prev == NULL) {
424 prom_firstprop(node, p->name);
425 } else {
426 prom_nextprop(node, prev, p->name);
427 }
428 if (strlen(p->name) == 0) {
429 tmp = p;
430 return NULL;
431 }
432 p->length = prom_getproplen(node, p->name);
433 if (p->length <= 0) {
434 p->length = 0;
435 } else {
436 p->value = prom_early_alloc(p->length + 1);
437 prom_getproperty(node, p->name, p->value, p->length);
438 ((unsigned char *)p->value)[p->length] = '\0';
439 }
440 }
441 return p;
442}
443
444static struct property * __init build_prop_list(phandle node)
445{
446 struct property *head, *tail;
447
448 head = tail = build_one_prop(node, NULL,
449 ".node", &node, sizeof(node));
450
451 tail->next = build_one_prop(node, NULL, NULL, NULL, 0);
452 tail = tail->next;
453 while(tail) {
454 tail->next = build_one_prop(node, tail->name,
455 NULL, NULL, 0);
456 tail = tail->next;
457 }
458
459 return head;
460}
461
462static char * __init get_one_property(phandle node, const char *name) 402static char * __init get_one_property(phandle node, const char *name)
463{ 403{
464 char *buf = "<NULL>"; 404 char *buf = "<NULL>";
diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
index a23180801014..762056762b72 100644
--- a/arch/sparc/kernel/prom_common.c
+++ b/arch/sparc/kernel/prom_common.c
@@ -120,3 +120,84 @@ int of_find_in_proplist(const char *list, const char *match, int len)
120EXPORT_SYMBOL(of_find_in_proplist); 120EXPORT_SYMBOL(of_find_in_proplist);
121 121
122unsigned int prom_unique_id; 122unsigned int prom_unique_id;
123
124static struct property * __init build_one_prop(phandle node, char *prev,
125 char *special_name,
126 void *special_val,
127 int special_len)
128{
129 static struct property *tmp = NULL;
130 struct property *p;
131 const char *name;
132
133 if (tmp) {
134 p = tmp;
135 memset(p, 0, sizeof(*p) + 32);
136 tmp = NULL;
137 } else {
138 p = prom_early_alloc(sizeof(struct property) + 32);
139 p->unique_id = prom_unique_id++;
140 }
141
142 p->name = (char *) (p + 1);
143 if (special_name) {
144 strcpy(p->name, special_name);
145 p->length = special_len;
146 p->value = prom_early_alloc(special_len);
147 memcpy(p->value, special_val, special_len);
148 } else {
149#ifdef CONFIG_SPARC32
150 if (prev == NULL) {
151 name = prom_firstprop(node, NULL);
152 } else {
153 name = prom_nextprop(node, prev, NULL);
154 }
155#else
156 if (prev == NULL) {
157 prom_firstprop(node, p->name);
158 } else {
159 prom_nextprop(node, prev, p->name);
160 }
161 name = p->name;
162#endif
163 if (strlen(name) == 0) {
164 tmp = p;
165 return NULL;
166 }
167#ifdef CONFIG_SPARC32
168 strcpy(p->name, name);
169#endif
170 p->length = prom_getproplen(node, p->name);
171 if (p->length <= 0) {
172 p->length = 0;
173 } else {
174 int len;
175
176 p->value = prom_early_alloc(p->length + 1);
177 len = prom_getproperty(node, p->name, p->value,
178 p->length);
179 if (len <= 0)
180 p->length = 0;
181 ((unsigned char *)p->value)[p->length] = '\0';
182 }
183 }
184 return p;
185}
186
187struct property * __init build_prop_list(phandle node)
188{
189 struct property *head, *tail;
190
191 head = tail = build_one_prop(node, NULL,
192 ".node", &node, sizeof(node));
193
194 tail->next = build_one_prop(node, NULL, NULL, NULL, 0);
195 tail = tail->next;
196 while(tail) {
197 tail->next = build_one_prop(node, tail->name,
198 NULL, NULL, 0);
199 tail = tail->next;
200 }
201
202 return head;
203}