From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: "Clément Léger" <clement.leger@bootlin.com>,
"Michael Ellerman" <mpe@ellerman.id.au>,
"Benjamin Herrenschmidt" <benh@kernel.crashing.org>,
"Paul Mackerras" <paulus@samba.org>,
"Rob Herring" <robh+dt@kernel.org>,
"Frank Rowand" <frowand.list@gmail.com>,
"Nathan Lynch" <nathanl@linux.ibm.com>,
"Laurent Dufour" <ldufour@linux.ibm.com>,
"Daniel Henrique Barboza" <danielhb413@gmail.com>,
"David Gibson" <david@gibson.dropbear.id.au>,
"Andrew Morton" <akpm@linux-foundation.org>,
"David Hildenbrand" <david@redhat.com>,
"Ohhoon Kwon" <ohoono.kwon@samsung.com>,
"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>,
YueHaibing <yuehaibing@huawei.com>
Cc: "devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
Steen Hegelund <steen.hegelund@microchip.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Horatiu Vultur <horatiu.vultur@microchip.com>,
Allan Nielsen <allan.nielsen@microchip.com>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Bjorn Helgaas <helgaas@kernel.org>,
"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
Lizhi Hou <lizhi.hou@xilinx.com>
Subject: Re: [PATCH v3 5/5] powerpc/pseries: use of_property_alloc/free() and of_node_alloc()
Date: Tue, 28 Jun 2022 17:00:45 +0000 [thread overview]
Message-ID: <a6068e53-80ea-600b-0b54-0a1d0c784c54@csgroup.eu> (raw)
In-Reply-To: <20220620104123.341054-6-clement.leger@bootlin.com>
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.leger@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)
next prev parent reply other threads:[~2022-06-28 17:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-20 10:41 [PATCH v3 0/5] of: add of_property_alloc/free() and of_node_alloc() Clément Léger
2022-06-20 10:41 ` [PATCH v3 1/5] of: constify of_property_check_flags() prop argument Clément Léger
2022-06-27 17:19 ` Rob Herring
2022-06-20 10:41 ` [PATCH v3 2/5] of: remove __of_node_dup() allocflags parameter Clément Léger
2022-06-21 17:15 ` Bjorn Helgaas
2022-06-20 10:41 ` [PATCH v3 3/5] of: dynamic: add of_property_alloc() and of_property_free() Clément Léger
2022-06-20 10:41 ` [PATCH v3 4/5] of: dynamic: add of_node_alloc() Clément Léger
2022-06-20 10:41 ` [PATCH v3 5/5] powerpc/pseries: use of_property_alloc/free() and of_node_alloc() Clément Léger
2022-06-28 17:00 ` Christophe Leroy [this message]
2022-06-29 7:30 ` Clément Léger
2022-06-24 4:02 ` [PATCH v3 0/5] of: add " Frank Rowand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a6068e53-80ea-600b-0b54-0a1d0c784c54@csgroup.eu \
--to=christophe.leroy@csgroup.eu \
--cc=akpm@linux-foundation.org \
--cc=allan.nielsen@microchip.com \
--cc=aneesh.kumar@linux.ibm.com \
--cc=benh@kernel.crashing.org \
--cc=clement.leger@bootlin.com \
--cc=danielhb413@gmail.com \
--cc=david@gibson.dropbear.id.au \
--cc=david@redhat.com \
--cc=devicetree@vger.kernel.org \
--cc=frowand.list@gmail.com \
--cc=helgaas@kernel.org \
--cc=horatiu.vultur@microchip.com \
--cc=ldufour@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=lizhi.hou@xilinx.com \
--cc=mpe@ellerman.id.au \
--cc=nathanl@linux.ibm.com \
--cc=ohoono.kwon@samsung.com \
--cc=paulus@samba.org \
--cc=robh+dt@kernel.org \
--cc=steen.hegelund@microchip.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=yuehaibing@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).