summaryrefslogtreecommitdiff
path: root/drivers/core
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2022-09-06 20:27:33 -0600
committerTom Rini <trini@konsulko.com>2022-09-29 22:43:43 -0400
commitdb1ef1e12b993275e09f116ebc3d23d675c7e28c (patch)
tree2a1798758c85d3010640cf6bacb1ad7caaa29133 /drivers/core
parent0b58eaa89c4d7a4aea1f7f63ff4aca2c2f1d90c4 (diff)
downloadu-boot-db1ef1e12b993275e09f116ebc3d23d675c7e28c.tar.gz
u-boot-db1ef1e12b993275e09f116ebc3d23d675c7e28c.tar.bz2
u-boot-db1ef1e12b993275e09f116ebc3d23d675c7e28c.zip
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/core')
-rw-r--r--drivers/core/ofnode.c24
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;
+}