Commit 6448c097 authored by Rob Herring's avatar Rob Herring

Merge branch 'dt-printf-v2' into HEAD

parents 0c37c56d a7e4cfb0
...@@ -75,24 +75,17 @@ static struct property *dlpar_parse_cc_property(struct cc_workarea *ccwa) ...@@ -75,24 +75,17 @@ static struct property *dlpar_parse_cc_property(struct cc_workarea *ccwa)
return prop; return prop;
} }
static struct device_node *dlpar_parse_cc_node(struct cc_workarea *ccwa, static struct device_node *dlpar_parse_cc_node(struct cc_workarea *ccwa)
const char *path)
{ {
struct device_node *dn; struct device_node *dn;
char *name; const char *name;
/* If parent node path is "/" advance path to NULL terminator to
* prevent double leading slashs in full_name.
*/
if (!path[1])
path++;
dn = kzalloc(sizeof(*dn), GFP_KERNEL); dn = kzalloc(sizeof(*dn), GFP_KERNEL);
if (!dn) if (!dn)
return NULL; return NULL;
name = (char *)ccwa + be32_to_cpu(ccwa->name_offset); name = (const char *)ccwa + be32_to_cpu(ccwa->name_offset);
dn->full_name = kasprintf(GFP_KERNEL, "%s/%s", path, name); dn->full_name = kstrdup(name, GFP_KERNEL);
if (!dn->full_name) { if (!dn->full_name) {
kfree(dn); kfree(dn);
return NULL; return NULL;
...@@ -148,7 +141,6 @@ struct device_node *dlpar_configure_connector(__be32 drc_index, ...@@ -148,7 +141,6 @@ struct device_node *dlpar_configure_connector(__be32 drc_index,
struct property *last_property = NULL; struct property *last_property = NULL;
struct cc_workarea *ccwa; struct cc_workarea *ccwa;
char *data_buf; char *data_buf;
const char *parent_path = parent->full_name;
int cc_token; int cc_token;
int rc = -1; int rc = -1;
...@@ -182,7 +174,7 @@ struct device_node *dlpar_configure_connector(__be32 drc_index, ...@@ -182,7 +174,7 @@ struct device_node *dlpar_configure_connector(__be32 drc_index,
break; break;
case NEXT_SIBLING: case NEXT_SIBLING:
dn = dlpar_parse_cc_node(ccwa, parent_path); dn = dlpar_parse_cc_node(ccwa);
if (!dn) if (!dn)
goto cc_error; goto cc_error;
...@@ -192,10 +184,7 @@ struct device_node *dlpar_configure_connector(__be32 drc_index, ...@@ -192,10 +184,7 @@ struct device_node *dlpar_configure_connector(__be32 drc_index,
break; break;
case NEXT_CHILD: case NEXT_CHILD:
if (first_dn) dn = dlpar_parse_cc_node(ccwa);
parent_path = last_dn->full_name;
dn = dlpar_parse_cc_node(ccwa, parent_path);
if (!dn) if (!dn)
goto cc_error; goto cc_error;
...@@ -226,7 +215,6 @@ struct device_node *dlpar_configure_connector(__be32 drc_index, ...@@ -226,7 +215,6 @@ struct device_node *dlpar_configure_connector(__be32 drc_index,
case PREV_PARENT: case PREV_PARENT:
last_dn = last_dn->parent; last_dn = last_dn->parent;
parent_path = last_dn->parent->full_name;
break; break;
case CALL_AGAIN: case CALL_AGAIN:
......
...@@ -33,7 +33,7 @@ static int pSeries_reconfig_add_node(const char *path, struct property *proplist ...@@ -33,7 +33,7 @@ static int pSeries_reconfig_add_node(const char *path, struct property *proplist
if (!np) if (!np)
goto out_err; goto out_err;
np->full_name = kstrdup(path, GFP_KERNEL); np->full_name = kstrdup(kbasename(path), GFP_KERNEL);
if (!np->full_name) if (!np->full_name)
goto out_err; goto out_err;
......
...@@ -266,74 +266,32 @@ static void populate_properties(const void *blob, ...@@ -266,74 +266,32 @@ static void populate_properties(const void *blob,
*pprev = NULL; *pprev = NULL;
} }
static unsigned int populate_node(const void *blob, static bool populate_node(const void *blob,
int offset, int offset,
void **mem, void **mem,
struct device_node *dad, struct device_node *dad,
unsigned int fpsize, struct device_node **pnp,
struct device_node **pnp, bool dryrun)
bool dryrun)
{ {
struct device_node *np; struct device_node *np;
const char *pathp; const char *pathp;
unsigned int l, allocl; unsigned int l, allocl;
int new_format = 0;
pathp = fdt_get_name(blob, offset, &l); pathp = fdt_get_name(blob, offset, &l);
if (!pathp) { if (!pathp) {
*pnp = NULL; *pnp = NULL;
return 0; return false;
} }
allocl = ++l; 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, np = unflatten_dt_alloc(mem, sizeof(struct device_node) + allocl,
__alignof__(struct device_node)); __alignof__(struct device_node));
if (!dryrun) { if (!dryrun) {
char *fn; char *fn;
of_node_init(np); of_node_init(np);
np->full_name = fn = ((char *)np) + sizeof(*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); memcpy(fn, pathp, l);
if (dad != NULL) { if (dad != NULL) {
...@@ -355,7 +313,7 @@ static unsigned int populate_node(const void *blob, ...@@ -355,7 +313,7 @@ static unsigned int populate_node(const void *blob,
} }
*pnp = np; *pnp = np;
return fpsize; return true;
} }
static void reverse_nodes(struct device_node *parent) static void reverse_nodes(struct device_node *parent)
...@@ -399,7 +357,6 @@ static int unflatten_dt_nodes(const void *blob, ...@@ -399,7 +357,6 @@ static int unflatten_dt_nodes(const void *blob,
struct device_node *root; struct device_node *root;
int offset = 0, depth = 0, initial_depth = 0; int offset = 0, depth = 0, initial_depth = 0;
#define FDT_MAX_DEPTH 64 #define FDT_MAX_DEPTH 64
unsigned int fpsizes[FDT_MAX_DEPTH];
struct device_node *nps[FDT_MAX_DEPTH]; struct device_node *nps[FDT_MAX_DEPTH];
void *base = mem; void *base = mem;
bool dryrun = !base; bool dryrun = !base;
...@@ -418,7 +375,6 @@ static int unflatten_dt_nodes(const void *blob, ...@@ -418,7 +375,6 @@ static int unflatten_dt_nodes(const void *blob,
depth = initial_depth = 1; depth = initial_depth = 1;
root = dad; root = dad;
fpsizes[depth] = dad ? strlen(of_node_full_name(dad)) : 0;
nps[depth] = dad; nps[depth] = dad;
for (offset = 0; for (offset = 0;
...@@ -427,11 +383,8 @@ static int unflatten_dt_nodes(const void *blob, ...@@ -427,11 +383,8 @@ static int unflatten_dt_nodes(const void *blob,
if (WARN_ON_ONCE(depth >= FDT_MAX_DEPTH)) if (WARN_ON_ONCE(depth >= FDT_MAX_DEPTH))
continue; continue;
fpsizes[depth+1] = populate_node(blob, offset, &mem, if (!populate_node(blob, offset, &mem, nps[depth],
nps[depth], &nps[depth+1], dryrun))
fpsizes[depth],
&nps[depth+1], dryrun);
if (!fpsizes[depth+1])
return mem - base; return mem - base;
if (!dryrun && nodepp && !*nodepp) if (!dryrun && nodepp && !*nodepp)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment