From: Javier Carrasco <javier.carrasco.cruz@gmail.com>
To: Antoniu Miclaus <antoniu.miclaus@analog.com>,
Jean Delvare <jdelvare@suse.com>,
Guenter Roeck <linux@roeck-us.net>,
Tim Harvey <tharvey@gateworks.com>
Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org,
Javier Carrasco <javier.carrasco.cruz@gmail.com>
Subject: [PATCH 2/2] hwmon: (gsc-hwmon) use device_for_each_child_node_scoped()
Date: Thu, 04 Apr 2024 13:13:28 +0200 [thread overview]
Message-ID: <20240404-hwmon_device_for_each_child_node_scoped-v1-2-53997abde43c@gmail.com> (raw)
In-Reply-To: <20240404-hwmon_device_for_each_child_node_scoped-v1-0-53997abde43c@gmail.com>
Switch to the _scoped() version introduced in commit 365130fd47af
("device property: Introduce device_for_each_child_node_scoped()")
to remove the need for manual calling of fwnode_handle_put() in the
paths where the code exits the loop early.
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
drivers/hwmon/gsc-hwmon.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/hwmon/gsc-hwmon.c b/drivers/hwmon/gsc-hwmon.c
index 1501ceb551e7..0f2147699c91 100644
--- a/drivers/hwmon/gsc-hwmon.c
+++ b/drivers/hwmon/gsc-hwmon.c
@@ -249,7 +249,6 @@ gsc_hwmon_get_devtree_pdata(struct device *dev)
{
struct gsc_hwmon_platform_data *pdata;
struct gsc_hwmon_channel *ch;
- struct fwnode_handle *child;
struct device_node *fan;
int nchannels;
@@ -276,25 +275,21 @@ gsc_hwmon_get_devtree_pdata(struct device *dev)
ch = pdata->channels;
/* allocate structures for channels and count instances of each type */
- device_for_each_child_node(dev, child) {
+ device_for_each_child_node_scoped(dev, child) {
if (fwnode_property_read_string(child, "label", &ch->name)) {
dev_err(dev, "channel without label\n");
- fwnode_handle_put(child);
return ERR_PTR(-EINVAL);
}
if (fwnode_property_read_u32(child, "reg", &ch->reg)) {
dev_err(dev, "channel without reg\n");
- fwnode_handle_put(child);
return ERR_PTR(-EINVAL);
}
if (fwnode_property_read_u32(child, "gw,mode", &ch->mode)) {
dev_err(dev, "channel without mode\n");
- fwnode_handle_put(child);
return ERR_PTR(-EINVAL);
}
if (ch->mode > mode_max) {
dev_err(dev, "invalid channel mode\n");
- fwnode_handle_put(child);
return ERR_PTR(-EINVAL);
}
--
2.40.1
next prev parent reply other threads:[~2024-04-04 11:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-04 11:13 [PATCH 0/2] hwmon: " Javier Carrasco
2024-04-04 11:13 ` [PATCH 1/2] hwmon: (ltc2991) " Javier Carrasco
2024-06-07 22:08 ` Guenter Roeck
2024-04-04 11:13 ` Javier Carrasco [this message]
2024-06-07 22:09 ` [PATCH 2/2] hwmon: (gsc-hwmon) " Guenter Roeck
2024-06-07 21:00 ` [PATCH 0/2] hwmon: " Javier Carrasco
2024-06-07 22:11 ` Guenter Roeck
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=20240404-hwmon_device_for_each_child_node_scoped-v1-2-53997abde43c@gmail.com \
--to=javier.carrasco.cruz@gmail.com \
--cc=antoniu.miclaus@analog.com \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=tharvey@gateworks.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
all inboxes | Powered by JetHome®