From: Jonathan Cameron <jic23@kernel.org>
To: linux-iio@vger.kernel.org,
Marius Cristea <marius.cristea@microchip.com>,
Marek Vasut <marex@denx.de>
Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>,
Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Subject: [PATCH v6 2/2] iio: adc: ti-ads1015: Use device_for_each_child_node_scoped()
Date: Sun, 28 Apr 2024 18:40:20 +0100 [thread overview]
Message-ID: <20240428174020.1832825-3-jic23@kernel.org> (raw)
In-Reply-To: <20240428174020.1832825-1-jic23@kernel.org>
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Switching to the _scoped() version removes the need for manual
calling of fwnode_handle_put() in the paths where the code
exits the loop early. In this case that's all in error paths.
Cc: Marek Vasut <marex@denx.de>
Reviewed-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.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 6ae967e4d8fa..d3363d02f292 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.44.0
prev parent reply other threads:[~2024-04-28 17:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-28 17:40 [RESEND PATCH v6 0/2] IIO: Use device_for_each_child_scope() Jonathan Cameron
2024-04-28 17:40 ` [PATCH v6 1/2] iio: adc: mcp3564: Use device_for_each_child_node_scoped() Jonathan Cameron
2024-04-28 20:25 ` Marius.Cristea
2024-04-28 20:25 ` Marcelo Schmitt
2024-04-29 19:56 ` Jonathan Cameron
2024-04-29 20:00 ` Jonathan Cameron
2024-04-28 17:40 ` Jonathan Cameron [this message]
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=20240428174020.1832825-3-jic23@kernel.org \
--to=jic23@kernel.org \
--cc=Jonathan.Cameron@huawei.com \
--cc=linux-iio@vger.kernel.org \
--cc=marcelo.schmitt1@gmail.com \
--cc=marex@denx.de \
--cc=marius.cristea@microchip.com \
/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