From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Hans de Goede <hdegoede@redhat.com>, Chen-Yu Tsai <wens@csie.org>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Samuel Holland <samuel@sholland.org>,
Florian Fainelli <florian.fainelli@broadcom.com>,
Broadcom internal kernel review list
<bcm-kernel-feedback-list@broadcom.com>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, linux-sunxi@lists.linux.dev,
linux-rpi-kernel@lists.infradead.org
Subject: Re: [PATCH 03/10] Input: sun4i-lradc-keys - switch to for_each_child_of_node_scoped
Date: Sat, 19 Oct 2024 21:02:25 -0700 [thread overview]
Message-ID: <ZxSA0YF3f7Q86pRV@google.com> (raw)
In-Reply-To: <20241010-input_automate_of_node_put-v1-3-ebc62138fbf8@gmail.com>
On Thu, Oct 10, 2024 at 11:25:53PM +0200, Javier Carrasco wrote:
> Use the scoped variant of the macro to simplify the code and error
> handling. This makes the error handling more robust by ensuring that
> the child node is always freed.
>
> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
> ---
> drivers/input/keyboard/sun4i-lradc-keys.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/input/keyboard/sun4i-lradc-keys.c b/drivers/input/keyboard/sun4i-lradc-keys.c
> index f304cab0ebdb..f1e269605f05 100644
> --- a/drivers/input/keyboard/sun4i-lradc-keys.c
> +++ b/drivers/input/keyboard/sun4i-lradc-keys.c
> @@ -202,7 +202,7 @@ static void sun4i_lradc_close(struct input_dev *dev)
> static int sun4i_lradc_load_dt_keymap(struct device *dev,
> struct sun4i_lradc_data *lradc)
> {
> - struct device_node *np, *pp;
> + struct device_node *np;
> int i;
> int error;
>
> @@ -223,28 +223,25 @@ static int sun4i_lradc_load_dt_keymap(struct device *dev,
> return -ENOMEM;
>
> i = 0;
> - for_each_child_of_node(np, pp) {
> + for_each_child_of_node_scoped(np, pp) {
> struct sun4i_lradc_keymap *map = &lradc->chan0_map[i];
> u32 channel;
>
> error = of_property_read_u32(pp, "channel", &channel);
> if (error || channel != 0) {
> dev_err(dev, "%pOFn: Inval channel prop\n", pp);
> - of_node_put(pp);
> return -EINVAL;
> }
>
> error = of_property_read_u32(pp, "voltage", &map->voltage);
> if (error) {
> dev_err(dev, "%pOFn: Inval voltage prop\n", pp);
> - of_node_put(pp);
> return -EINVAL;
I wonder if it would not be better to return the real error rather than
clobber it with -EINVAL, but I guess this should be a separate patch.
Applied, thank you.
--
Dmitry
next prev parent reply other threads:[~2024-10-20 4:04 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-10 21:25 [PATCH 00/10] input: automate of_node_put() calls for device_node Javier Carrasco
2024-10-10 21:25 ` [PATCH 01/10] Input: cap11xx - switch to for_each_child_of_node_scoped Javier Carrasco
2024-10-20 3:59 ` Dmitry Torokhov
2024-10-10 21:25 ` [PATCH 02/10] Input: mtk-pmic-keys " Javier Carrasco
2024-10-20 4:00 ` Dmitry Torokhov
2024-10-10 21:25 ` [PATCH 03/10] Input: sun4i-lradc-keys " Javier Carrasco
2024-10-11 10:36 ` Andre Przywara
2024-10-20 4:02 ` Dmitry Torokhov [this message]
2024-10-10 21:25 ` [PATCH 04/10] Input: twl6040-vibra - use cleanup facility for device_node Javier Carrasco
2024-10-20 4:09 ` Dmitry Torokhov
2024-10-10 21:25 ` [PATCH 05/10] Input: twl4030-vibra " Javier Carrasco
2024-10-20 4:09 ` Dmitry Torokhov
2024-10-10 21:25 ` [PATCH 06/10] Input: sparcspkr " Javier Carrasco
2024-10-10 21:43 ` Al Viro
2024-10-10 22:01 ` Javier Carrasco
2024-10-10 22:09 ` Javier Carrasco
2024-10-10 22:22 ` Al Viro
2024-10-10 22:28 ` Javier Carrasco
2024-10-10 21:25 ` [PATCH 07/10] Input: 88pm860x " Javier Carrasco
2024-10-20 4:19 ` Dmitry Torokhov
2024-10-10 21:25 ` [PATCH 08/10] Input: i8042 " Javier Carrasco
2024-10-20 4:19 ` Dmitry Torokhov
2024-10-10 21:25 ` [PATCH 09/10] Input: raspberrypi-ts " Javier Carrasco
2024-10-20 4:20 ` Dmitry Torokhov
2024-10-10 21:26 ` [PATCH 10/10] Input: ts4800-ts " Javier Carrasco
2024-10-20 4:20 ` Dmitry Torokhov
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=ZxSA0YF3f7Q86pRV@google.com \
--to=dmitry.torokhov@gmail.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=florian.fainelli@broadcom.com \
--cc=hdegoede@redhat.com \
--cc=javier.carrasco.cruz@gmail.com \
--cc=jernej.skrabec@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=matthias.bgg@gmail.com \
--cc=samuel@sholland.org \
--cc=wens@csie.org \
/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).