Skip to content

Commit 122d57e

Browse files
krzklag-linaro
authored andcommitted
leds: turris-omnia: 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]> Reviewed-by: Marek Behún <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent 42476bc commit 122d57e

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

drivers/leds/leds-turris-omnia.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ static int omnia_mcu_get_features(const struct i2c_client *client)
452452
static int omnia_leds_probe(struct i2c_client *client)
453453
{
454454
struct device *dev = &client->dev;
455-
struct device_node *np = dev_of_node(dev), *child;
455+
struct device_node *np = dev_of_node(dev);
456456
struct omnia_leds *leds;
457457
struct omnia_led *led;
458458
int ret, count;
@@ -497,12 +497,10 @@ static int omnia_leds_probe(struct i2c_client *client)
497497
}
498498

499499
led = &leds->leds[0];
500-
for_each_available_child_of_node(np, child) {
500+
for_each_available_child_of_node_scoped(np, child) {
501501
ret = omnia_led_register(client, led, child);
502-
if (ret < 0) {
503-
of_node_put(child);
502+
if (ret < 0)
504503
return ret;
505-
}
506504

507505
led += ret;
508506
}

0 commit comments

Comments
 (0)