* [PATCH v3] iio: adc: ti-ads1015: use device_for_each_child_node_scoped()
@ 2024-04-29 13:22 Lincoln Yuji
2024-05-01 7:45 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Lincoln Yuji @ 2024-04-29 13:22 UTC (permalink / raw)
To: jic23
Cc: Lincoln Yuji, Luiza Soezima, Sabrina Araujo, Marcelo Schmitt,
linux-iio
This loop definition removes the need for manual releasing of the
fwnode_handle in early exit paths (here an error path) allow
simplification of the code and reducing the chance of future
modifications not releasing fwnode_handle correctly.
Co-developed-by: Luiza Soezima <lbrsoezima@usp.br>
Signed-off-by: Luiza Soezima <lbrsoezima@usp.br>
Co-developed-by: Sabrina Araujo <sabrinaaraujo@usp.br>
Signed-off-by: Sabrina Araujo <sabrinaaraujo@usp.br>
Signed-off-by: Lincoln Yuji <lincolnyuji@usp.br>
Reviewed-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
---
drivers/iio/adc/ti-ads1015.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c
index 6ae967e4d..d3363d02f 100644
--- a/drivers/iio/adc/ti-ads1015.c
+++ b/drivers/iio/adc/ti-ads1015.c
@@ -902,10 +902,9 @@ static int ads1015_client_get_channels_config(struct i2c_client *client)
struct iio_dev *indio_dev = i2c_get_clientdata(client);
struct ads1015_data *data = iio_priv(indio_dev);
struct device *dev = &client->dev;
- struct fwnode_handle *node;
int i = -1;
- device_for_each_child_node(dev, node) {
+ device_for_each_child_node_scoped(dev, node) {
u32 pval;
unsigned int channel;
unsigned int pga = ADS1015_DEFAULT_PGA;
@@ -927,7 +926,6 @@ static int ads1015_client_get_channels_config(struct i2c_client *client)
pga = pval;
if (pga > 5) {
dev_err(dev, "invalid gain on %pfw\n", node);
- fwnode_handle_put(node);
return -EINVAL;
}
}
@@ -936,7 +934,6 @@ static int ads1015_client_get_channels_config(struct i2c_client *client)
data_rate = pval;
if (data_rate > 7) {
dev_err(dev, "invalid data_rate on %pfw\n", node);
- fwnode_handle_put(node);
return -EINVAL;
}
}
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v3] iio: adc: ti-ads1015: use device_for_each_child_node_scoped()
2024-04-29 13:22 [PATCH v3] iio: adc: ti-ads1015: use device_for_each_child_node_scoped() Lincoln Yuji
@ 2024-05-01 7:45 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2024-05-01 7:45 UTC (permalink / raw)
To: Lincoln Yuji; +Cc: Luiza Soezima, Sabrina Araujo, Marcelo Schmitt, linux-iio
On Mon, 29 Apr 2024 10:22:33 -0300
Lincoln Yuji <lincolnyuji@usp.br> wrote:
> This loop definition removes the need for manual releasing of the
> fwnode_handle in early exit paths (here an error path) allow
> simplification of the code and reducing the chance of future
> modifications not releasing fwnode_handle correctly.
>
> Co-developed-by: Luiza Soezima <lbrsoezima@usp.br>
> Signed-off-by: Luiza Soezima <lbrsoezima@usp.br>
> Co-developed-by: Sabrina Araujo <sabrinaaraujo@usp.br>
> Signed-off-by: Sabrina Araujo <sabrinaaraujo@usp.br>
> Signed-off-by: Lincoln Yuji <lincolnyuji@usp.br>
> Reviewed-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Meh. If I take this one I don't need to wait for review on the version
everyone ignored :(
Applied.
> ---
> drivers/iio/adc/ti-ads1015.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c
> index 6ae967e4d..d3363d02f 100644
> --- a/drivers/iio/adc/ti-ads1015.c
> +++ b/drivers/iio/adc/ti-ads1015.c
> @@ -902,10 +902,9 @@ static int ads1015_client_get_channels_config(struct i2c_client *client)
> struct iio_dev *indio_dev = i2c_get_clientdata(client);
> struct ads1015_data *data = iio_priv(indio_dev);
> struct device *dev = &client->dev;
> - struct fwnode_handle *node;
> int i = -1;
>
> - device_for_each_child_node(dev, node) {
> + device_for_each_child_node_scoped(dev, node) {
> u32 pval;
> unsigned int channel;
> unsigned int pga = ADS1015_DEFAULT_PGA;
> @@ -927,7 +926,6 @@ static int ads1015_client_get_channels_config(struct i2c_client *client)
> pga = pval;
> if (pga > 5) {
> dev_err(dev, "invalid gain on %pfw\n", node);
> - fwnode_handle_put(node);
> return -EINVAL;
> }
> }
> @@ -936,7 +934,6 @@ static int ads1015_client_get_channels_config(struct i2c_client *client)
> data_rate = pval;
> if (data_rate > 7) {
> dev_err(dev, "invalid data_rate on %pfw\n", node);
> - fwnode_handle_put(node);
> return -EINVAL;
> }
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-05-01 7:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-29 13:22 [PATCH v3] iio: adc: ti-ads1015: use device_for_each_child_node_scoped() Lincoln Yuji
2024-05-01 7:45 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox