aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-12-05 04:10:18 -0500
committerDavid S. Miller <davem@davemloft.net>2008-12-05 20:09:10 -0500
commit7d9439d50b6dadcfdf6d28be2234461709719e14 (patch)
treeadd153d782e475df716e4c2371c3f23d019bcebe /arch
parent06c0db7221de09cdf1d5dd2ce2780cc3361ad9f9 (diff)
sparc: Move create_node() and friends into prom_common.c
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch')
-rw-r--r--arch/sparc/kernel/prom.h3
-rw-r--r--arch/sparc/kernel/prom_32.c38
-rw-r--r--arch/sparc/kernel/prom_64.c38
-rw-r--r--arch/sparc/kernel/prom_common.c41
4 files changed, 42 insertions, 78 deletions
diff --git a/arch/sparc/kernel/prom.h b/arch/sparc/kernel/prom.h
index 49c25bdaeff3..d14b4ae4fc57 100644
--- a/arch/sparc/kernel/prom.h
+++ b/arch/sparc/kernel/prom.h
@@ -15,6 +15,7 @@ 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); 18extern struct device_node * __init create_node(phandle node,
19 struct device_node *parent);
19 20
20#endif /* __PROM_H */ 21#endif /* __PROM_H */
diff --git a/arch/sparc/kernel/prom_32.c b/arch/sparc/kernel/prom_32.c
index 5818aa9e85a0..5881c1438198 100644
--- a/arch/sparc/kernel/prom_32.c
+++ b/arch/sparc/kernel/prom_32.c
@@ -196,44 +196,6 @@ static char * __init build_full_name(struct device_node *dp)
196 return n; 196 return n;
197} 197}
198 198
199static char * __init get_one_property(phandle node, const char *name)
200{
201 char *buf = "<NULL>";
202 int len;
203
204 len = prom_getproplen(node, name);
205 if (len > 0) {
206 buf = prom_early_alloc(len);
207 len = prom_getproperty(node, name, buf, len);
208 }
209
210 return buf;
211}
212
213static struct device_node * __init create_node(phandle node, struct device_node *parent)
214{
215 struct device_node *dp;
216
217 if (!node)
218 return NULL;
219
220 dp = prom_early_alloc(sizeof(*dp));
221 dp->unique_id = prom_unique_id++;
222 dp->parent = parent;
223
224 kref_init(&dp->kref);
225
226 dp->name = get_one_property(node, "name");
227 dp->type = get_one_property(node, "device_type");
228 dp->node = node;
229
230 /* Build interrupts later... */
231
232 dp->properties = build_prop_list(node);
233
234 return dp;
235}
236
237static struct device_node * __init build_tree(struct device_node *parent, phandle node, struct device_node ***nextp) 199static struct device_node * __init build_tree(struct device_node *parent, phandle node, struct device_node ***nextp)
238{ 200{
239 struct device_node *dp; 201 struct device_node *dp;
diff --git a/arch/sparc/kernel/prom_64.c b/arch/sparc/kernel/prom_64.c
index ce96c1cf6c3a..c1ce987b8429 100644
--- a/arch/sparc/kernel/prom_64.c
+++ b/arch/sparc/kernel/prom_64.c
@@ -399,44 +399,6 @@ static char * __init build_full_name(struct device_node *dp)
399 return n; 399 return n;
400} 400}
401 401
402static char * __init get_one_property(phandle node, const char *name)
403{
404 char *buf = "<NULL>";
405 int len;
406
407 len = prom_getproplen(node, name);
408 if (len > 0) {
409 buf = prom_early_alloc(len);
410 len = prom_getproperty(node, name, buf, len);
411 }
412
413 return buf;
414}
415
416static struct device_node * __init create_node(phandle node, struct device_node *parent)
417{
418 struct device_node *dp;
419
420 if (!node)
421 return NULL;
422
423 dp = prom_early_alloc(sizeof(*dp));
424 dp->unique_id = prom_unique_id++;
425 dp->parent = parent;
426
427 kref_init(&dp->kref);
428
429 dp->name = get_one_property(node, "name");
430 dp->type = get_one_property(node, "device_type");
431 dp->node = node;
432
433 dp->properties = build_prop_list(node);
434
435 irq_trans_init(dp);
436
437 return dp;
438}
439
440static struct device_node * __init build_tree(struct device_node *parent, phandle node, struct device_node ***nextp) 402static struct device_node * __init build_tree(struct device_node *parent, phandle node, struct device_node ***nextp)
441{ 403{
442 struct device_node *ret = NULL, *prev_sibling = NULL; 404 struct device_node *ret = NULL, *prev_sibling = NULL;
diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
index 762056762b72..d3eddc76763d 100644
--- a/arch/sparc/kernel/prom_common.c
+++ b/arch/sparc/kernel/prom_common.c
@@ -184,7 +184,7 @@ static struct property * __init build_one_prop(phandle node, char *prev,
184 return p; 184 return p;
185} 185}
186 186
187struct property * __init build_prop_list(phandle node) 187static struct property * __init build_prop_list(phandle node)
188{ 188{
189 struct property *head, *tail; 189 struct property *head, *tail;
190 190
@@ -201,3 +201,42 @@ struct property * __init build_prop_list(phandle node)
201 201
202 return head; 202 return head;
203} 203}
204
205static char * __init get_one_property(phandle node, const char *name)
206{
207 char *buf = "<NULL>";
208 int len;
209
210 len = prom_getproplen(node, name);
211 if (len > 0) {
212 buf = prom_early_alloc(len);
213 len = prom_getproperty(node, name, buf, len);
214 }
215
216 return buf;
217}
218
219struct device_node * __init create_node(phandle node,
220 struct device_node *parent)
221{
222 struct device_node *dp;
223
224 if (!node)
225 return NULL;
226
227 dp = prom_early_alloc(sizeof(*dp));
228 dp->unique_id = prom_unique_id++;
229 dp->parent = parent;
230
231 kref_init(&dp->kref);
232
233 dp->name = get_one_property(node, "name");
234 dp->type = get_one_property(node, "device_type");
235 dp->node = node;
236
237 /* Build interrupts later... */
238
239 dp->properties = build_prop_list(node);
240
241 return dp;
242}