dm: core: Allow copying ofnode property data when writing

At present ofnode_write_prop() is inconsistent between livetree and
flattree, in that livetree requires the caller to ensure the property
value is stable (e.g. in rodata or allocated) but flattree does not, since
it makes a copy.

This makes the API call a bit painful to use, since the caller must do
different things depending on OF_LIVE.

Add a new 'copy' argument which tells the function to make a copy if
needed. Add some tests to cover this behaviour.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2022-09-29 22:43:43 -04:00
committed by Tom Rini
parent 0d63213c1e
commit 0b58eaa89c
4 changed files with 92 additions and 13 deletions
+2
View File
@@ -325,3 +325,5 @@ Live tree support was introduced in U-Boot 2017.07. Some possible enhancements
are:
- support for livetree in SPL and before relocation (if desired)
- freeing leaked memory caused by writing new nodes / property values to the
livetree (ofnode_write_prop())