diff options
Diffstat (limited to 'scripts/dtc/libfdt/fdt_wip.c')
-rw-r--r-- | scripts/dtc/libfdt/fdt_wip.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/scripts/dtc/libfdt/fdt_wip.c b/scripts/dtc/libfdt/fdt_wip.c index c5bbb68d3273..6aaab399929c 100644 --- a/scripts/dtc/libfdt/fdt_wip.c +++ b/scripts/dtc/libfdt/fdt_wip.c | |||
@@ -55,21 +55,42 @@ | |||
55 | 55 | ||
56 | #include "libfdt_internal.h" | 56 | #include "libfdt_internal.h" |
57 | 57 | ||
58 | int fdt_setprop_inplace_namelen_partial(void *fdt, int nodeoffset, | ||
59 | const char *name, int namelen, | ||
60 | uint32_t idx, const void *val, | ||
61 | int len) | ||
62 | { | ||
63 | void *propval; | ||
64 | int proplen; | ||
65 | |||
66 | propval = fdt_getprop_namelen_w(fdt, nodeoffset, name, namelen, | ||
67 | &proplen); | ||
68 | if (!propval) | ||
69 | return proplen; | ||
70 | |||
71 | if (proplen < (len + idx)) | ||
72 | return -FDT_ERR_NOSPACE; | ||
73 | |||
74 | memcpy((char *)propval + idx, val, len); | ||
75 | return 0; | ||
76 | } | ||
77 | |||
58 | int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name, | 78 | int fdt_setprop_inplace(void *fdt, int nodeoffset, const char *name, |
59 | const void *val, int len) | 79 | const void *val, int len) |
60 | { | 80 | { |
61 | void *propval; | 81 | const void *propval; |
62 | int proplen; | 82 | int proplen; |
63 | 83 | ||
64 | propval = fdt_getprop_w(fdt, nodeoffset, name, &proplen); | 84 | propval = fdt_getprop(fdt, nodeoffset, name, &proplen); |
65 | if (! propval) | 85 | if (! propval) |
66 | return proplen; | 86 | return proplen; |
67 | 87 | ||
68 | if (proplen != len) | 88 | if (proplen != len) |
69 | return -FDT_ERR_NOSPACE; | 89 | return -FDT_ERR_NOSPACE; |
70 | 90 | ||
71 | memcpy(propval, val, len); | 91 | return fdt_setprop_inplace_namelen_partial(fdt, nodeoffset, name, |
72 | return 0; | 92 | strlen(name), 0, |
93 | val, len); | ||
73 | } | 94 | } |
74 | 95 | ||
75 | static void _fdt_nop_region(void *start, int len) | 96 | static void _fdt_nop_region(void *start, int len) |