[PATCH 19/21] leds: is31fl32xx: Clamp channel current limit in is31fl3293_reset()

From: Lee Jones

Date: Wed Oct 21 2026 - 08:48:19 EST


is31fl3293_reset() uses max() instead of min() when comparing
led_data->max_microamp against IS31FL3293_MAX_MICROAMP, ignoring any
lower led-max-microamp limit configured in the Device Tree and
overflowing the 8-bit current level register if a larger value is
provided.

Clamp led_data->max_microamp to IS31FL3293_MAX_MICROAMP when specified,
falling back to IS31FL3293_MAX_MICROAMP when the optional property is
omitted.

Fixes: a18983b95a61 ("leds: is31f132xx: Add support for is31fl3293")
Closes: https://sashiko.dev/#/bug/linux-878f32ad-ca35-4759-a194-76fe03caee21
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
---
drivers/leds/leds-is31fl32xx.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/leds/leds-is31fl32xx.c b/drivers/leds/leds-is31fl32xx.c
index 285085d27453..aebedf8b2f4b 100644
--- a/drivers/leds/leds-is31fl32xx.c
+++ b/drivers/leds/leds-is31fl32xx.c
@@ -194,7 +194,8 @@ static int is31fl3293_reset(struct is31fl32xx_priv *priv)
for (i = 0; i < priv->num_leds; i++) {
struct is31fl32xx_led_data *led_data = &priv->leds[i];
int current_level_reg = IS31FL3293_CL_REG + led_data->channel - 1;
- int microamp = max(led_data->max_microamp, IS31FL3293_MAX_MICROAMP);
+ u32 microamp = min_not_zero(led_data->max_microamp,
+ IS31FL3293_MAX_MICROAMP);
int current_level = (microamp * 0xff) / IS31FL3293_MAX_MICROAMP;

ret = is31fl32xx_write(priv, current_level_reg, current_level);
--
2.56.0.218.g1ec904b173-goog