From 8a185a4ff2283c670ffc8724c1b7bdbf8d458cbe Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 19 Feb 2013 23:38:32 +0100 Subject: 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 --- commands/oftree.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'commands/oftree.c') 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 #include #include +#include #include #include #include @@ -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; -- cgit v1.2.3