dm: core: Add a way to copy a node
Add a function to copy a node to another place under a new name. This is useful at least for testing, since copying a test node with existing properties is easier than writing the code to generate it all afresh. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -1802,3 +1802,23 @@ int ofnode_copy_props(ofnode dst, ofnode src)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ofnode_copy_node(ofnode dst_parent, const char *name, ofnode src,
|
||||
ofnode *nodep)
|
||||
{
|
||||
ofnode node;
|
||||
int ret;
|
||||
|
||||
ret = ofnode_add_subnode(dst_parent, name, &node);
|
||||
if (ret) {
|
||||
if (ret == -EEXIST)
|
||||
*nodep = node;
|
||||
return log_msg_ret("add", ret);
|
||||
}
|
||||
ret = ofnode_copy_props(node, src);
|
||||
if (ret)
|
||||
return log_msg_ret("cpy", ret);
|
||||
*nodep = node;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user