public inbox for linux-leds@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] leds: pwm: clear the led structure before parsing each child node
@ 2022-12-20  7:33 Hui Wang
  2023-01-04 18:15 ` Lee Jones
  0 siblings, 1 reply; 2+ messages in thread
From: Hui Wang @ 2022-12-20  7:33 UTC (permalink / raw)
  To: linux-leds, pavel; +Cc: hui.wang

I defined 2 leds in the device tree, in the 1st led node, the
max-brightness is set to 248, while in the 2nd led node, I
mis-spelled the max-brightness to max-brighttness, but the driver
is still able to get the max-brightness 248 for the 2nd node,  that
is because the led structure is not cleared before parsing each child
node.

	pwmleds {
		compatible = "pwm-leds";

		pwm-green {
			...
			max-brightness = <248>;
		};

		pwm-red {
		        ...
			max-brighttness = <128>;
		};

Signed-off-by: Hui Wang <hui.wang@canonical.com>
---
 drivers/leds/leds-pwm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
index 6832180c1c54..29194cc382af 100644
--- a/drivers/leds/leds-pwm.c
+++ b/drivers/leds/leds-pwm.c
@@ -138,9 +138,9 @@ static int led_pwm_create_fwnode(struct device *dev, struct led_pwm_priv *priv)
 	struct led_pwm led;
 	int ret;
 
-	memset(&led, 0, sizeof(led));
-
 	device_for_each_child_node(dev, fwnode) {
+		memset(&led, 0, sizeof(led));
+
 		ret = fwnode_property_read_string(fwnode, "label", &led.name);
 		if (ret && is_of_node(fwnode))
 			led.name = to_of_node(fwnode)->name;
-- 
2.34.1


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

* Re: [PATCH] leds: pwm: clear the led structure before parsing each child node
  2022-12-20  7:33 [PATCH] leds: pwm: clear the led structure before parsing each child node Hui Wang
@ 2023-01-04 18:15 ` Lee Jones
  0 siblings, 0 replies; 2+ messages in thread
From: Lee Jones @ 2023-01-04 18:15 UTC (permalink / raw)
  To: Hui Wang; +Cc: linux-leds, pavel

On Tue, 20 Dec 2022, Hui Wang wrote:

> I defined 2 leds in the device tree, in the 1st led node, the
> max-brightness is set to 248, while in the 2nd led node, I
> mis-spelled the max-brightness to max-brighttness, but the driver
> is still able to get the max-brightness 248 for the 2nd node,  that
> is because the led structure is not cleared before parsing each child
> node.
> 
> 	pwmleds {
> 		compatible = "pwm-leds";
> 
> 		pwm-green {
> 			...
> 			max-brightness = <248>;
> 		};
> 
> 		pwm-red {
> 		        ...
> 			max-brighttness = <128>;
> 		};
> 
> Signed-off-by: Hui Wang <hui.wang@canonical.com>
> ---
>  drivers/leds/leds-pwm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Applied, thanks

-- 
Lee Jones [李琼斯]

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

end of thread, other threads:[~2023-01-04 18:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-20  7:33 [PATCH] leds: pwm: clear the led structure before parsing each child node Hui Wang
2023-01-04 18:15 ` Lee Jones

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