Skip to content

Commit 40da473

Browse files
Uwe Kleine-Königlag-linaro
authored andcommitted
backlight: pwm_bl: Disable PWM on shutdown, suspend and remove
Since commit 00e7e69 ("backlight: pwm_bl: Configure pwm only once per backlight toggle") calling pwm_backlight_power_off() doesn't disable the PWM any more. However this is necessary to suspend because PWM drivers usually refuse to suspend if they are still enabled. Also adapt shutdown and remove callbacks to disable the PWM for similar reasons. Fixes: 00e7e69 ("backlight: pwm_bl: Configure pwm only once per backlight toggle") Reported-by: Aisheng Dong <[email protected]> Tested-by: Aisheng Dong <[email protected]> Signed-off-by: Uwe Kleine-König <[email protected]> Reviewed-by: Daniel Thompson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]>
1 parent 02c4e66 commit 40da473

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

drivers/video/backlight/pwm_bl.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,9 +626,14 @@ static void pwm_backlight_remove(struct platform_device *pdev)
626626
{
627627
struct backlight_device *bl = platform_get_drvdata(pdev);
628628
struct pwm_bl_data *pb = bl_get_data(bl);
629+
struct pwm_state state;
629630

630631
backlight_device_unregister(bl);
631632
pwm_backlight_power_off(pb);
633+
pwm_get_state(pb->pwm, &state);
634+
state.duty_cycle = 0;
635+
state.enabled = false;
636+
pwm_apply_state(pb->pwm, &state);
632637

633638
if (pb->exit)
634639
pb->exit(&pdev->dev);
@@ -638,21 +643,38 @@ static void pwm_backlight_shutdown(struct platform_device *pdev)
638643
{
639644
struct backlight_device *bl = platform_get_drvdata(pdev);
640645
struct pwm_bl_data *pb = bl_get_data(bl);
646+
struct pwm_state state;
641647

642648
pwm_backlight_power_off(pb);
649+
pwm_get_state(pb->pwm, &state);
650+
state.duty_cycle = 0;
651+
state.enabled = false;
652+
pwm_apply_state(pb->pwm, &state);
643653
}
644654

645655
#ifdef CONFIG_PM_SLEEP
646656
static int pwm_backlight_suspend(struct device *dev)
647657
{
648658
struct backlight_device *bl = dev_get_drvdata(dev);
649659
struct pwm_bl_data *pb = bl_get_data(bl);
660+
struct pwm_state state;
650661

651662
if (pb->notify)
652663
pb->notify(pb->dev, 0);
653664

654665
pwm_backlight_power_off(pb);
655666

667+
/*
668+
* Note that disabling the PWM doesn't guarantee that the output stays
669+
* at its inactive state. However without the PWM disabled, the PWM
670+
* driver refuses to suspend. So disable here even though this might
671+
* enable the backlight on poorly designed boards.
672+
*/
673+
pwm_get_state(pb->pwm, &state);
674+
state.duty_cycle = 0;
675+
state.enabled = false;
676+
pwm_apply_state(pb->pwm, &state);
677+
656678
if (pb->notify_after)
657679
pb->notify_after(pb->dev, 0);
658680

0 commit comments

Comments
 (0)