backlight: lp855x: Initialize PWM state on first brightness change
authorArtur Weber <aweber.kernel@gmail.com>
Fri, 14 Jul 2023 12:14:39 +0000 (14:14 +0200)
committerLee Jones <lee@kernel.org>
Fri, 28 Jul 2023 09:22:31 +0000 (10:22 +0100)
commit4c09e20b3c85f60353ace21092e34f35f5e3ab00
tree038f21e2e8b49e9292fc496ba5ec3a51bb17d777
parent1bb5187b673208f7191f227249ffe7401e969b97
backlight: lp855x: Initialize PWM state on first brightness change

As pointed out by Uwe Kleine-König[1], the changes introduced in
commit c1ff7da03e16 ("video: backlight: lp855x: Get PWM for PWM mode
during probe") caused the PWM state set up by the bootloader to be
re-set when the driver is probed. This differs from the behavior from
before that patch, where the PWM state would be initialized on the
first brightness change.

Fix this by moving the PWM state initialization into the PWM control
function. Add a new variable, needs_pwm_init, to the device info struct
to allow us to check whether we need the initialization, or whether it
has already been done.

[1] https://lore.kernel.org/lkml/20230614083953.e4kkweddjz7wztby@pengutronix.de/

Fixes: c1ff7da03e16 ("video: backlight: lp855x: Get PWM for PWM mode during probe")
Signed-off-by: Artur Weber <aweber.kernel@gmail.com>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Link: https://lore.kernel.org/r/20230714121440.7717-2-aweber.kernel@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/video/backlight/lp855x_bl.c