Commit 05c2f554 authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Lee Jones

leds: max77693: 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-4-1d0292802470@linaro.orgSigned-off-by: default avatarLee Jones <lee@kernel.org>
parent d225d436
...@@ -599,7 +599,7 @@ static int max77693_led_parse_dt(struct max77693_led_device *led, ...@@ -599,7 +599,7 @@ static int max77693_led_parse_dt(struct max77693_led_device *led,
{ {
struct device *dev = &led->pdev->dev; struct device *dev = &led->pdev->dev;
struct max77693_sub_led *sub_leds = led->sub_leds; struct max77693_sub_led *sub_leds = led->sub_leds;
struct device_node *node = dev_of_node(dev), *child_node; struct device_node *node = dev_of_node(dev);
struct property *prop; struct property *prop;
u32 led_sources[2]; u32 led_sources[2];
int i, ret, fled_id; int i, ret, fled_id;
...@@ -608,7 +608,7 @@ static int max77693_led_parse_dt(struct max77693_led_device *led, ...@@ -608,7 +608,7 @@ static int max77693_led_parse_dt(struct max77693_led_device *led,
of_property_read_u32(node, "maxim,boost-mvout", &cfg->boost_vout); of_property_read_u32(node, "maxim,boost-mvout", &cfg->boost_vout);
of_property_read_u32(node, "maxim,mvsys-min", &cfg->low_vsys); of_property_read_u32(node, "maxim,mvsys-min", &cfg->low_vsys);
for_each_available_child_of_node(node, child_node) { for_each_available_child_of_node_scoped(node, child_node) {
prop = of_find_property(child_node, "led-sources", NULL); prop = of_find_property(child_node, "led-sources", NULL);
if (prop) { if (prop) {
const __be32 *srcs = NULL; const __be32 *srcs = NULL;
...@@ -622,7 +622,6 @@ static int max77693_led_parse_dt(struct max77693_led_device *led, ...@@ -622,7 +622,6 @@ static int max77693_led_parse_dt(struct max77693_led_device *led,
} else { } else {
dev_err(dev, dev_err(dev,
"led-sources DT property missing\n"); "led-sources DT property missing\n");
of_node_put(child_node);
return -EINVAL; return -EINVAL;
} }
...@@ -638,14 +637,12 @@ static int max77693_led_parse_dt(struct max77693_led_device *led, ...@@ -638,14 +637,12 @@ static int max77693_led_parse_dt(struct max77693_led_device *led,
} else { } else {
dev_err(dev, dev_err(dev,
"Wrong led-sources DT property value.\n"); "Wrong led-sources DT property value.\n");
of_node_put(child_node);
return -EINVAL; return -EINVAL;
} }
if (sub_nodes[fled_id]) { if (sub_nodes[fled_id]) {
dev_err(dev, dev_err(dev,
"Conflicting \"led-sources\" DT properties\n"); "Conflicting \"led-sources\" DT properties\n");
of_node_put(child_node);
return -EINVAL; return -EINVAL;
} }
...@@ -681,10 +678,8 @@ static int max77693_led_parse_dt(struct max77693_led_device *led, ...@@ -681,10 +678,8 @@ static int max77693_led_parse_dt(struct max77693_led_device *led,
if (++cfg->num_leds == 2 || if (++cfg->num_leds == 2 ||
(max77693_fled_used(led, FLED1) && (max77693_fled_used(led, FLED1) &&
max77693_fled_used(led, FLED2))) { max77693_fled_used(led, FLED2)))
of_node_put(child_node);
break; break;
}
} }
if (cfg->num_leds == 0) { if (cfg->num_leds == 0) {
......
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