backlight: pwm_bl: Re-add driver internal enabled tracking
authorHeiko Stuebner <heiko@sntech.de>
Fri, 9 Nov 2018 09:48:57 +0000 (10:48 +0100)
committerLee Jones <lee.jones@linaro.org>
Tue, 27 Nov 2018 12:10:51 +0000 (12:10 +0000)
commite4c8ae3e3d6d473bfbfbb5db234792b9f8ddab3b
treee4174f69235037d15ff9529599d884c1b2d692cc
parent651022382c7f8da46cb4872a545ee1da6d097d2a
backlight: pwm_bl: Re-add driver internal enabled tracking

Commit e6bcca0890b9 ("backlight: pwm_bl: Switch to using "atomic" PWM API")
removed the driver internal enabled tracking in favor of simply checking
the pwm state.

This can lead to issues as all of gpio-, regulator- and pwm-state are used
to determine the initial state and the bootloader or kernel can leave them
in an inconsistent state at boot.

In my case on rk3399-kevin, the pwm backlight is build as module and the
kernel disables the supply regulator as unused while keeping the pwm running
thus pwm_bl calling pwm_backlight_power_off() during probe and creating an
unmatched regulator-disable call, as it never got enabled from the pwm-bl
before.

To prevent these consistency issues, reintroduce the driver-internal
tracking of the enabled state.

Fixes: e6bcca0890b9 ("backlight: pwm_bl: Switch to using "atomic" PWM API")
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Acked-by: Thierry Reding <thierry.reding@gmail.com>
Acked-by: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
drivers/video/backlight/pwm_bl.c