Skip to content

Commit 073f016

Browse files
krzklag-linaro
authored andcommitted
leds: aw2013: Simplify with scoped for each OF child loop
Use scoped for_each_available_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Signed-off-by: Krzysztof Kozlowski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent 6c17a9a commit 073f016

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

drivers/leds/leds-aw2013.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ static int aw2013_blink_set(struct led_classdev *cdev,
263263

264264
static int aw2013_probe_dt(struct aw2013 *chip)
265265
{
266-
struct device_node *np = dev_of_node(&chip->client->dev), *child;
266+
struct device_node *np = dev_of_node(&chip->client->dev);
267267
int count, ret = 0, i = 0;
268268
struct aw2013_led *led;
269269

@@ -273,7 +273,7 @@ static int aw2013_probe_dt(struct aw2013 *chip)
273273

274274
regmap_write(chip->regmap, AW2013_RSTR, AW2013_RSTR_RESET);
275275

276-
for_each_available_child_of_node(np, child) {
276+
for_each_available_child_of_node_scoped(np, child) {
277277
struct led_init_data init_data = {};
278278
u32 source;
279279
u32 imax;
@@ -304,10 +304,8 @@ static int aw2013_probe_dt(struct aw2013 *chip)
304304

305305
ret = devm_led_classdev_register_ext(&chip->client->dev,
306306
&led->cdev, &init_data);
307-
if (ret < 0) {
308-
of_node_put(child);
307+
if (ret < 0)
309308
return ret;
310-
}
311309

312310
i++;
313311
}

0 commit comments

Comments
 (0)