mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] leds: max77705: use fwnode_for_each_child_node_scoped() in max77705_add_led()
@ 2026-08-28  9:00 Manush Prajwal
  2026-08-28  9:25 ` Krzysztof Kozlowski
  0 siblings, 1 reply; 2+ messages in thread
From: Manush Prajwal @ 2026-08-28  9:00 UTC (permalink / raw)
  To: cw00.choi, krzk, lee, pavel
  Cc: linux-leds, linux-kernel, dsankouski, sakari.ailus

Rework the subled loop in max77705_add_led() around
fwnode_for_each_child_node_scoped() instead of adding a manual
fwnode_handle_put(child) before the early return on a
max77705_parse_subled() failure, so the reference on the current
child fwnode is released automatically on every exit path from the
loop. child is never used outside the loop, so the now-unused outer
child declaration is dropped along with it.

Suggested-by: Krzysztof Kozlowski <krzk@kernel.org>
Fixes: 3b6eaa3db567 ("leds: Use fwnode_for_each_child_node() instead")
Signed-off-by: Manush Prajwal <manushprajwal555@gmail.com>
---
v2: Rework around fwnode_for_each_child_node_scoped() instead of the
    manual fwnode_handle_put(child) from v1, per Krzysztof
    Kozlowski's review.
---
 drivers/leds/leds-max77705.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/leds/leds-max77705.c b/drivers/leds/leds-max77705.c
index 1e2054c..4fd803c 100644
--- a/drivers/leds/leds-max77705.c
+++ b/drivers/leds/leds-max77705.c
@@ -160,7 +160,6 @@ static int max77705_add_led(struct device *dev, struct regmap *regmap, struct fw
 	struct max77705_led *led;
 	struct led_classdev *cdev;
 	struct mc_subled *info;
-	struct fwnode_handle *child;
 	struct led_init_data init_data = {};

 	led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL);
@@ -191,7 +190,7 @@ static int max77705_add_led(struct device *dev, struct regmap *regmap, struct fw
 		cdev->brightness_set_blocking = max77705_led_brightness_set_multi;
 		cdev->blink_set = max77705_rgb_blink;

-		fwnode_for_each_child_node(np, child) {
+		fwnode_for_each_child_node_scoped(np, child) {
 			ret = max77705_parse_subled(dev, child, &info[i]);
 			if (ret < 0)
 				return ret;
--
2.46.2.windows.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] leds: max77705: use fwnode_for_each_child_node_scoped() in max77705_add_led()
  2026-08-28  9:00 [PATCH v2] leds: max77705: use fwnode_for_each_child_node_scoped() in max77705_add_led() Manush Prajwal
@ 2026-08-28  9:25 ` Krzysztof Kozlowski
  0 siblings, 0 replies; 2+ messages in thread
From: Krzysztof Kozlowski @ 2026-08-28  9:25 UTC (permalink / raw)
  To: Manush Prajwal, cw00.choi, lee, pavel
  Cc: linux-leds, linux-kernel, dsankouski, sakari.ailus

On 28/08/2026 11:00, Manush Prajwal wrote:
> Rework the subled loop in max77705_add_led() around
> fwnode_for_each_child_node_scoped() instead of adding a manual
> fwnode_handle_put(child) before the early return on a
> max77705_parse_subled() failure, so the reference on the current
> child fwnode is released automatically on every exit path from the
> loop. child is never used outside the loop, so the now-unused outer
> child declaration is dropped along with it.
> 
> Suggested-by: Krzysztof Kozlowski <krzk@kernel.org>

That's probably a stretch, I suggested only a solution, not the commit
itself. Anyway, no need to resend to change it.

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-28  9:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-28  9:00 [PATCH v2] leds: max77705: use fwnode_for_each_child_node_scoped() in max77705_add_led() Manush Prajwal
2026-08-28  9:25 ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®