From: Jonathan Cameron <jic23@kernel.org>
To: Lorenzo Bertin Salvador <lorenzobs@usp.br>
Cc: Briza Mel Dias de Sousa <brizamel.dias@usp.br>,
linux-iio@vger.kernel.org
Subject: Re: [PATCH 1/2] iio: adc: ti-ads131e08: Use device_for_each_child_node_scoped() to simplify error paths.
Date: Sun, 21 Apr 2024 18:43:23 +0100 [thread overview]
Message-ID: <20240421184323.68b710e2@jic23-huawei> (raw)
In-Reply-To: <20240420182744.153184-2-lorenzobs@usp.br>
On Sat, 20 Apr 2024 15:27:43 -0300
Lorenzo Bertin Salvador <lorenzobs@usp.br> wrote:
> This loop definition automatically releases the handle on early exit
> reducing the chance of bugs that cause resource leaks.
>
> Co-developed-by: Briza Mel Dias de Sousa <brizamel.dias@usp.br>
> Signed-off-by: Briza Mel Dias de Sousa <brizamel.dias@usp.br>
> Signed-off-by: Lorenzo Bertin Salvador <lorenzobs@usp.br>
Good patch.
Applied to the togreg branch of iio.git, but I'll only push it out
as testing today so that 0-day (an autobuilder) can see if it can
find anything that we have missed.
Thanks,
Jonathan
> ---
> drivers/iio/adc/ti-ads131e08.c | 12 ++++--------
> 1 file changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/iio/adc/ti-ads131e08.c b/drivers/iio/adc/ti-ads131e08.c
> index fcfc46254..cb04a29b3 100644
> --- a/drivers/iio/adc/ti-ads131e08.c
> +++ b/drivers/iio/adc/ti-ads131e08.c
> @@ -694,7 +694,6 @@ static int ads131e08_alloc_channels(struct iio_dev *indio_dev)
> struct ads131e08_channel_config *channel_config;
> struct device *dev = &st->spi->dev;
> struct iio_chan_spec *channels;
> - struct fwnode_handle *node;
> unsigned int channel, tmp;
> int num_channels, i, ret;
>
> @@ -736,10 +735,10 @@ static int ads131e08_alloc_channels(struct iio_dev *indio_dev)
> return -ENOMEM;
>
> i = 0;
> - device_for_each_child_node(dev, node) {
> + device_for_each_child_node_scoped(dev, node) {
> ret = fwnode_property_read_u32(node, "reg", &channel);
> if (ret)
> - goto err_child_out;
> + return ret;
>
> ret = fwnode_property_read_u32(node, "ti,gain", &tmp);
> if (ret) {
> @@ -747,7 +746,7 @@ static int ads131e08_alloc_channels(struct iio_dev *indio_dev)
> } else {
> ret = ads131e08_pga_gain_to_field_value(st, tmp);
> if (ret < 0)
> - goto err_child_out;
> + return ret;
>
> channel_config[i].pga_gain = tmp;
> }
> @@ -758,7 +757,7 @@ static int ads131e08_alloc_channels(struct iio_dev *indio_dev)
> } else {
> ret = ads131e08_validate_channel_mux(st, tmp);
> if (ret)
> - goto err_child_out;
> + return ret;
>
> channel_config[i].mux = tmp;
> }
> @@ -785,9 +784,6 @@ static int ads131e08_alloc_channels(struct iio_dev *indio_dev)
>
> return 0;
>
> -err_child_out:
> - fwnode_handle_put(node);
> - return ret;
> }
>
> static void ads131e08_regulator_disable(void *data)
next prev parent reply other threads:[~2024-04-21 17:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-20 18:27 [PATCH 0/2] IIO: Use of device_for_each_child_node_scoped() in ti-ads131e08 Lorenzo Bertin Salvador
2024-04-20 18:27 ` [PATCH 1/2] iio: adc: ti-ads131e08: Use device_for_each_child_node_scoped() to simplify error paths Lorenzo Bertin Salvador
2024-04-21 17:43 ` Jonathan Cameron [this message]
2024-04-20 18:27 ` [PATCH 2/2] iio: adc: ti-ads131e08: Fix a style problem in struct declaration Lorenzo Bertin Salvador
2024-04-21 17:27 ` Jonathan Cameron
2024-04-21 17:40 ` [PATCH 0/2] IIO: Use of device_for_each_child_node_scoped() in ti-ads131e08 Jonathan Cameron
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=20240421184323.68b710e2@jic23-huawei \
--to=jic23@kernel.org \
--cc=brizamel.dias@usp.br \
--cc=linux-iio@vger.kernel.org \
--cc=lorenzobs@usp.br \
/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