Message ID | 20230922192834.1695727-1-u.kleine-koenig@pengutronix.de |
---|---|
State | New |
Headers | show |
Series | [v2] leds: pwm: Don't disable the PWM when the LED should be off | expand |
On Fri, 22 Sep 2023 21:28:34 +0200, Uwe Kleine-König wrote: > Disabling a PWM (i.e. calling pwm_apply_state with .enabled = false) > gives no guarantees what the PWM output does. It might freeze where it > currently is, or go in a High-Z state or drive the active or inactive > state, it might even continue to toggle. > > To ensure that the LED gets really disabled, don't disable the PWM even > when .duty_cycle is zero. > > [...] Applied, thanks! [1/1] leds: pwm: Don't disable the PWM when the LED should be off commit: 1025d4c1837eb457f9d599611096bf3a4d954333 -- Lee Jones [李琼斯]
diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c index 419b710984ab..2b3bf1353b70 100644 --- a/drivers/leds/leds-pwm.c +++ b/drivers/leds/leds-pwm.c @@ -53,7 +53,7 @@ static int led_pwm_set(struct led_classdev *led_cdev, duty = led_dat->pwmstate.period - duty; led_dat->pwmstate.duty_cycle = duty; - led_dat->pwmstate.enabled = duty > 0; + led_dat->pwmstate.enabled = true; return pwm_apply_state(led_dat->pwm, &led_dat->pwmstate); }