diff options
author | David S. Miller <davem@davemloft.net> | 2008-12-05 01:21:41 -0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-12-05 18:15:03 -0800 |
commit | 6524036a1e5736a07466208362d83ddf31aae3ac (patch) | |
tree | dea250164424676bd19505adcbf6ae260559c403 /arch/sparc/kernel/prom_32.c | |
parent | 4aef8c53fe517542d8185b7d771f291865b49177 (diff) | |
download | kernel_samsung_smdk4412-6524036a1e5736a07466208362d83ddf31aae3ac.zip kernel_samsung_smdk4412-6524036a1e5736a07466208362d83ddf31aae3ac.tar.gz kernel_samsung_smdk4412-6524036a1e5736a07466208362d83ddf31aae3ac.tar.bz2 |
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 35cb4c7..75eb40b 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) return ret; } -static int is_root_node(const struct device_node *dp) -{ - if (!dp) - return 0; - - return (dp->parent == NULL); -} - /* The following routines deal with the black magic of fully naming a * node. * @@ -161,7 +153,7 @@ static void __init __build_path_component(struct device_node *dp, char *tmp_buf) return sparc32_path_component(dp, tmp_buf); } -static char * __init build_path_component(struct device_node *dp) +char * __init build_path_component(struct device_node *dp) { char tmp_buf[64], *n; @@ -176,57 +168,6 @@ static char * __init build_path_component(struct device_node *dp) return n; } -static char * __init build_full_name(struct device_node *dp) -{ - int len, ourlen, plen; - char *n; - - plen = strlen(dp->parent->full_name); - ourlen = strlen(dp->path_component_name); - len = ourlen + plen + 2; - - n = prom_early_alloc(len); - strcpy(n, dp->parent->full_name); - if (!is_root_node(dp->parent)) { - strcpy(n + plen, "/"); - plen++; - } - strcpy(n + plen, dp->path_component_name); - - return n; -} - -static struct device_node * __init build_tree(struct device_node *parent, phandle node, struct device_node ***nextp) -{ - struct device_node *ret = NULL, *prev_sibling = NULL; - struct device_node *dp; - - while (1) { - dp = create_node(node, parent); - if (!dp) - break; - - if (prev_sibling) - prev_sibling->sibling = dp; - - if (!ret) - ret = dp; - prev_sibling = dp; - - *(*nextp) = dp; - *nextp = &dp->allnext; - - dp->path_component_name = build_path_component(dp); - dp->full_name = build_full_name(dp); - - dp->child = build_tree(dp, prom_getchild(node), nextp); - - node = prom_getsibling(node); - } - - return ret; -} - struct device_node *of_console_device; EXPORT_SYMBOL(of_console_device); @@ -360,14 +301,14 @@ void __init prom_build_devicetree(void) { struct device_node **nextp; - allnodes = create_node(prom_root_node, NULL); + allnodes = prom_create_node(prom_root_node, NULL); allnodes->path_component_name = ""; allnodes->full_name = "/"; nextp = &allnodes->allnext; - allnodes->child = build_tree(allnodes, - prom_getchild(allnodes->node), - &nextp); + allnodes->child = prom_build_tree(allnodes, + prom_getchild(allnodes->node), + &nextp); of_console_init(); printk("PROM: Built device tree with %u bytes of memory.\n", |