Le 20/06/2022 à 12:41, Clément Léger a écrit :
> Use of_property_alloc/free() and of_node_alloc() to create and free
> device-tree nodes and properties. In order to obtain something cleaner
> and allow using only of_node_put() instead of manual property deletion,
> a rework of the usage of node in reconfig.c has been done.
> 
> Signed-off-by: Clément Léger <clement.le...@bootlin.com>
> ---

> diff --git a/arch/powerpc/platforms/pseries/reconfig.c 
> b/arch/powerpc/platforms/pseries/reconfig.c
> index cad7a0c93117..8704c541de3c 100644
> --- a/arch/powerpc/platforms/pseries/reconfig.c
> +++ b/arch/powerpc/platforms/pseries/reconfig.c
> @@ -19,46 +19,29 @@
>   
>   #include "of_helpers.h"
>   
> -static int pSeries_reconfig_add_node(const char *path, struct property 
> *proplist)
> +static struct device_node *pSeries_reconfig_add_node(const char *path)
>   {
> -     struct device_node *np;
> -     int err = -ENOMEM;
> -
> -     np = kzalloc(sizeof(*np), GFP_KERNEL);
> -     if (!np)
> -             goto out_err;
> -
> -     np->full_name = kstrdup(kbasename(path), GFP_KERNEL);
> -     if (!np->full_name)
> -             goto out_err;
> -
> -     np->properties = proplist;
> -     of_node_set_flag(np, OF_DYNAMIC);
> -     of_node_init(np);
> +     struct device_node *np, *parent;
>   
> -     np->parent = pseries_of_derive_parent(path);
> -     if (IS_ERR(np->parent)) {
> -             err = PTR_ERR(np->parent);
> -             goto out_err;
> +     np = of_find_node_by_path(path)

Missing ;

Did you test build ?

> +     if (np) {
> +             of_node_put(np);
> +             return ERR_PTR(-EINVAL);
>       }
>   
> -     err = of_attach_node(np);
> -     if (err) {
> -             printk(KERN_ERR "Failed to add device node %s\n", path);
> -             goto out_err;
> -     }
> +     parent = pseries_of_derive_parent(path);
> +     if (IS_ERR(parent))
> +             return parent;
>   
> -     of_node_put(np->parent);
> +     np = of_node_alloc(kbasename(path));
> +     if (!np) {
> +             of_node_put(parent);
> +             return ERR_PTR(-ENOMEM);
> +     }
>   
> -     return 0;
> +     np->parent = parent;
>   
> -out_err:
> -     if (np) {
> -             of_node_put(np->parent);
> -             kfree(np->full_name);
> -             kfree(np);
> -     }
> -     return err;
> +     return np;
>   }
>   
>   static int pSeries_reconfig_remove_node(struct device_node *np)

Reply via email to