]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
leds: pca9532: Don't stop blinking for non-zero brightness
authorTobias Deiminger <tobias.deiminger@linutronix.de>
Tue, 31 Mar 2026 20:28:48 +0000 (22:28 +0200)
committerLee Jones <lee@kernel.org>
Wed, 17 Jun 2026 10:28:03 +0000 (11:28 +0100)
pca9532 unexpectedly stopped blinking when changing brightness to a
non-zero value. To reproduce:

 echo timer > /sys/class/leds/led-1/trigger   # blinks
 echo 255 > /sys/class/leds/led-1/brightness  # blinking stops, light on
 cat /sys/class/leds/led-1/trigger            # still claims [timer]

According to Documentation/leds/leds-class.rst, only brightness = 0
shall be a stop condition:

> You can change the brightness value of a LED independently of the
> timer trigger. However, if you set the brightness value to LED_OFF it
> will also disable the timer trigger.

Therefore add a guard to continue blinking when brightness != LED_OFF,
similar to how pca955x does it since 575f10dc64a2 ("leds: pca955x: Add
HW blink support").

Signed-off-by: Tobias Deiminger <tobias.deiminger@linutronix.de>
Link: https://patch.msgid.link/20260331202848.658676-1-tobias.deiminger@linutronix.de
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/leds/leds-pca9532.c

index 0344189bb991c8304524f6bdf495e133eb704d8e..dae7c67605084b4a77489930932cf2f7e9fb7600 100644 (file)
@@ -182,11 +182,13 @@ static int pca9532_set_brightness(struct led_classdev *led_cdev,
        int err = 0;
        struct pca9532_led *led = ldev_to_led(led_cdev);
 
-       if (value == LED_OFF)
+       if (value == LED_OFF) {
                led->state = PCA9532_OFF;
-       else if (value == LED_FULL)
+       } else if (led->state == PCA9532_PWM1) {
+               return 0; /* Non-zero brightness shall not stop HW blinking */
+       } else if (value == LED_FULL) {
                led->state = PCA9532_ON;
-       else {
+       else {
                led->state = PCA9532_PWM0; /* Thecus: hardcode one pwm */
                err = pca9532_calcpwm(led->client, PCA9532_PWM_ID_0, 0, value);
                if (err)