[PATCH v2 1/4] of: base: factor out of_merge_nodes from of_copy_node

Sascha Hauer sha at pengutronix.de
Fri Mar 10 01:51:11 PST 2023


On Fri, Feb 10, 2023 at 05:53:50PM +0100, Ahmad Fatoum wrote:
> 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 at pengutronix.de>
> ---

Applied, thanks

Sascha

> 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
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list