diff options
author | Tom Rini <trini@konsulko.com> | 2017-06-10 18:01:22 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2017-06-10 18:01:22 -0400 |
commit | 8cb3ce64f936f5dedbcfc1935c5caf31bb682474 (patch) | |
tree | bc6cbbacd344ccdac327b4bb7337aa316ad000e0 /cmd | |
parent | 4bdb49a7487d1c46c04e3da3f1f370cde1566aea (diff) | |
parent | 9620d87259572ef21f0df60988d9a932ca673779 (diff) | |
download | u-boot-8cb3ce64f936f5dedbcfc1935c5caf31bb682474.zip u-boot-8cb3ce64f936f5dedbcfc1935c5caf31bb682474.tar.gz u-boot-8cb3ce64f936f5dedbcfc1935c5caf31bb682474.tar.bz2 |
Merge git://git.denx.de/u-boot-dm
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/fdt.c | 29 |
1 files changed, 21 insertions, 8 deletions
@@ -257,6 +257,7 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) char *prop; /* property */ int nodeoffset; /* node offset from libfdt */ static char data[SCRATCHPAD]; /* storage for the property */ + const void *ptmp; int len; /* new length of the property */ int ret; /* return value */ @@ -268,13 +269,6 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) pathp = argv[2]; prop = argv[3]; - if (argc == 4) { - len = 0; - } else { - ret = fdt_parse_prop(&argv[4], argc - 4, data, &len); - if (ret != 0) - return ret; - } nodeoffset = fdt_path_offset (working_fdt, pathp); if (nodeoffset < 0) { @@ -286,6 +280,21 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 1; } + if (argc == 4) { + len = 0; + } else { + ptmp = fdt_getprop(working_fdt, nodeoffset, prop, &len); + if (len > SCRATCHPAD) { + printf("prop (%d) doesn't fit in scratchpad!\n", + len); + return 1; + } + memcpy(data, ptmp, len); + ret = fdt_parse_prop(&argv[4], argc - 4, data, &len); + if (ret != 0) + return ret; + } + ret = fdt_setprop(working_fdt, nodeoffset, prop, data, len); if (ret < 0) { printf ("libfdt fdt_setprop(): %s\n", fdt_strerror(ret)); @@ -766,7 +775,11 @@ static int fdt_parse_prop(char * const *newval, int count, char *data, int *len) cp = newp; tmp = simple_strtoul(cp, &newp, 0); - *(fdt32_t *)data = cpu_to_fdt32(tmp); + if (*cp != '?') + *(fdt32_t *)data = cpu_to_fdt32(tmp); + else + newp++; + data += 4; *len += 4; |