summaryrefslogtreecommitdiffstats
path: root/commands/oftree.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-02-19 23:38:32 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2013-03-06 11:41:27 +0100
commit8a185a4ff2283c670ffc8724c1b7bdbf8d458cbe (patch)
tree0c1b954b5915c5d4384c7a5d5be21a03ca710ef6 /commands/oftree.c
parent3afab2a83ef55f37c85c8abf13722a1f0b4c82cf (diff)
downloadbarebox-8a185a4ff2283c670ffc8724c1b7bdbf8d458cbe.tar.gz
barebox-8a185a4ff2283c670ffc8724c1b7bdbf8d458cbe.tar.xz
of: let of_unflatten_dtb return the unflattened tree
In order to be able to handle multiple devicetrees, do not assume the tree to be unflattened is the barebox internal one. Instead, just return a pointer to it and assign the barebox internal root_node external to the unflatten function. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/oftree.c')
-rw-r--r--commands/oftree.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/commands/oftree.c b/commands/oftree.c
index ddbff3e374..68e3fb43c2 100644
--- a/commands/oftree.c
+++ b/commands/oftree.c
@@ -32,6 +32,7 @@
#include <malloc.h>
#include <libfdt.h>
#include <linux/ctype.h>
+#include <linux/err.h>
#include <asm/byteorder.h>
#include <errno.h>
#include <getopt.h>
@@ -52,6 +53,7 @@ static int do_oftree(int argc, char *argv[])
int save = 0;
int free_of = 0;
int ret;
+ struct device_node *n, *root;
while ((opt = getopt(argc, argv, "dpfn:ls")) > 0) {
switch (opt) {
@@ -135,7 +137,17 @@ static int do_oftree(int argc, char *argv[])
goto out;
}
- ret = of_unflatten_dtb(fdt);
+ n = of_get_root_node();
+
+ root = of_unflatten_dtb(n, fdt);
+ if (IS_ERR(root))
+ ret = PTR_ERR(root);
+ else
+ ret = 0;
+
+ if (!n)
+ ret = of_set_root_node(root);
+
if (ret) {
printf("parse oftree: %s\n", strerror(-ret));
goto out;