dm: core: Allow copying ofnode property data when writing
authorSimon Glass <sjg@chromium.org>
Wed, 7 Sep 2022 02:27:32 +0000 (20:27 -0600)
committerTom Rini <trini@konsulko.com>
Fri, 30 Sep 2022 02:43:43 +0000 (22:43 -0400)
commit0b58eaa89c4d7a4aea1f7f63ff4aca2c2f1d90c4
tree2cfa68b6cbd711ec4ec34e92aa1320930e6a8fd4
parent0d63213c1ed5246423c22cbe3c6798a09763a2b9
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>
doc/develop/driver-model/livetree.rst
drivers/core/ofnode.c
include/dm/ofnode.h
test/dm/ofnode.c