Skip to content

Commit af72872

Browse files
krzklag-linaro
authored andcommitted
leds: pca9532: 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 d3f5f67 commit af72872

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

drivers/leds/leds-pca9532.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,6 @@ static struct pca9532_platform_data *
506506
pca9532_of_populate_pdata(struct device *dev, struct device_node *np)
507507
{
508508
struct pca9532_platform_data *pdata;
509-
struct device_node *child;
510509
int devid, maxleds;
511510
int i = 0;
512511
const char *state;
@@ -525,7 +524,7 @@ pca9532_of_populate_pdata(struct device *dev, struct device_node *np)
525524
of_property_read_u8_array(np, "nxp,psc", &pdata->psc[PCA9532_PWM_ID_0],
526525
ARRAY_SIZE(pdata->psc));
527526

528-
for_each_available_child_of_node(np, child) {
527+
for_each_available_child_of_node_scoped(np, child) {
529528
if (of_property_read_string(child, "label",
530529
&pdata->leds[i].name))
531530
pdata->leds[i].name = child->name;
@@ -538,10 +537,8 @@ pca9532_of_populate_pdata(struct device *dev, struct device_node *np)
538537
else if (!strcmp(state, "keep"))
539538
pdata->leds[i].state = PCA9532_KEEP;
540539
}
541-
if (++i >= maxleds) {
542-
of_node_put(child);
540+
if (++i >= maxleds)
543541
break;
544-
}
545542
}
546543

547544
return pdata;

0 commit comments

Comments
 (0)