Linux-IIO Archive mirror
 help / color / mirror / Atom feed
From: Lincoln Yuji <lincolnyuji@usp.br>
To: jic23@kernel.org
Cc: Lincoln Yuji <lincolnyuji@hotmail.com>,
	Luiza Soezima <lbrsoezima@usp.br>,
	Sabrina Araujo <sabrinaaraujo@usp.br>,
	Lincoln Yuji <lincolnyuji@usp.br>,
	linux-iio@vger.kernel.org
Subject: [PATCH] iio: adc: ti-ads1015: use device_for_each_child_node_scoped()
Date: Fri, 26 Apr 2024 10:19:53 -0300	[thread overview]
Message-ID: <20240426131953.14933-1-lincolnyuji@usp.br> (raw)

From: Lincoln Yuji <lincolnyuji@hotmail.com>

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>
---
 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


             reply	other threads:[~2024-04-26 13:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-26 13:19 Lincoln Yuji [this message]
2024-04-27 11:14 ` [PATCH] iio: adc: ti-ads1015: use device_for_each_child_node_scoped() Marcelo Schmitt
2024-04-28 15:36   ` Jonathan Cameron
2024-04-28 15:41     ` Jonathan Cameron
  -- strict thread matches above, loose matches on Subject: below --
2024-04-27 12:10 Lincoln Yuji
2024-04-28 11:39 ` 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=20240426131953.14933-1-lincolnyuji@usp.br \
    --to=lincolnyuji@usp.br \
    --cc=jic23@kernel.org \
    --cc=lbrsoezima@usp.br \
    --cc=lincolnyuji@hotmail.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=sabrinaaraujo@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).