summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-01-09 15:30:17 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2013-01-19 11:48:17 +0100
commit9e824f30c21c1f6b667b82a287105803598b98a1 (patch)
tree8227f368415985a28984dbc22dc0808b7aebed2d /drivers
parentf3e173f6c2a086f33e7d661a92418c479d33648a (diff)
downloadbarebox-9e824f30c21c1f6b667b82a287105803598b98a1.tar.gz
barebox-9e824f30c21c1f6b667b82a287105803598b98a1.tar.xz
of: unflatten: allow overlay dtbs
This implements overlaying a currently loaded dtb with another dtb. We used to return -EBUSY when a oftree is currently loaded. Instead of doing this, check if a node already exists before creating a new one. Similarly, if a property already exists, just overwrite the value instead of creating a new property. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/of/base.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 96ddcbc4ca..50c7ec98f0 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -845,13 +845,11 @@ int of_unflatten_dtb(struct fdt_header *fdt)
const struct fdt_property *fdt_prop;
const char *pathp;
int depth = 10000;
- struct device_node *node = NULL;
+ struct device_node *node = NULL, *n;
+ struct property *p;
char buf[1024];
int ret;
- if (root_node)
- return -EBUSY;
-
nodeoffset = fdt_path_offset(fdt, "/");
if (nodeoffset < 0) {
/*
@@ -875,12 +873,17 @@ int of_unflatten_dtb(struct fdt_header *fdt)
if (ret)
return -EINVAL;
- node = new_device_node(node);
- if (!node->parent)
- root_node = node;
- node->full_name = xstrdup(buf);
- node->name = xstrdup(pathp);
- list_add_tail(&node->list, &allnodes);
+ n = of_find_node_by_path(buf);
+ if (n) {
+ node = n;
+ } else {
+ node = new_device_node(node);
+ if (!node->parent)
+ root_node = node;
+ node->full_name = xstrdup(buf);
+ node->name = xstrdup(pathp);
+ list_add_tail(&node->list, &allnodes);
+ }
break;
case FDT_END_NODE:
node = node->parent;
@@ -892,7 +895,15 @@ int of_unflatten_dtb(struct fdt_header *fdt)
fdt32_to_cpu(fdt_prop->nameoff));
len = fdt32_to_cpu(fdt_prop->len);
nodep = fdt_prop->data;
- new_property(node, pathp, nodep, len);
+
+ p = of_find_property(node, pathp);
+ if (p) {
+ free(p->value);
+ p->value = xzalloc(len);
+ memcpy(p->value, nodep, len);
+ } else {
+ new_property(node, pathp, nodep, len);
+ }
break;
case FDT_NOP:
break;