[PATCH v2 3/8] leds: pca995x: Fix maximum LED index for 16-channel variants
From: Nora Schiffer
Date: Tue Sep 15 2026 - 10:00:33 EST
The pca995x_chipdef for the 16-channel variants PCA9952 and PCA9955B
correctly sets num_leds to 16, but the value was not actually used when
checking and iterating over the LEDs during probe.
Fixes: 68d6520d2e76 ("leds: leds-pca995x: Add support for NXP PCA9956B")
Link: https://sashiko.dev/#/patchset/6d3600f99c77c31166f0b6a5ccfb7f518b53c4c9.1788350618.git.nora.schiffer@xxxxxxxxxxxxxxx
Signed-off-by: Nora Schiffer <nora.schiffer@xxxxxxxxxxxxxxx>
---
v2: new patch
drivers/leds/leds-pca995x.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/leds/leds-pca995x.c b/drivers/leds/leds-pca995x.c
index fee6216cd1bd0..8b05b3f12cf38 100644
--- a/drivers/leds/leds-pca995x.c
+++ b/drivers/leds/leds-pca995x.c
@@ -146,7 +146,7 @@ static int pca995x_probe(struct i2c_client *client)
if (ret)
return ret;
- if (reg < 0 || reg >= PCA995X_MAX_OUTPUTS || led_fwnodes[reg])
+ if (reg < 0 || reg >= chipdef->num_leds || led_fwnodes[reg])
return -EINVAL;
led = &chip->leds[reg];
@@ -157,7 +157,7 @@ static int pca995x_probe(struct i2c_client *client)
led->ldev.max_brightness = 255;
}
- for (i = 0; i < PCA995X_MAX_OUTPUTS; i++) {
+ for (i = 0; i < chipdef->num_leds; i++) {
struct led_init_data init_data = {};
if (!led_fwnodes[i])
@@ -169,7 +169,7 @@ static int pca995x_probe(struct i2c_client *client)
&chip->leds[i].ldev,
&init_data);
if (ret < 0) {
- for (j = i; j < PCA995X_MAX_OUTPUTS; j++)
+ for (j = i; j < chipdef->num_leds; j++)
fwnode_handle_put(led_fwnodes[j]);
return dev_err_probe(dev, ret,
"Could not register LED %s\n",
--
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
https://www.tq-group.com/