fdtdec: support multiple phandles in memory carveout
v2 cover fdtdec: support multiple phandles in memory carveout
Content-Type: text/plain; charset="us-ascii"
fdtdec_set_carveout() is limited to only one phandle. Fix this limitation by adding support for multiple phandles and also add an unit test for the function.
Changes in v2:
- added a unit test for the function (Simon)
- added a cover letter
Laurentiu Tudor (2):
fdtdec: support multiple phandles in memory carveout
test: fdtdec: test fdtdec_set_carveout()
lib/fdtdec.c | 36 +++++++++++++++++++++-------- test/dm/Makefile | 1 + test/dm/fdtdec.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 10 deletions(-) create mode 100644 test/dm/fdtdec.c
Signature · 1 line
2.17.1
PATCH v2 1/2 fdtdec: support multiple phandles in memory carveout
fdtdec_set_carveout() is limited to only one phandle. Fix this limitation by adding support for multiple phandles.
--- lib/fdtdec.c | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-)
lib/fdtdec.c +26 -10
@@ -1433,14 +1433,9 @@ int fdtdec_set_carveout(void *blob, const char *node, const char *prop_name, const struct fdt_memory *carveout) {uint32_t phandle; -int err, offset; +int err, offset, len;fdt32_t value; - -/* XXX implement support for multiple phandles */ -if (index >0 ) { -debug ("invalid index %u\n" , index); -return -FDT_ERR_BADOFFSET ; - } +void *prop; err =fdtdec_add_reserved_memory (blob, name, carveout, &phandle);if (err <0 ) {
@@ -1456,10 +1451,31 @@ int fdtdec_set_carveout(void *blob, const char *node, const char *prop_name, value =cpu_to_fdt32 (phandle); - err =fdt_setprop (blob, offset, prop_name, &value,sizeof (value)); +if (!fdt_getprop (blob, offset, prop_name, &len)) { +if (len == -FDT_ERR_NOTFOUND ) + len =0 ; +else +return len; + } + +if ((index +1 ) *sizeof (value) > len) { + err =fdt_setprop_placeholder (blob, offset, prop_name, + (index +1 ) *sizeof (value), + &prop); +if (err <0 ) { +debug ("failed to resize reserved memory property: %s\n" , +fdt_strerror (err)); +return err; + } + } + + err =fdt_setprop_inplace_namelen_partial (blob, offset, prop_name, +strlen (prop_name), + index *sizeof (value), + &value,sizeof (value));if (err <0 ) { -debug ("failed to set %s property for node %s: %d\n" , prop_name, - node, err); +debug ("failed to update %s property for node %s: %s\n" , + prop_name, node,fdt_strerror (err));return err; }
Signature · 1 line
2.17.1
PATCH v2 1/2 fdtdec: support multiple phandles in memory carveout
Quoted 8 lines · Laurentiu Tudor
fdtdec_set_carveout()is limited to only one phandle. Fix this limitation by adding support for multiple phandles.Signed-off-by Laurentiu Tudor <[email protected]>--- lib/fdtdec.c | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-)
PATCH v2 1/2 fdtdec: support multiple phandles in memory carveout
Quoted 8 lines · Laurentiu Tudor
fdtdec_set_carveout()is limited to only one phandle. Fix this limitation by adding support for multiple phandles.Signed-off-by Laurentiu Tudor <[email protected]>--- lib/fdtdec.c | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v2 2/2 test: fdtdec: test fdtdec_set_carveout()
In reply to Laurentiu TudorAdd a new test for fdtdec_set_carveout().
--- test/dm/Makefile | 1 + test/dm/fdtdec.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 test/dm/fdtdec.c
test/dm/Makefile +1 -0
@@ -31,6 +31,7 @@ obj-$(CONFIG_LED) += led.o obj-$(CONFIG_DM_MAILBOX) += mailbox.o obj-$(CONFIG_DM_MMC) += mmc.o obj-y += ofnode.o +obj-y += fdtdec.o obj-$(CONFIG_OSD) += osd.o obj-$(CONFIG_DM_VIDEO) += panel.o obj-$(CONFIG_DM_PCI) += pci.o
test/dm/fdtdec.c new file +60 -0
60 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 2/2 test: fdtdec: test fdtdec_set_carveout()
Quoted 9 lines · Laurentiu Tudor
Add a new test for
fdtdec_set_carveout().Signed-off-by Laurentiu Tudor <[email protected]>--- test/dm/Makefile | 1 + test/dm/fdtdec.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 test/dm/fdtdec.c
PATCH v2 2/2 test: fdtdec: test fdtdec_set_carveout()
Quoted 9 lines · Laurentiu Tudor
Add a new test for
fdtdec_set_carveout().Signed-off-by Laurentiu Tudor <[email protected]>--- test/dm/Makefile | 1 + test/dm/fdtdec.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 test/dm/fdtdec.c
Applied to u-boot-dm/next, thanks!