Later commit will need to merge two DTs from the root up. Refactor that part out of of_copy_node to make it usable on its own. Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> --- v1 -> v2: - no changes --- drivers/of/base.c | 17 ++++++++++++----- include/of.h | 1 + 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/of/base.c b/drivers/of/base.c index 937847f44ab7..1221cd316cdf 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -2616,19 +2616,26 @@ out: return dn; } -struct device_node *of_copy_node(struct device_node *parent, const struct device_node *other) +void of_merge_nodes(struct device_node *np, const struct device_node *other) { - struct device_node *np, *child; + struct device_node *child; struct property *pp; - np = of_new_node(parent, other->name); - np->phandle = other->phandle; - list_for_each_entry(pp, &other->properties, list) of_new_property(np, pp->name, pp->value, pp->length); for_each_child_of_node(other, child) of_copy_node(np, child); +} + +struct device_node *of_copy_node(struct device_node *parent, const struct device_node *other) +{ + struct device_node *np; + + np = of_new_node(parent, other->name); + np->phandle = other->phandle; + + of_merge_nodes(np, other); return np; } diff --git a/include/of.h b/include/of.h index 7ee1304b932b..1a38774615a4 100644 --- a/include/of.h +++ b/include/of.h @@ -180,6 +180,7 @@ extern struct device_node *of_new_node(struct device_node *parent, const char *name); extern struct device_node *of_create_node(struct device_node *root, const char *path); +extern void of_merge_nodes(struct device_node *np, const struct device_node *other); extern struct device_node *of_copy_node(struct device_node *parent, const struct device_node *other); extern struct device_node *of_dup(const struct device_node *root); -- 2.30.2