diff options
author | David S. Miller <davem@davemloft.net> | 2008-12-05 04:21:41 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-12-05 21:15:03 -0500 |
commit | 6524036a1e5736a07466208362d83ddf31aae3ac (patch) | |
tree | dea250164424676bd19505adcbf6ae260559c403 /arch/sparc/kernel/prom_32.c | |
parent | 4aef8c53fe517542d8185b7d771f291865b49177 (diff) |
sparc: Move core of OF device tree building code into prom_common.c
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc/kernel/prom_32.c')
-rw-r--r-- | arch/sparc/kernel/prom_32.c | 69 |
1 files changed, 5 insertions, 64 deletions
diff --git a/arch/sparc/kernel/prom_32.c b/arch/sparc/kernel/prom_32.c index 35cb4c742524..75eb40be5e8a 100644 --- a/arch/sparc/kernel/prom_32.c +++ b/arch/sparc/kernel/prom_32.c | |||
@@ -42,14 +42,6 @@ void * __init prom_early_alloc(unsigned long size) | |||
42 | return ret; | 42 | return ret; |
43 | } | 43 | } |
44 | 44 | ||
45 | static int is_root_node(const struct device_node *dp) | ||
46 | { | ||
47 | if (!dp) | ||
48 | return 0; | ||
49 | |||
50 | return (dp->parent == NULL); | ||
51 | } | ||
52 | |||
53 | /* The following routines deal with the black magic of fully naming a | 45 | /* The following routines deal with the black magic of fully naming a |
54 | * node. | 46 | * node. |
55 | * | 47 | * |
@@ -161,7 +153,7 @@ static void __init __build_path_component(struct device_node *dp, char *tmp_buf) | |||
161 | return sparc32_path_component(dp, tmp_buf); | 153 | return sparc32_path_component(dp, tmp_buf); |
162 | } | 154 | } |
163 | 155 | ||
164 | static char * __init build_path_component(struct device_node *dp) | 156 | char * __init build_path_component(struct device_node *dp) |
165 | { | 157 | { |
166 | char tmp_buf[64], *n; | 158 | char tmp_buf[64], *n; |
167 | 159 | ||
@@ -176,57 +168,6 @@ static char * __init build_path_component(struct device_node *dp) | |||
176 | return n; | 168 | return n; |
177 | } | 169 | } |
178 | 170 | ||
179 | static char * __init build_full_name(struct device_node *dp) | ||
180 | { | ||
181 | int len, ourlen, plen; | ||
182 | char *n; | ||
183 | |||
184 | plen = strlen(dp->parent->full_name); | ||
185 | ourlen = strlen(dp->path_component_name); | ||
186 | len = ourlen + plen + 2; | ||
187 | |||
188 | n = prom_early_alloc(len); | ||
189 | strcpy(n, dp->parent->full_name); | ||
190 | if (!is_root_node(dp->parent)) { | ||
191 | strcpy(n + plen, "/"); | ||
192 | plen++; | ||
193 | } | ||
194 | strcpy(n + plen, dp->path_component_name); | ||
195 | |||
196 | return n; | ||
197 | } | ||
198 | |||
199 | static struct device_node * __init build_tree(struct device_node *parent, phandle node, struct device_node ***nextp) | ||
200 | { | ||
201 | struct device_node *ret = NULL, *prev_sibling = NULL; | ||
202 | struct device_node *dp; | ||
203 | |||
204 | while (1) { | ||
205 | dp = create_node(node, parent); | ||
206 | if (!dp) | ||
207 | break; | ||
208 | |||
209 | if (prev_sibling) | ||
210 | prev_sibling->sibling = dp; | ||
211 | |||
212 | if (!ret) | ||
213 | ret = dp; | ||
214 | prev_sibling = dp; | ||
215 | |||
216 | *(*nextp) = dp; | ||
217 | *nextp = &dp->allnext; | ||
218 | |||
219 | dp->path_component_name = build_path_component(dp); | ||
220 | dp->full_name = build_full_name(dp); | ||
221 | |||
222 | dp->child = build_tree(dp, prom_getchild(node), nextp); | ||
223 | |||
224 | node = prom_getsibling(node); | ||
225 | } | ||
226 | |||
227 | return ret; | ||
228 | } | ||
229 | |||
230 | struct device_node *of_console_device; | 171 | struct device_node *of_console_device; |
231 | EXPORT_SYMBOL(of_console_device); | 172 | EXPORT_SYMBOL(of_console_device); |
232 | 173 | ||
@@ -360,14 +301,14 @@ void __init prom_build_devicetree(void) | |||
360 | { | 301 | { |
361 | struct device_node **nextp; | 302 | struct device_node **nextp; |
362 | 303 | ||
363 | allnodes = create_node(prom_root_node, NULL); | 304 | allnodes = prom_create_node(prom_root_node, NULL); |
364 | allnodes->path_component_name = ""; | 305 | allnodes->path_component_name = ""; |
365 | allnodes->full_name = "/"; | 306 | allnodes->full_name = "/"; |
366 | 307 | ||
367 | nextp = &allnodes->allnext; | 308 | nextp = &allnodes->allnext; |
368 | allnodes->child = build_tree(allnodes, | 309 | allnodes->child = prom_build_tree(allnodes, |
369 | prom_getchild(allnodes->node), | 310 | prom_getchild(allnodes->node), |
370 | &nextp); | 311 | &nextp); |
371 | of_console_init(); | 312 | of_console_init(); |
372 | 313 | ||
373 | printk("PROM: Built device tree with %u bytes of memory.\n", | 314 | printk("PROM: Built device tree with %u bytes of memory.\n", |