diff options
Diffstat (limited to 'scripts/dtc/libfdt/fdt_rw.c')
-rw-r--r-- | scripts/dtc/libfdt/fdt_rw.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/scripts/dtc/libfdt/fdt_rw.c b/scripts/dtc/libfdt/fdt_rw.c index 8e7ec4cb7bcd..24437dfc32b8 100644 --- a/scripts/dtc/libfdt/fdt_rw.c +++ b/scripts/dtc/libfdt/fdt_rw.c | |||
@@ -289,6 +289,33 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name, | |||
289 | return 0; | 289 | return 0; |
290 | } | 290 | } |
291 | 291 | ||
292 | int fdt_appendprop(void *fdt, int nodeoffset, const char *name, | ||
293 | const void *val, int len) | ||
294 | { | ||
295 | struct fdt_property *prop; | ||
296 | int err, oldlen, newlen; | ||
297 | |||
298 | FDT_RW_CHECK_HEADER(fdt); | ||
299 | |||
300 | prop = fdt_get_property_w(fdt, nodeoffset, name, &oldlen); | ||
301 | if (prop) { | ||
302 | newlen = len + oldlen; | ||
303 | err = _fdt_splice_struct(fdt, prop->data, | ||
304 | FDT_TAGALIGN(oldlen), | ||
305 | FDT_TAGALIGN(newlen)); | ||
306 | if (err) | ||
307 | return err; | ||
308 | prop->len = cpu_to_fdt32(newlen); | ||
309 | memcpy(prop->data + oldlen, val, len); | ||
310 | } else { | ||
311 | err = _fdt_add_property(fdt, nodeoffset, name, len, &prop); | ||
312 | if (err) | ||
313 | return err; | ||
314 | memcpy(prop->data, val, len); | ||
315 | } | ||
316 | return 0; | ||
317 | } | ||
318 | |||
292 | int fdt_delprop(void *fdt, int nodeoffset, const char *name) | 319 | int fdt_delprop(void *fdt, int nodeoffset, const char *name) |
293 | { | 320 | { |
294 | struct fdt_property *prop; | 321 | struct fdt_property *prop; |
@@ -406,6 +433,8 @@ int fdt_open_into(const void *fdt, void *buf, int bufsize) | |||
406 | struct_size = 0; | 433 | struct_size = 0; |
407 | while (fdt_next_tag(fdt, struct_size, &struct_size) != FDT_END) | 434 | while (fdt_next_tag(fdt, struct_size, &struct_size) != FDT_END) |
408 | ; | 435 | ; |
436 | if (struct_size < 0) | ||
437 | return struct_size; | ||
409 | } | 438 | } |
410 | 439 | ||
411 | if (!_fdt_blocks_misordered(fdt, mem_rsv_size, struct_size)) { | 440 | if (!_fdt_blocks_misordered(fdt, mem_rsv_size, struct_size)) { |