Skip to content

Commit d3f5f67

Browse files
krzklag-linaro
authored andcommitted
leds: netxbig: 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 84e2b97 commit d3f5f67

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

drivers/leds/leds-netxbig.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,6 @@ static int netxbig_leds_get_of_pdata(struct device *dev,
423423
struct device_node *gpio_ext_np;
424424
struct platform_device *gpio_ext_pdev;
425425
struct device *gpio_ext_dev;
426-
struct device_node *child;
427426
struct netxbig_gpio_ext *gpio_ext;
428427
struct netxbig_led_timer *timers;
429428
struct netxbig_led *leds, *led;
@@ -507,33 +506,33 @@ static int netxbig_leds_get_of_pdata(struct device *dev,
507506
}
508507

509508
led = leds;
510-
for_each_available_child_of_node(np, child) {
509+
for_each_available_child_of_node_scoped(np, child) {
511510
const char *string;
512511
int *mode_val;
513512
int num_modes;
514513

515514
ret = of_property_read_u32(child, "mode-addr",
516515
&led->mode_addr);
517516
if (ret)
518-
goto err_node_put;
517+
goto put_device;
519518

520519
ret = of_property_read_u32(child, "bright-addr",
521520
&led->bright_addr);
522521
if (ret)
523-
goto err_node_put;
522+
goto put_device;
524523

525524
ret = of_property_read_u32(child, "max-brightness",
526525
&led->bright_max);
527526
if (ret)
528-
goto err_node_put;
527+
goto put_device;
529528

530529
mode_val =
531530
devm_kcalloc(dev,
532531
NETXBIG_LED_MODE_NUM, sizeof(*mode_val),
533532
GFP_KERNEL);
534533
if (!mode_val) {
535534
ret = -ENOMEM;
536-
goto err_node_put;
535+
goto put_device;
537536
}
538537

539538
for (i = 0; i < NETXBIG_LED_MODE_NUM; i++)
@@ -542,12 +541,12 @@ static int netxbig_leds_get_of_pdata(struct device *dev,
542541
ret = of_property_count_u32_elems(child, "mode-val");
543542
if (ret < 0 || ret % 2) {
544543
ret = -EINVAL;
545-
goto err_node_put;
544+
goto put_device;
546545
}
547546
num_modes = ret / 2;
548547
if (num_modes > NETXBIG_LED_MODE_NUM) {
549548
ret = -EINVAL;
550-
goto err_node_put;
549+
goto put_device;
551550
}
552551

553552
for (i = 0; i < num_modes; i++) {
@@ -560,7 +559,7 @@ static int netxbig_leds_get_of_pdata(struct device *dev,
560559
"mode-val", 2 * i + 1, &val);
561560
if (mode >= NETXBIG_LED_MODE_NUM) {
562561
ret = -EINVAL;
563-
goto err_node_put;
562+
goto put_device;
564563
}
565564
mode_val[mode] = val;
566565
}
@@ -583,8 +582,6 @@ static int netxbig_leds_get_of_pdata(struct device *dev,
583582

584583
return 0;
585584

586-
err_node_put:
587-
of_node_put(child);
588585
put_device:
589586
put_device(gpio_ext_dev);
590587
return ret;

0 commit comments

Comments
 (0)