]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
leds: leds-lp50xx: Allow LED 0 to be added to module bank
authorChristian Hitz <christian.hitz@bbv.ch>
Wed, 8 Oct 2025 12:32:21 +0000 (14:32 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 19 Jan 2026 12:10:00 +0000 (13:10 +0100)
commit 26fe74d598c32e7bc6f150edfc4aa43e1bee55db upstream.

led_banks contains LED module number(s) that should be grouped into the
module bank. led_banks is 0-initialized.
By checking the led_banks entries for 0, un-set entries are detected.
But a 0-entry also indicates that LED module 0 should be grouped into the
module bank.

By only iterating over the available entries no check for unused entries
is required and LED module 0 can be added to bank.

Cc: stable@vger.kernel.org
Fixes: 242b81170fb8 ("leds: lp50xx: Add the LP50XX family of the RGB LED driver")
Signed-off-by: Christian Hitz <christian.hitz@bbv.ch>
Reviewed-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Link: https://patch.msgid.link/20251008123222.1117331-1-christian@klarinett.li
Signed-off-by: Lee Jones <lee@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/leds/leds-lp50xx.c

index a2748e46745149e3f2fa9e81676e975d06891104..c31f3694937d97c33bb693c5d49645bbdb0d7703 100644 (file)
@@ -347,17 +347,15 @@ out:
        return ret;
 }
 
-static int lp50xx_set_banks(struct lp50xx *priv, u32 led_banks[])
+static int lp50xx_set_banks(struct lp50xx *priv, u32 led_banks[], int num_leds)
 {
        u8 led_config_lo, led_config_hi;
        u32 bank_enable_mask = 0;
        int ret;
        int i;
 
-       for (i = 0; i < priv->chip_info->max_modules; i++) {
-               if (led_banks[i])
-                       bank_enable_mask |= (1 << led_banks[i]);
-       }
+       for (i = 0; i < num_leds; i++)
+               bank_enable_mask |= (1 << led_banks[i]);
 
        led_config_lo = bank_enable_mask;
        led_config_hi = bank_enable_mask >> 8;
@@ -413,7 +411,7 @@ static int lp50xx_probe_leds(struct fwnode_handle *child, struct lp50xx *priv,
                        return ret;
                }
 
-               ret = lp50xx_set_banks(priv, led_banks);
+               ret = lp50xx_set_banks(priv, led_banks, num_leds);
                if (ret) {
                        dev_err(priv->dev, "Cannot setup banked LEDs\n");
                        return ret;