aboutsummaryrefslogtreecommitdiffstats
path: root/libfdt/fdt_rw.c
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2012-07-24 02:58:10 +0000
committerWarner Losh <imp@FreeBSD.org>2012-07-24 02:58:10 +0000
commitbae61446cfa6a4b67c0197a6c7535190b80c8a3d (patch)
tree0adf736d61fa3f379fec96cd67783a6029af264e /libfdt/fdt_rw.c
parentb7b62f41399c6bc3ef3f9583dbc35cbd0a28101f (diff)
downloadsrc-bae61446cfa6a4b67c0197a6c7535190b80c8a3d.tar.gz
src-bae61446cfa6a4b67c0197a6c7535190b80c8a3d.zip
Import dtc from git://git.jdl.com/software/dtc
hash f807af192828222dee7a5c9f94d999673bb4d8a1
Notes
Notes: svn path=/vendor/dtc/dist/; revision=238733
Diffstat (limited to 'libfdt/fdt_rw.c')
-rw-r--r--libfdt/fdt_rw.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/libfdt/fdt_rw.c b/libfdt/fdt_rw.c
index 994037bbbda9..24437dfc32b8 100644
--- a/libfdt/fdt_rw.c
+++ b/libfdt/fdt_rw.c
@@ -289,6 +289,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;