summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJan Luebbe <jlu@pengutronix.de>2014-11-19 14:34:08 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2014-11-20 14:43:06 +0100
commit78f20990cec884b8e1fc707868f94b6faf12b3bb (patch)
tree7d019a12b7688d2f3ebee5ae27a970ad5e68f751 /drivers
parent7dc430e612bb965d01a31592f87ee5705d1e3616 (diff)
downloadbarebox-78f20990cec884b8e1fc707868f94b6faf12b3bb.tar.gz
barebox-78f20990cec884b8e1fc707868f94b6faf12b3bb.tar.xz
dt: factor out common code
Currently, dt_struct is always checked with the same code after dt_struct_advance(). Move the check after the switch statement. Signed-off-by: Jan Luebbe <jlu@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/of/fdt.c33
1 files changed, 11 insertions, 22 deletions
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index cfe1833509..d465f98797 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -120,18 +120,14 @@ struct device_node *of_unflatten_dtb(void *infdt)
goto err;
}
- dt_struct = dt_struct_advance(&f, dt_struct,
- sizeof(struct fdt_node_header) + len + 1);
- if (!dt_struct) {
- ret = -ESPIPE;
- goto err;
- }
-
if (!node)
node = root;
else
node = of_new_node(node, pathp);
+ dt_struct = dt_struct_advance(&f, dt_struct,
+ sizeof(struct fdt_node_header) + len + 1);
+
break;
case FDT_END_NODE:
@@ -144,10 +140,6 @@ struct device_node *of_unflatten_dtb(void *infdt)
node = node->parent;
dt_struct = dt_struct_advance(&f, dt_struct, FDT_TAGSIZE);
- if (!dt_struct) {
- ret = -ESPIPE;
- goto err;
- }
break;
@@ -162,25 +154,17 @@ struct device_node *of_unflatten_dtb(void *infdt)
goto err;
}
- dt_struct = dt_struct_advance(&f, dt_struct,
- sizeof(struct fdt_property) + len);
- if (!dt_struct) {
- ret = -ESPIPE;
- goto err;
- }
-
p = of_new_property(node, name, nodep, len);
if (!strcmp(name, "phandle") && len == 4)
node->phandle = be32_to_cpup(p->value);
+ dt_struct = dt_struct_advance(&f, dt_struct,
+ sizeof(struct fdt_property) + len);
+
break;
case FDT_NOP:
dt_struct = dt_struct_advance(&f, dt_struct, FDT_TAGSIZE);
- if (!dt_struct) {
- ret = -ESPIPE;
- goto err;
- }
break;
@@ -192,6 +176,11 @@ struct device_node *of_unflatten_dtb(void *infdt)
ret = -EINVAL;
goto err;
}
+
+ if (!dt_struct) {
+ ret = -ESPIPE;
+ goto err;
+ }
}
err:
of_delete_node(root);