Skip to content

Commit 9557b43

Browse files
krzklag-linaro
authored andcommitted
leds: qcom-lpg: 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 122d57e commit 9557b43

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

drivers/leds/rgb/leds-qcom-lpg.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,7 +1368,6 @@ static int lpg_add_led(struct lpg *lpg, struct device_node *np)
13681368
{
13691369
struct led_init_data init_data = {};
13701370
struct led_classdev *cdev;
1371-
struct device_node *child;
13721371
struct mc_subled *info;
13731372
struct lpg_led *led;
13741373
const char *state;
@@ -1399,12 +1398,10 @@ static int lpg_add_led(struct lpg *lpg, struct device_node *np)
13991398
if (!info)
14001399
return -ENOMEM;
14011400
i = 0;
1402-
for_each_available_child_of_node(np, child) {
1401+
for_each_available_child_of_node_scoped(np, child) {
14031402
ret = lpg_parse_channel(lpg, child, &led->channels[i]);
1404-
if (ret < 0) {
1405-
of_node_put(child);
1403+
if (ret < 0)
14061404
return ret;
1407-
}
14081405

14091406
info[i].color_index = led->channels[i]->color;
14101407
info[i].intensity = 0;
@@ -1600,7 +1597,6 @@ static int lpg_init_sdam(struct lpg *lpg)
16001597

16011598
static int lpg_probe(struct platform_device *pdev)
16021599
{
1603-
struct device_node *np;
16041600
struct lpg *lpg;
16051601
int ret;
16061602
int i;
@@ -1640,12 +1636,10 @@ static int lpg_probe(struct platform_device *pdev)
16401636
if (ret < 0)
16411637
return ret;
16421638

1643-
for_each_available_child_of_node(pdev->dev.of_node, np) {
1639+
for_each_available_child_of_node_scoped(pdev->dev.of_node, np) {
16441640
ret = lpg_add_led(lpg, np);
1645-
if (ret) {
1646-
of_node_put(np);
1641+
if (ret)
16471642
return ret;
1648-
}
16491643
}
16501644

16511645
for (i = 0; i < lpg->num_channels; i++)

0 commit comments

Comments
 (0)