Skip to content

Commit 1ee1237

Browse files
javiercarrascocruzgroeck
authored andcommitted
hwmon: (gsc-hwmon) use device_for_each_child_node_scoped()
Switch to the _scoped() version introduced in commit 365130f ("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> Link: https://lore.kernel.org/r/20240404-hwmon_device_for_each_child_node_scoped-v1-2-53997abde43c@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
1 parent 234c074 commit 1ee1237

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

drivers/hwmon/gsc-hwmon.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ gsc_hwmon_get_devtree_pdata(struct device *dev)
249249
{
250250
struct gsc_hwmon_platform_data *pdata;
251251
struct gsc_hwmon_channel *ch;
252-
struct fwnode_handle *child;
253252
struct device_node *fan;
254253
int nchannels;
255254

@@ -276,25 +275,21 @@ gsc_hwmon_get_devtree_pdata(struct device *dev)
276275

277276
ch = pdata->channels;
278277
/* allocate structures for channels and count instances of each type */
279-
device_for_each_child_node(dev, child) {
278+
device_for_each_child_node_scoped(dev, child) {
280279
if (fwnode_property_read_string(child, "label", &ch->name)) {
281280
dev_err(dev, "channel without label\n");
282-
fwnode_handle_put(child);
283281
return ERR_PTR(-EINVAL);
284282
}
285283
if (fwnode_property_read_u32(child, "reg", &ch->reg)) {
286284
dev_err(dev, "channel without reg\n");
287-
fwnode_handle_put(child);
288285
return ERR_PTR(-EINVAL);
289286
}
290287
if (fwnode_property_read_u32(child, "gw,mode", &ch->mode)) {
291288
dev_err(dev, "channel without mode\n");
292-
fwnode_handle_put(child);
293289
return ERR_PTR(-EINVAL);
294290
}
295291
if (ch->mode > mode_max) {
296292
dev_err(dev, "invalid channel mode\n");
297-
fwnode_handle_put(child);
298293
return ERR_PTR(-EINVAL);
299294
}
300295

0 commit comments

Comments
 (0)