diff options
Diffstat (limited to 'drivers/of/fdt.c')
-rw-r--r-- | drivers/of/fdt.c | 44 |
1 files changed, 12 insertions, 32 deletions
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 3dc5d47602..8e4c7756fb 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -54,20 +54,20 @@ static inline char *dt_string(struct fdt_header *f, char *strstart, uint32_t ofs * Parse a flat device tree binary blob and return a pointer to the * unflattened tree. */ -struct device_node *of_unflatten_dtb(struct device_node *root, void *infdt) +struct device_node *of_unflatten_dtb(void *infdt) { const void *nodep; /* property node pointer */ uint32_t tag; /* tag */ int len; /* length of the property */ const struct fdt_property *fdt_prop; const char *pathp, *name; - struct device_node *node = NULL; + struct device_node *root, *node = NULL; struct property *p; uint32_t dt_struct; struct fdt_node_header *fnh; void *dt_strings; struct fdt_header f; - int ret, merge = 0; + int ret; unsigned int maxlen; struct fdt_header *fdt = infdt; @@ -100,14 +100,9 @@ struct device_node *of_unflatten_dtb(struct device_node *root, void *infdt) dt_struct = f.off_dt_struct; dt_strings = (void *)fdt + f.off_dt_strings; - if (root) { - pr_debug("unflatten: merging into existing tree\n"); - merge = 1; - } else { - root = of_new_node(NULL, NULL); - if (!root) - return ERR_PTR(-ENOMEM); - } + root = of_new_node(NULL, NULL); + if (!root) + return ERR_PTR(-ENOMEM); while (1) { tag = be32_to_cpu(*(uint32_t *)(infdt + dt_struct)); @@ -132,15 +127,10 @@ struct device_node *of_unflatten_dtb(struct device_node *root, void *infdt) goto err; } - if (!node) { + if (!node) node = root; - } else { - if (merge) - node = of_get_child_by_name(node, - pathp); - if (!merge || !node) - node = of_new_node(node, pathp); - } + else + node = of_new_node(node, pathp); break; @@ -179,19 +169,9 @@ struct device_node *of_unflatten_dtb(struct device_node *root, void *infdt) goto err; } - p = NULL; - if (merge) - p = of_find_property(node, name, NULL); - if (merge && p) { - free(p->value); - p->value = xzalloc(len); - p->length = len; - memcpy(p->value, nodep, len); - } else { - p = of_new_property(node, name, nodep, len); - if (!strcmp(name, "phandle") && len == 4) - node->phandle = be32_to_cpup(p->value); - } + p = of_new_property(node, name, nodep, len); + if (!strcmp(name, "phandle") && len == 4) + node->phandle = be32_to_cpup(p->value); break; |