Skip to content

Commit 29df702

Browse files
Jakob Rieplerlag-linaro
authored andcommitted
leds: pwm-multicolor: Disable PWM when going to suspend
This fixes suspend on platforms like stm32mp1xx, where the PWM consumer has to be disabled for the PWM to enter suspend. Another positive side effect is that active-low LEDs now properly turn off instead of going back to full brightness when they are set to 0. Link: https://lore.kernel.org/all/20240417153846.271751-2-u.kleine-koenig@pengutronix.de/ Signed-off-by: Jakob Riepler <jakob+lkml@paranoidlabs.org> Acked-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> Link: https://lore.kernel.org/r/20241216213754.18374-2-jakob+lkml@paranoidlabs.org Signed-off-by: Lee Jones <lee@kernel.org>
1 parent 0508316 commit 29df702

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/leds/rgb/leds-pwm-multicolor.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,13 @@ static int led_pwm_mc_set(struct led_classdev *cdev,
5050
duty = priv->leds[i].state.period - duty;
5151

5252
priv->leds[i].state.duty_cycle = duty;
53-
priv->leds[i].state.enabled = duty > 0;
53+
/*
54+
* Disabling a PWM doesn't guarantee that it emits the inactive level.
55+
* So keep it on. Only for suspending the PWM should be disabled because
56+
* otherwise it refuses to suspend. The possible downside is that the
57+
* LED might stay (or even go) on.
58+
*/
59+
priv->leds[i].state.enabled = !(cdev->flags & LED_SUSPENDED);
5460
ret = pwm_apply_might_sleep(priv->leds[i].pwm,
5561
&priv->leds[i].state);
5662
if (ret)

0 commit comments

Comments
 (0)