Skip to content

Commit 6a1d796

Browse files
krzklag-linaro
authored andcommitted
leds: bcm6328: 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 <krzysztof.kozlowski@linaro.org> Link: https://lore.kernel.org/r/20240816-cleanup-h-of-node-put-var-v1-7-1d0292802470@linaro.org Signed-off-by: Lee Jones <lee@kernel.org>
1 parent 073f016 commit 6a1d796

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

drivers/leds/leds-bcm6328.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,6 @@ static int bcm6328_leds_probe(struct platform_device *pdev)
392392
{
393393
struct device *dev = &pdev->dev;
394394
struct device_node *np = dev_of_node(&pdev->dev);
395-
struct device_node *child;
396395
void __iomem *mem;
397396
spinlock_t *lock; /* memory lock */
398397
unsigned long val, *blink_leds, *blink_delay;
@@ -435,7 +434,7 @@ static int bcm6328_leds_probe(struct platform_device *pdev)
435434
val |= BCM6328_SERIAL_LED_SHIFT_DIR;
436435
bcm6328_led_write(mem + BCM6328_REG_INIT, val);
437436

438-
for_each_available_child_of_node(np, child) {
437+
for_each_available_child_of_node_scoped(np, child) {
439438
int rc;
440439
u32 reg;
441440

@@ -454,10 +453,8 @@ static int bcm6328_leds_probe(struct platform_device *pdev)
454453
rc = bcm6328_led(dev, child, reg, mem, lock,
455454
blink_leds, blink_delay);
456455

457-
if (rc < 0) {
458-
of_node_put(child);
456+
if (rc < 0)
459457
return rc;
460-
}
461458
}
462459

463460
return 0;

0 commit comments

Comments
 (0)