static struct device_node * __init prom_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 = prom_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 = prom_build_tree(dp, prom_getchild(node), nextp); if (prom_build_more) prom_build_more(dp, nextp); node = prom_getsibling(node); } return ret; }
static char * __init of_pdt_build_full_name(struct device_node *dp) { int len, ourlen, plen; char *n; dp->path_component_name = build_path_component(dp); 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 (!of_node_is_root(dp->parent)) { strcpy(n + plen, "/"); plen++; } strcpy(n + plen, dp->path_component_name); return n; }
static struct device_node * __init of_pdt_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 = of_pdt_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; #if defined(CONFIG_SPARC) dp->path_component_name = build_path_component(dp); #endif dp->full_name = of_pdt_build_full_name(dp); dp->child = of_pdt_build_tree(dp, of_pdt_prom_ops->getchild(node), nextp); if (of_pdt_build_more) of_pdt_build_more(dp, nextp); node = of_pdt_prom_ops->getsibling(node); } return ret; }