Loading arch/powerpc/platforms/pseries/dlpar.c +6 −18 Original line number Diff line number Diff line Loading @@ -75,24 +75,17 @@ static struct property *dlpar_parse_cc_property(struct cc_workarea *ccwa) return prop; } static struct device_node *dlpar_parse_cc_node(struct cc_workarea *ccwa, const char *path) static struct device_node *dlpar_parse_cc_node(struct cc_workarea *ccwa) { struct device_node *dn; char *name; /* If parent node path is "/" advance path to NULL terminator to * prevent double leading slashs in full_name. */ if (!path[1]) path++; const char *name; dn = kzalloc(sizeof(*dn), GFP_KERNEL); if (!dn) return NULL; name = (char *)ccwa + be32_to_cpu(ccwa->name_offset); dn->full_name = kasprintf(GFP_KERNEL, "%s/%s", path, name); name = (const char *)ccwa + be32_to_cpu(ccwa->name_offset); dn->full_name = kstrdup(name, GFP_KERNEL); if (!dn->full_name) { kfree(dn); return NULL; Loading Loading @@ -148,7 +141,6 @@ struct device_node *dlpar_configure_connector(__be32 drc_index, struct property *last_property = NULL; struct cc_workarea *ccwa; char *data_buf; const char *parent_path = parent->full_name; int cc_token; int rc = -1; Loading Loading @@ -182,7 +174,7 @@ struct device_node *dlpar_configure_connector(__be32 drc_index, break; case NEXT_SIBLING: dn = dlpar_parse_cc_node(ccwa, parent_path); dn = dlpar_parse_cc_node(ccwa); if (!dn) goto cc_error; Loading @@ -192,10 +184,7 @@ struct device_node *dlpar_configure_connector(__be32 drc_index, break; case NEXT_CHILD: if (first_dn) parent_path = last_dn->full_name; dn = dlpar_parse_cc_node(ccwa, parent_path); dn = dlpar_parse_cc_node(ccwa); if (!dn) goto cc_error; Loading Loading @@ -226,7 +215,6 @@ struct device_node *dlpar_configure_connector(__be32 drc_index, case PREV_PARENT: last_dn = last_dn->parent; parent_path = last_dn->parent->full_name; break; case CALL_AGAIN: Loading arch/powerpc/platforms/pseries/reconfig.c +1 −1 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ static int pSeries_reconfig_add_node(const char *path, struct property *proplist if (!np) goto out_err; np->full_name = kstrdup(path, GFP_KERNEL); np->full_name = kstrdup(kbasename(path), GFP_KERNEL); if (!np->full_name) goto out_err; Loading drivers/of/fdt.c +11 −58 Original line number Diff line number Diff line Loading @@ -266,74 +266,32 @@ static void populate_properties(const void *blob, *pprev = NULL; } static unsigned int populate_node(const void *blob, static bool populate_node(const void *blob, int offset, void **mem, struct device_node *dad, unsigned int fpsize, struct device_node **pnp, bool dryrun) { struct device_node *np; const char *pathp; unsigned int l, allocl; int new_format = 0; pathp = fdt_get_name(blob, offset, &l); if (!pathp) { *pnp = NULL; return 0; return false; } allocl = ++l; /* version 0x10 has a more compact unit name here instead of the full * path. we accumulate the full path size using "fpsize", we'll rebuild * it later. We detect this because the first character of the name is * not '/'. */ if ((*pathp) != '/') { new_format = 1; if (fpsize == 0) { /* root node: special case. fpsize accounts for path * plus terminating zero. root node only has '/', so * fpsize should be 2, but we want to avoid the first * level nodes to have two '/' so we use fpsize 1 here */ fpsize = 1; allocl = 2; l = 1; pathp = ""; } else { /* account for '/' and path size minus terminal 0 * already in 'l' */ fpsize += l; allocl = fpsize; } } np = unflatten_dt_alloc(mem, sizeof(struct device_node) + allocl, __alignof__(struct device_node)); if (!dryrun) { char *fn; of_node_init(np); np->full_name = fn = ((char *)np) + sizeof(*np); if (new_format) { /* rebuild full path for new format */ if (dad && dad->parent) { strcpy(fn, dad->full_name); #ifdef DEBUG if ((strlen(fn) + l + 1) != allocl) { pr_debug("%s: p: %d, l: %d, a: %d\n", pathp, (int)strlen(fn), l, allocl); } #endif fn += strlen(fn); } *(fn++) = '/'; } memcpy(fn, pathp, l); if (dad != NULL) { Loading @@ -355,7 +313,7 @@ static unsigned int populate_node(const void *blob, } *pnp = np; return fpsize; return true; } static void reverse_nodes(struct device_node *parent) Loading Loading @@ -399,7 +357,6 @@ static int unflatten_dt_nodes(const void *blob, struct device_node *root; int offset = 0, depth = 0, initial_depth = 0; #define FDT_MAX_DEPTH 64 unsigned int fpsizes[FDT_MAX_DEPTH]; struct device_node *nps[FDT_MAX_DEPTH]; void *base = mem; bool dryrun = !base; Loading @@ -418,7 +375,6 @@ static int unflatten_dt_nodes(const void *blob, depth = initial_depth = 1; root = dad; fpsizes[depth] = dad ? strlen(of_node_full_name(dad)) : 0; nps[depth] = dad; for (offset = 0; Loading @@ -427,11 +383,8 @@ static int unflatten_dt_nodes(const void *blob, if (WARN_ON_ONCE(depth >= FDT_MAX_DEPTH)) continue; fpsizes[depth+1] = populate_node(blob, offset, &mem, nps[depth], fpsizes[depth], &nps[depth+1], dryrun); if (!fpsizes[depth+1]) if (!populate_node(blob, offset, &mem, nps[depth], &nps[depth+1], dryrun)) return mem - base; if (!dryrun && nodepp && !*nodepp) Loading Loading
arch/powerpc/platforms/pseries/dlpar.c +6 −18 Original line number Diff line number Diff line Loading @@ -75,24 +75,17 @@ static struct property *dlpar_parse_cc_property(struct cc_workarea *ccwa) return prop; } static struct device_node *dlpar_parse_cc_node(struct cc_workarea *ccwa, const char *path) static struct device_node *dlpar_parse_cc_node(struct cc_workarea *ccwa) { struct device_node *dn; char *name; /* If parent node path is "/" advance path to NULL terminator to * prevent double leading slashs in full_name. */ if (!path[1]) path++; const char *name; dn = kzalloc(sizeof(*dn), GFP_KERNEL); if (!dn) return NULL; name = (char *)ccwa + be32_to_cpu(ccwa->name_offset); dn->full_name = kasprintf(GFP_KERNEL, "%s/%s", path, name); name = (const char *)ccwa + be32_to_cpu(ccwa->name_offset); dn->full_name = kstrdup(name, GFP_KERNEL); if (!dn->full_name) { kfree(dn); return NULL; Loading Loading @@ -148,7 +141,6 @@ struct device_node *dlpar_configure_connector(__be32 drc_index, struct property *last_property = NULL; struct cc_workarea *ccwa; char *data_buf; const char *parent_path = parent->full_name; int cc_token; int rc = -1; Loading Loading @@ -182,7 +174,7 @@ struct device_node *dlpar_configure_connector(__be32 drc_index, break; case NEXT_SIBLING: dn = dlpar_parse_cc_node(ccwa, parent_path); dn = dlpar_parse_cc_node(ccwa); if (!dn) goto cc_error; Loading @@ -192,10 +184,7 @@ struct device_node *dlpar_configure_connector(__be32 drc_index, break; case NEXT_CHILD: if (first_dn) parent_path = last_dn->full_name; dn = dlpar_parse_cc_node(ccwa, parent_path); dn = dlpar_parse_cc_node(ccwa); if (!dn) goto cc_error; Loading Loading @@ -226,7 +215,6 @@ struct device_node *dlpar_configure_connector(__be32 drc_index, case PREV_PARENT: last_dn = last_dn->parent; parent_path = last_dn->parent->full_name; break; case CALL_AGAIN: Loading
arch/powerpc/platforms/pseries/reconfig.c +1 −1 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ static int pSeries_reconfig_add_node(const char *path, struct property *proplist if (!np) goto out_err; np->full_name = kstrdup(path, GFP_KERNEL); np->full_name = kstrdup(kbasename(path), GFP_KERNEL); if (!np->full_name) goto out_err; Loading
drivers/of/fdt.c +11 −58 Original line number Diff line number Diff line Loading @@ -266,74 +266,32 @@ static void populate_properties(const void *blob, *pprev = NULL; } static unsigned int populate_node(const void *blob, static bool populate_node(const void *blob, int offset, void **mem, struct device_node *dad, unsigned int fpsize, struct device_node **pnp, bool dryrun) { struct device_node *np; const char *pathp; unsigned int l, allocl; int new_format = 0; pathp = fdt_get_name(blob, offset, &l); if (!pathp) { *pnp = NULL; return 0; return false; } allocl = ++l; /* version 0x10 has a more compact unit name here instead of the full * path. we accumulate the full path size using "fpsize", we'll rebuild * it later. We detect this because the first character of the name is * not '/'. */ if ((*pathp) != '/') { new_format = 1; if (fpsize == 0) { /* root node: special case. fpsize accounts for path * plus terminating zero. root node only has '/', so * fpsize should be 2, but we want to avoid the first * level nodes to have two '/' so we use fpsize 1 here */ fpsize = 1; allocl = 2; l = 1; pathp = ""; } else { /* account for '/' and path size minus terminal 0 * already in 'l' */ fpsize += l; allocl = fpsize; } } np = unflatten_dt_alloc(mem, sizeof(struct device_node) + allocl, __alignof__(struct device_node)); if (!dryrun) { char *fn; of_node_init(np); np->full_name = fn = ((char *)np) + sizeof(*np); if (new_format) { /* rebuild full path for new format */ if (dad && dad->parent) { strcpy(fn, dad->full_name); #ifdef DEBUG if ((strlen(fn) + l + 1) != allocl) { pr_debug("%s: p: %d, l: %d, a: %d\n", pathp, (int)strlen(fn), l, allocl); } #endif fn += strlen(fn); } *(fn++) = '/'; } memcpy(fn, pathp, l); if (dad != NULL) { Loading @@ -355,7 +313,7 @@ static unsigned int populate_node(const void *blob, } *pnp = np; return fpsize; return true; } static void reverse_nodes(struct device_node *parent) Loading Loading @@ -399,7 +357,6 @@ static int unflatten_dt_nodes(const void *blob, struct device_node *root; int offset = 0, depth = 0, initial_depth = 0; #define FDT_MAX_DEPTH 64 unsigned int fpsizes[FDT_MAX_DEPTH]; struct device_node *nps[FDT_MAX_DEPTH]; void *base = mem; bool dryrun = !base; Loading @@ -418,7 +375,6 @@ static int unflatten_dt_nodes(const void *blob, depth = initial_depth = 1; root = dad; fpsizes[depth] = dad ? strlen(of_node_full_name(dad)) : 0; nps[depth] = dad; for (offset = 0; Loading @@ -427,11 +383,8 @@ static int unflatten_dt_nodes(const void *blob, if (WARN_ON_ONCE(depth >= FDT_MAX_DEPTH)) continue; fpsizes[depth+1] = populate_node(blob, offset, &mem, nps[depth], fpsizes[depth], &nps[depth+1], dryrun); if (!fpsizes[depth+1]) if (!populate_node(blob, offset, &mem, nps[depth], &nps[depth+1], dryrun)) return mem - base; if (!dryrun && nodepp && !*nodepp) Loading