diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2013-02-16 19:18:39 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-03-03 14:08:44 +0100 |
commit | 6ae2455e808cbb51303981fe9d6afb785ea99566 (patch) | |
tree | 50b5cc3ada2d00dc699628b0a9964a876806c13d /common/oftree.c | |
parent | 3f1f8821d65a4edb024db5a7978784f349f2acd2 (diff) | |
download | barebox-6ae2455e808cbb51303981fe9d6afb785ea99566.tar.gz barebox-6ae2455e808cbb51303981fe9d6afb785ea99566.tar.xz |
of: add do_fixup_by_compatible with u32 and string version
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/oftree.c')
-rw-r--r-- | common/oftree.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/common/oftree.c b/common/oftree.c index 0df5209bda..9241ebf195 100644 --- a/common/oftree.c +++ b/common/oftree.c @@ -229,6 +229,33 @@ void do_fixup_by_path_u32(struct fdt_header *fdt, const char *path, do_fixup_by_path(fdt, path, prop, &val, sizeof(val), create); } +void do_fixup_by_compatible(struct fdt_header *fdt, const char *compatible, + const char *prop, const void *val, int len, int create) +{ + int off = -1; + + off = fdt_node_offset_by_compatible(fdt, -1, compatible); + while (off != -FDT_ERR_NOTFOUND) { + if (create || (fdt_get_property(fdt, off, prop, 0) != NULL)) + fdt_setprop(fdt, off, prop, val, len); + off = fdt_node_offset_by_compatible(fdt, off, compatible); + } +} + +void do_fixup_by_compatible_u32(struct fdt_header *fdt, const char *compatible, + const char *prop, u32 val, int create) +{ + val = cpu_to_fdt32(val); + do_fixup_by_compatible(fdt, compatible, prop, &val, 4, create); +} + +void do_fixup_by_compatible_string(struct fdt_header *fdt, const char *compatible, + const char *prop, const char *val, int create) +{ + do_fixup_by_compatible(fdt, compatible, prop, val, strlen(val) + 1, + create); +} + int fdt_get_path_or_create(struct fdt_header *fdt, const char *path) { int nodeoffset; |