diff options
author | Pantelis Antoniou <pantelis.antoniou@konsulko.com> | 2017-07-27 19:33:11 +0300 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2017-07-28 14:34:36 +1000 |
commit | a33c2247ac8d90d14ed622fa3c23695a82ce264f (patch) | |
tree | 18a9f335298336222e1f59534fe222cfd7e3859f /libfdt/fdt_rw.c | |
parent | 0016f8c2aa32423f680ec6e94a00f1095b81b5fc (diff) | |
download | dtc-a33c2247ac8d90d14ed622fa3c23695a82ce264f.zip dtc-a33c2247ac8d90d14ed622fa3c23695a82ce264f.tar.gz dtc-a33c2247ac8d90d14ed622fa3c23695a82ce264f.tar.bz2 |
Introduce fdt_setprop_placeholder() method
In some cases you need to add a property but the contents of it
are not known at creation time, merely the extend of it.
This method allows you to create a property of a given size (filled
with garbage) while a pointer to the property data will be provided.
Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
[dwg: Corrected commit message]
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'libfdt/fdt_rw.c')
-rw-r--r-- | libfdt/fdt_rw.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/libfdt/fdt_rw.c b/libfdt/fdt_rw.c index 8b487f6..5c3a2bb 100644 --- a/libfdt/fdt_rw.c +++ b/libfdt/fdt_rw.c @@ -269,8 +269,8 @@ int fdt_set_name(void *fdt, int nodeoffset, const char *name) return 0; } -int fdt_setprop(void *fdt, int nodeoffset, const char *name, - const void *val, int len) +int fdt_setprop_placeholder(void *fdt, int nodeoffset, const char *name, + int len, void **prop_data) { struct fdt_property *prop; int err; @@ -283,8 +283,22 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name, if (err) return err; + *prop_data = prop->data; + return 0; +} + +int fdt_setprop(void *fdt, int nodeoffset, const char *name, + const void *val, int len) +{ + void *prop_data; + int err; + + err = fdt_setprop_placeholder(fdt, nodeoffset, name, len, &prop_data); + if (err) + return err; + if (len) - memcpy(prop->data, val, len); + memcpy(prop_data, val, len); return 0; } |