]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
leds: pwm: Clear the led structure before parsing each child node
authorHui Wang <hui.wang@canonical.com>
Tue, 20 Dec 2022 07:33:35 +0000 (15:33 +0800)
committerLee Jones <lee@kernel.org>
Mon, 30 Jan 2023 08:00:51 +0000 (08:00 +0000)
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>
Signed-off-by: Lee Jones <lee@kernel.org>
Link: https://lore.kernel.org/r/20221220073335.393489-1-hui.wang@canonical.com
drivers/leds/leds-pwm.c

index 6832180c1c54fd2cede277d38cfff1efa3d8f1e1..29194cc382afbc58315e9be435dc906d35fcf822 100644 (file)
@@ -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;