From: Lee Jones <lee@kernel.org>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: linux-leds@vger.kernel.org, Abdel Alkuor <alkuor@gmail.com>,
Pavel Machek <pavel@ucw.cz>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] leds: ncp5623: Use common error handling code in ncp5623_probe()
Date: Thu, 13 Jun 2024 15:47:03 +0100 [thread overview]
Message-ID: <20240613144703.GH2561462@google.com> (raw)
In-Reply-To: <5faec5de-fc36-4b38-abcb-c61954a824cd@web.de>
On Wed, 05 Jun 2024, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 5 Jun 2024 16:19:26 +0200
>
> Add a label so that a bit of exception handling can be better reused
> at the end of this function implementation.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/leds/rgb/leds-ncp5623.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/leds/rgb/leds-ncp5623.c b/drivers/leds/rgb/leds-ncp5623.c
> index 2be4ff918516..f18156683375 100644
> --- a/drivers/leds/rgb/leds-ncp5623.c
> +++ b/drivers/leds/rgb/leds-ncp5623.c
> @@ -183,16 +183,12 @@ static int ncp5623_probe(struct i2c_client *client)
>
> fwnode_for_each_available_child_node(mc_node, led_node) {
> ret = fwnode_property_read_u32(led_node, "color", &color_index);
> - if (ret) {
> - fwnode_handle_put(led_node);
> - goto release_mc_node;
> - }
> + if (ret)
> + goto release_led_node;
>
> ret = fwnode_property_read_u32(led_node, "reg", ®);
> - if (ret) {
> - fwnode_handle_put(led_node);
> - goto release_mc_node;
> - }
> + if (ret)
> + goto release_led_node;
>
> subled_info[ncp->mc_dev.num_colors].channel = reg;
> subled_info[ncp->mc_dev.num_colors++].color_index = color_index;
> @@ -223,6 +219,10 @@ static int ncp5623_probe(struct i2c_client *client)
> fwnode_handle_put(mc_node);
>
> return ret;
> +
> +release_led_node:
> + fwnode_handle_put(led_node);
> + goto release_mc_node;
No, we're not bouncing around the function like that.
Only use gotos to skip _down_ to error handling code please.
> }
>
> static void ncp5623_remove(struct i2c_client *client)
> --
> 2.45.1
>
--
Lee Jones [李琼斯]
next prev parent reply other threads:[~2024-06-13 14:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-05 14:30 [PATCH] leds: ncp5623: Use common error handling code in ncp5623_probe() Markus Elfring
2024-06-13 14:47 ` Lee Jones [this message]
2024-06-13 16:05 ` (subset) " Lee Jones
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=20240613144703.GH2561462@google.com \
--to=lee@kernel.org \
--cc=Markus.Elfring@web.de \
--cc=alkuor@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-leds@vger.kernel.org \
--cc=pavel@ucw.cz \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.