diff options
author | Lorenzo Bertin Salvador <lorenzobs@usp.br> | 2024-04-20 15:27:43 -0300 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2024-04-21 18:42:33 +0100 |
commit | b80ad8e3cd2712b78b98804d1f59199680d8ed91 (patch) | |
tree | 8fdfb6d6416d31540b1a5fc81dfb39e1329600b3 /drivers/iio/adc/ti-ads131e08.c | |
parent | cf1c833f89e7c8635a28c3db15c68ead150ea712 (diff) | |
download | lwn-b80ad8e3cd2712b78b98804d1f59199680d8ed91.tar.gz lwn-b80ad8e3cd2712b78b98804d1f59199680d8ed91.zip |
iio: adc: ti-ads131e08: Use device_for_each_child_node_scoped() to simplify error paths.
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>
Link: https://lore.kernel.org/r/20240420182744.153184-2-lorenzobs@usp.br
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/adc/ti-ads131e08.c')
-rw-r--r-- | drivers/iio/adc/ti-ads131e08.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/drivers/iio/adc/ti-ads131e08.c b/drivers/iio/adc/ti-ads131e08.c index fcfc46254313..cb04a29b3dba 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) |