diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2011-12-14 20:19:57 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2011-12-15 10:18:14 +0100 |
commit | 56442bb101597ecaf133647b2ee4707cbcdb0c97 (patch) | |
tree | 55a25dded45bff34581b7e93b47373d3d76bd424 | |
parent | a746f4685a1dec66fc59bf8b9e20524b10a5d8b7 (diff) | |
download | barebox-56442bb101597ecaf133647b2ee4707cbcdb0c97.tar.gz barebox-56442bb101597ecaf133647b2ee4707cbcdb0c97.tar.xz |
oftree: add of_fix_tree()
Currently we have of_get_fixed_tree() which assumes that
there is a global variable holding a oftree. This seems
not very flexible, so for now introduce a of_fix_tree()
which takes an fdt_header as argument and walks the
list of registered of fixup functions.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | common/oftree.c | 22 | ||||
-rw-r--r-- | include/of.h | 1 |
2 files changed, 16 insertions, 7 deletions
diff --git a/common/oftree.c b/common/oftree.c index 2a2f464204..a657d31664 100644 --- a/common/oftree.c +++ b/common/oftree.c @@ -293,20 +293,28 @@ int of_register_fixup(int (*fixup)(struct fdt_header *)) return 0; } -struct fdt_header *of_get_fixed_tree(void) +int of_fix_tree(struct fdt_header *fdt) { struct of_fixup *of_fixup; int ret; - if (!barebox_fdt) - return NULL; - list_for_each_entry(of_fixup, &of_fixup_list, list) { - ret = of_fixup->fixup(barebox_fdt); + ret = of_fixup->fixup(fdt); if (ret) - return NULL; + return ret; } - return barebox_fdt; + return 0; } +struct fdt_header *of_get_fixed_tree(void) +{ + int ret; + + if (!barebox_fdt) + return NULL; + ret = of_fix_tree(barebox_fdt); + if (ret) + return NULL; + return barebox_fdt; +} diff --git a/include/of.h b/include/of.h index c2661efaea..609b3b587b 100644 --- a/include/of.h +++ b/include/of.h @@ -8,6 +8,7 @@ extern struct fdt_header *barebox_fdt; int fdt_print(struct fdt_header *working_fdt, const char *pathp); struct fdt_header *of_get_fixed_tree(void); +int of_fix_tree(struct fdt_header *fdt); int of_register_fixup(int (*fixup)(struct fdt_header *)); int fdt_find_and_setprop(struct fdt_header *fdt, const char *node, const char *prop, |