Commit 42476bce authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Lee Jones

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: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240816-cleanup-h-of-node-put-var-v1-15-1d0292802470@linaro.orgSigned-off-by: default avatarLee Jones <lee@kernel.org>
parent af728722
...@@ -276,7 +276,7 @@ static int sc27xx_led_register(struct device *dev, struct sc27xx_led_priv *priv) ...@@ -276,7 +276,7 @@ static int sc27xx_led_register(struct device *dev, struct sc27xx_led_priv *priv)
static int sc27xx_led_probe(struct platform_device *pdev) static int sc27xx_led_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct device_node *np = dev_of_node(dev), *child; struct device_node *np = dev_of_node(dev);
struct sc27xx_led_priv *priv; struct sc27xx_led_priv *priv;
u32 base, count, reg; u32 base, count, reg;
int err; int err;
...@@ -304,17 +304,13 @@ static int sc27xx_led_probe(struct platform_device *pdev) ...@@ -304,17 +304,13 @@ static int sc27xx_led_probe(struct platform_device *pdev)
return err; return err;
} }
for_each_available_child_of_node(np, child) { for_each_available_child_of_node_scoped(np, child) {
err = of_property_read_u32(child, "reg", &reg); err = of_property_read_u32(child, "reg", &reg);
if (err) { if (err)
of_node_put(child);
return err; return err;
}
if (reg >= SC27XX_LEDS_MAX || priv->leds[reg].active) { if (reg >= SC27XX_LEDS_MAX || priv->leds[reg].active)
of_node_put(child);
return -EINVAL; return -EINVAL;
}
priv->leds[reg].fwnode = of_fwnode_handle(child); priv->leds[reg].fwnode = of_fwnode_handle(child);
priv->leds[reg].active = true; priv->leds[reg].active = true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment