Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

leds: leds-lp50xx: Allow LED 0 to be added to module bank

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>

authored by

Christian Hitz and committed by
Lee Jones
26fe74d5 7afd5335

+4 -6
+4 -6
drivers/leds/leds-lp50xx.c
··· 341 341 return ret; 342 342 } 343 343 344 - static int lp50xx_set_banks(struct lp50xx *priv, u32 led_banks[]) 344 + static int lp50xx_set_banks(struct lp50xx *priv, u32 led_banks[], int num_leds) 345 345 { 346 346 u8 led_config_lo, led_config_hi; 347 347 u32 bank_enable_mask = 0; 348 348 int ret; 349 349 int i; 350 350 351 - for (i = 0; i < priv->chip_info->max_modules; i++) { 352 - if (led_banks[i]) 353 - bank_enable_mask |= (1 << led_banks[i]); 354 - } 351 + for (i = 0; i < num_leds; i++) 352 + bank_enable_mask |= (1 << led_banks[i]); 355 353 356 354 led_config_lo = bank_enable_mask; 357 355 led_config_hi = bank_enable_mask >> 8; ··· 403 405 return ret; 404 406 } 405 407 406 - ret = lp50xx_set_banks(priv, led_banks); 408 + ret = lp50xx_set_banks(priv, led_banks, num_leds); 407 409 if (ret) { 408 410 dev_err(priv->dev, "Cannot setup banked LEDs\n"); 409 411 return ret;