1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-09-03 01:32:47 +02:00

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>
This commit is contained in:
Simon Glass
2022-09-06 20:27:33 -06:00
committed by Tom Rini
parent 0b58eaa89c
commit db1ef1e12b
3 changed files with 99 additions and 0 deletions

View File

@@ -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;
}