Skip to content

Commit 42476bc

Browse files
krzklag-linaro
authored andcommitted
leds: sc27xx: 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 af72872 commit 42476bc

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

drivers/leds/leds-sc27xx-bltc.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ static int sc27xx_led_register(struct device *dev, struct sc27xx_led_priv *priv)
276276
static int sc27xx_led_probe(struct platform_device *pdev)
277277
{
278278
struct device *dev = &pdev->dev;
279-
struct device_node *np = dev_of_node(dev), *child;
279+
struct device_node *np = dev_of_node(dev);
280280
struct sc27xx_led_priv *priv;
281281
u32 base, count, reg;
282282
int err;
@@ -304,17 +304,13 @@ static int sc27xx_led_probe(struct platform_device *pdev)
304304
return err;
305305
}
306306

307-
for_each_available_child_of_node(np, child) {
307+
for_each_available_child_of_node_scoped(np, child) {
308308
err = of_property_read_u32(child, "reg", &reg);
309-
if (err) {
310-
of_node_put(child);
309+
if (err)
311310
return err;
312-
}
313311

314-
if (reg >= SC27XX_LEDS_MAX || priv->leds[reg].active) {
315-
of_node_put(child);
312+
if (reg >= SC27XX_LEDS_MAX || priv->leds[reg].active)
316313
return -EINVAL;
317-
}
318314

319315
priv->leds[reg].fwnode = of_fwnode_handle(child);
320316
priv->leds[reg].active = true;

0 commit comments

Comments
 (0)