summaryrefslogtreecommitdiffstats
path: root/common/oftree.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-01-09 13:14:45 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2013-01-19 11:48:17 +0100
commite118761c5f7e8e41fa3503ae96885459869dcb84 (patch)
treeb12a3d7d2b014fa2405d5397877b29701fe8655b /common/oftree.c
parent9e824f30c21c1f6b667b82a287105803598b98a1 (diff)
downloadbarebox-e118761c5f7e8e41fa3503ae96885459869dcb84.tar.gz
barebox-e118761c5f7e8e41fa3503ae96885459869dcb84.tar.xz
oftree command: refactor
This has several improvements for the oftree command: - loading a devicetree (-l) and actually probing (-p) it now is separated - the command now can dump the internal devicetree or a dtb given on the command line. - The -f option now actually frees the internal devicetree With this the usage pattern for this command is: oftree -l /env/oftree oftree -d -n /sound oftree -d /env/oftree oftree -f oftree -p oftree -l -p /env/oftree Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/oftree.c')
-rw-r--r--common/oftree.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/common/oftree.c b/common/oftree.c
index d699cb6cf1..0df5209bda 100644
--- a/common/oftree.c
+++ b/common/oftree.c
@@ -325,11 +325,14 @@ int of_fix_tree(struct fdt_header *fdt)
struct fdt_header *of_get_fixed_tree(struct fdt_header *fdt)
{
int ret;
- void *fixfdt;
+ void *fixfdt, *internalfdt = NULL;
int size, align;
- if (!fdt)
- return NULL;
+ if (!fdt) {
+ fdt = internalfdt = of_flatten_dtb();
+ if (!fdt)
+ return NULL;
+ }
size = fdt_totalsize(fdt);
@@ -343,6 +346,8 @@ struct fdt_header *of_get_fixed_tree(struct fdt_header *fdt)
fixfdt = xmemalign(align, size + OFTREE_SIZE_INCREASE);
ret = fdt_open_into(fdt, fixfdt, size + OFTREE_SIZE_INCREASE);
+ free(internalfdt);
+
if (ret)
goto out_free;