libfdt: Add support for appending the values to a existing property
From: Minghuan Lian <[email protected]>
Some properties may contain multiple values, these values may need to be added to the property respectively. this patch provides this functionality. The main purpose of fdt_append_prop() is to append the values to a existing property, or create a new property if it dose not exist.
---
Jon,
Minghuan Lian sent this to the list ages ago, but it got stuck for months in a mailing list mishap. It more recently resurfaced, I made some small cleanups and added testcases. Please apply.
libfdt/fdt_rw.c +27 -0
@@ -289,6 +289,33 @@ int fdt_setprop(void *fdt, int nodeoffsereturn 0 ; } +int fdt_appendprop (void *fdt,int nodeoffset,const char *name, +const void *val,int len) +{ +struct fdt_property *prop; +int err, oldlen, newlen; + +FDT_RW_CHECK_HEADER (fdt); + + prop =fdt_get_property_w (fdt, nodeoffset, name, &oldlen); +if (prop) { + newlen = len + oldlen; + err =_fdt_splice_struct (fdt, prop->data, +FDT_TAGALIGN (oldlen), +FDT_TAGALIGN (newlen)); +if (err) +return err; + prop->len =cpu_to_fdt32 (newlen); +memcpy (prop->data + oldlen, val, len); + }else { + err =_fdt_add_property (fdt, nodeoffset, name, len, &prop); +if (err) +return err; +memcpy (prop->data, val, len); + } +return 0 ; +} +int fdt_delprop (void *fdt,int nodeoffset,const char *name) {struct fdt_property *prop;
libfdt/libfdt.h +95 -0
101 lines not on this page · raw message
tests/appendprop1.c new file +70 -0
70 lines not on this page · raw message
tests/appendprop.dts new file +7 -0
@@ -0,0 +1,7 @@ +/dts-v1/; + +/ { + prop-str = "hello world", "nastystring: \a\b\t\n\v\f\r\\\""; + prop-int = <0xdeadbeef 123456789>; + prop-bytes = [00010203040001020304]; +};
tests/appendprop2.c new file +64 -0
64 lines not on this page · raw message
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Jon Loeliger
AppliedQuoted 10 lines
From: Minghuan Lian <[email protected]>
Some properties may contain multiple values, these values may need to be added to the property respectively. this patch provides this functionality. The main purpose of
fdt_append_prop()is to append the values to a existing property, or create a new property if it dose not exist.Signed-off-by Minghuan Lian <[email protected]>Signed-off-by David Gibson <[email protected]>
Quoted 7 lines
---
Jon,
Minghuan Lian sent this to the list ages ago, but it got stuck for months in a mailing list mishap. It more recently resurfaced, I made some small cleanups and added testcases. Please apply.
Ooo, sorry. So, yeah...
Applied.
Thanks,
jdl
Quoted 14 lines · Jon Loeliger
Quoted 14 lines
From: Minghuan Lian <[email protected]>
Some properties may contain multiple values, these values may need to be added to the property respectively. this patch provides this functionality. The main purpose of
fdt_append_prop()is to append the values to a existing property, or create a new property if it dose not exist.Signed-off-by Minghuan Lian <[email protected]>Signed-off-by David Gibson <[email protected]>---
Jon,
Quoted 7 lines
Quoted 3 lines
Minghuan Lian sent this to the list ages ago, but it got stuck for months in a mailing list mishap. It more recently resurfaced, I made some small cleanups and added testcases. Please apply.
Ooo, sorry. So, yeah...
Applied.
Thanks.
But, apparently I've been using git so much lately, I've forgotten how to use quilt :(. Seems I left out the updates to the tests makefile and script:
tests/Makefile.tests +1 -0
@@ -12,6 +12,7 @@ LIB_TESTS_L = get_mem_rsv \ sw_tree1 \ move_and_save mangle-layout nopulate \ open_pack rw_tree1 set_name setprop del_property del_node \ + appendprop1 appendprop2 \ string_escapes references path-references phandle_format \ boot-cpuid incbin \ extra-terminating-null \
tests/run_tests.sh +4 -0
@@ -178,6 +178,10 @@ libfdt_tests () { run_test rw_tree1 tree1_tests rw_tree1.test.dtb tree1_tests_rw rw_tree1.test.dtb + run_test appendprop1 + run_test appendprop2 appendprop1.test.dtb + run_dtc_test -I dts -O dtb -o appendprop.test.dtb appendprop.dts + run_test dtbs_equal_ordered appendprop2.test.dtb appendprop.test.dtb for basetree in test_tree1.dtb sw_tree1.test.dtb rw_tree1.test.dtb; do run_test nopulate $basetree
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson