Skip to content

Commit 234c074

Browse files
javiercarrascocruzgroeck
authored andcommitted
hwmon: (ltc2991) 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-1-53997abde43c@gmail.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
1 parent 5507645 commit 234c074

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

drivers/hwmon/ltc2991.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,6 @@ static const struct regmap_config ltc2991_regmap_config = {
284284

285285
static int ltc2991_init(struct ltc2991_state *st, struct device *dev)
286286
{
287-
struct fwnode_handle *child;
288287
int ret;
289288
u32 val, addr;
290289
u8 v5_v8_reg_data = 0, v1_v4_reg_data = 0;
@@ -294,17 +293,13 @@ static int ltc2991_init(struct ltc2991_state *st, struct device *dev)
294293
return dev_err_probe(dev, ret,
295294
"failed to enable regulator\n");
296295

297-
device_for_each_child_node(dev, child) {
296+
device_for_each_child_node_scoped(dev, child) {
298297
ret = fwnode_property_read_u32(child, "reg", &addr);
299-
if (ret < 0) {
300-
fwnode_handle_put(child);
298+
if (ret < 0)
301299
return ret;
302-
}
303300

304-
if (addr > 3) {
305-
fwnode_handle_put(child);
301+
if (addr > 3)
306302
return -EINVAL;
307-
}
308303

309304
ret = fwnode_property_read_u32(child,
310305
"shunt-resistor-micro-ohms",

0 commit comments

Comments
 (0)