summaryrefslogtreecommitdiff
path: root/lib/libfdt/fdt_rw.c
diff options
context:
space:
mode:
authorTom Rini <trini@ti.com>2012-10-22 19:54:48 -0700
committerTom Rini <trini@ti.com>2012-10-22 19:54:48 -0700
commit71724830b42f67ea9633324183bb622724eee9cd (patch)
treeaf64d8706ac3777456c74b10a775d23d1e62e06c /lib/libfdt/fdt_rw.c
parentc7656bab411433f987baa2288eff8c78ddc0f378 (diff)
parentcae4a8a2a81ca6cd16d5de1b55d47e315cbff05a (diff)
downloadu-boot-imx-71724830b42f67ea9633324183bb622724eee9cd.zip
u-boot-imx-71724830b42f67ea9633324183bb622724eee9cd.tar.gz
u-boot-imx-71724830b42f67ea9633324183bb622724eee9cd.tar.bz2
Merge branch 'master' of git://git.denx.de/u-boot-fdt
Diffstat (limited to 'lib/libfdt/fdt_rw.c')
-rw-r--r--lib/libfdt/fdt_rw.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/libfdt/fdt_rw.c b/lib/libfdt/fdt_rw.c
index 5c27a67..5ed23d6 100644
--- a/lib/libfdt/fdt_rw.c
+++ b/lib/libfdt/fdt_rw.c
@@ -293,6 +293,33 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name,
return 0;
}
+int fdt_appendprop(void *fdt, int nodeoffset, const char *name,
+ const void *val, int len)
+{
+ struct fdt_property *prop;
+ int err, oldlen, newlen;
+
+ FDT_RW_CHECK_HEADER(fdt);
+
+ prop = fdt_get_property_w(fdt, nodeoffset, name, &oldlen);
+ if (prop) {
+ newlen = len + oldlen;
+ err = _fdt_splice_struct(fdt, prop->data,
+ FDT_TAGALIGN(oldlen),
+ FDT_TAGALIGN(newlen));
+ if (err)
+ return err;
+ prop->len = cpu_to_fdt32(newlen);
+ memcpy(prop->data + oldlen, val, len);
+ } else {
+ err = _fdt_add_property(fdt, nodeoffset, name, len, &prop);
+ if (err)
+ return err;
+ memcpy(prop->data, val, len);
+ }
+ return 0;
+}
+
int fdt_delprop(void *fdt, int nodeoffset, const char *name)
{
struct fdt_property *prop;