diff options
author | Simon Glass <sjg@chromium.org> | 2022-09-07 05:27:33 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-09-30 05:43:43 +0300 |
commit | db1ef1e12b993275e09f116ebc3d23d675c7e28c (patch) | |
tree | 2a1798758c85d3010640cf6bacb1ad7caaa29133 /drivers | |
parent | 0b58eaa89c4d7a4aea1f7f63ff4aca2c2f1d90c4 (diff) | |
download | u-boot-db1ef1e12b993275e09f116ebc3d23d675c7e28c.tar.xz |
dm: core: Support copying properties with ofnode
Add a function to copy properties from one node to another.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/core/ofnode.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 39636a5a18..14bbfe7232 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -1557,3 +1557,27 @@ int ofnode_add_subnode(ofnode node, const char *name, ofnode *subnodep) return ret; /* 0 or -EEXIST */ } + +int ofnode_copy_props(ofnode src, ofnode dst) +{ + struct ofprop prop; + + ofnode_for_each_prop(prop, src) { + const char *name; + const char *val; + int len, ret; + + val = ofprop_get_property(&prop, &name, &len); + if (!val) { + log_debug("Cannot read prop (err=%d)\n", len); + return log_msg_ret("get", -EINVAL); + } + ret = ofnode_write_prop(dst, name, val, len, true); + if (ret) { + log_debug("Cannot write prop (err=%d)\n", ret); + return log_msg_ret("wr", -EINVAL); + } + } + + return 0; +} |