Skip to content

Commit 974afcc

Browse files
Uwe Kleine-Königlag-linaro
authored andcommitted
leds: pwm: Disable PWM when going to suspend
On stm32mp1xx based machines (and others) a PWM consumer has to disable the PWM because an enabled PWM refuses to suspend. So check the LED_SUSPENDED flag and depending on that set the .enabled property. Link: https://bugzilla.kernel.org/show_bug.cgi?id=218559 Fixes: 76fe464 ("leds: pwm: Don't disable the PWM when the LED should be off") Signed-off-by: Uwe Kleine-König <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent aa172ba commit 974afcc

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/leds/leds-pwm.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,13 @@ static int led_pwm_set(struct led_classdev *led_cdev,
5353
duty = led_dat->pwmstate.period - duty;
5454

5555
led_dat->pwmstate.duty_cycle = duty;
56-
led_dat->pwmstate.enabled = true;
56+
/*
57+
* Disabling a PWM doesn't guarantee that it emits the inactive level.
58+
* So keep it on. Only for suspending the PWM should be disabled because
59+
* otherwise it refuses to suspend. The possible downside is that the
60+
* LED might stay (or even go) on.
61+
*/
62+
led_dat->pwmstate.enabled = !(led_cdev->flags & LED_SUSPENDED);
5763
return pwm_apply_might_sleep(led_dat->pwm, &led_dat->pwmstate);
5864
}
5965

0 commit comments

Comments
 (0)