Skip to content

Commit 2c37529

Browse files
krzklag-linaro
authored andcommitted
leds: is31fl32xx: 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 c57ba40 commit 2c37529

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

drivers/leds/leds-is31fl32xx.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -363,10 +363,9 @@ static struct is31fl32xx_led_data *is31fl32xx_find_led_data(
363363
static int is31fl32xx_parse_dt(struct device *dev,
364364
struct is31fl32xx_priv *priv)
365365
{
366-
struct device_node *child;
367366
int ret = 0;
368367

369-
for_each_available_child_of_node(dev_of_node(dev), child) {
368+
for_each_available_child_of_node_scoped(dev_of_node(dev), child) {
370369
struct led_init_data init_data = {};
371370
struct is31fl32xx_led_data *led_data =
372371
&priv->leds[priv->num_leds];
@@ -376,7 +375,7 @@ static int is31fl32xx_parse_dt(struct device *dev,
376375

377376
ret = is31fl32xx_parse_child_dt(dev, child, led_data);
378377
if (ret)
379-
goto err;
378+
return ret;
380379

381380
/* Detect if channel is already in use by another child */
382381
other_led_data = is31fl32xx_find_led_data(priv,
@@ -385,8 +384,7 @@ static int is31fl32xx_parse_dt(struct device *dev,
385384
dev_err(dev,
386385
"Node %pOF 'reg' conflicts with another LED\n",
387386
child);
388-
ret = -EINVAL;
389-
goto err;
387+
return -EINVAL;
390388
}
391389

392390
init_data.fwnode = of_fwnode_handle(child);
@@ -396,17 +394,13 @@ static int is31fl32xx_parse_dt(struct device *dev,
396394
if (ret) {
397395
dev_err(dev, "Failed to register LED for %pOF: %d\n",
398396
child, ret);
399-
goto err;
397+
return ret;
400398
}
401399

402400
priv->num_leds++;
403401
}
404402

405403
return 0;
406-
407-
err:
408-
of_node_put(child);
409-
return ret;
410404
}
411405

412406
static const struct of_device_id of_is31fl32xx_match[] = {

0 commit comments

Comments
 (0)