[PATCH] leds: lp55xx: Simplify with scoped for each OF child loop

Krzysztof Kozlowski posted 1 patch 1 month, 2 weeks ago
drivers/leds/leds-lp55xx-common.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
[PATCH] leds: lp55xx: Simplify with scoped for each OF child loop
Posted by Krzysztof Kozlowski 1 month, 2 weeks ago
Use scoped for-each loop when iterating over device nodes to make code a
bit simpler.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---
 drivers/leds/leds-lp55xx-common.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/leds/leds-lp55xx-common.c b/drivers/leds/leds-lp55xx-common.c
index fd447eb7eb15..ea131177de96 100644
--- a/drivers/leds/leds-lp55xx-common.c
+++ b/drivers/leds/leds-lp55xx-common.c
@@ -1204,7 +1204,6 @@ static struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev,
 							     struct device_node *np,
 							     struct lp55xx_chip *chip)
 {
-	struct device_node *child;
 	struct lp55xx_platform_data *pdata;
 	struct lp55xx_led_config *cfg;
 	int num_channels;
@@ -1229,12 +1228,10 @@ static struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev,
 	pdata->num_channels = num_channels;
 	cfg->max_channel = chip->cfg->max_channel;
 
-	for_each_available_child_of_node(np, child) {
+	for_each_available_child_of_node_scoped(np, child) {
 		ret = lp55xx_parse_logical_led(child, cfg, i);
-		if (ret) {
-			of_node_put(child);
+		if (ret)
 			return ERR_PTR(-EINVAL);
-		}
 		i++;
 	}
 
-- 
2.51.0
Re: (subset) [PATCH] leds: lp55xx: Simplify with scoped for each OF child loop
Posted by Lee Jones 1 month ago
On Wed, 24 Dec 2025 13:45:22 +0100, Krzysztof Kozlowski wrote:
> Use scoped for-each loop when iterating over device nodes to make code a
> bit simpler.
> 
> 

Applied, thanks!

[1/1] leds: lp55xx: Simplify with scoped for each OF child loop
      commit: e257dc532c20bd93f0076c18cb5ffd739a5f0bb4

--
Lee Jones [李琼斯]