pwm: sun4i: Fix incorrect calculation of duty_cycle/period
authorOndrej Jirman <megous@megous.com>
Mon, 14 Oct 2019 13:53:03 +0000 (15:53 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 26 Jan 2020 09:01:04 +0000 (10:01 +0100)
commite70290bb1f8fa625b0e9a98fd78efd3ec51fabcb
tree86c1bc0c7e3c59b52c6415e47c5091f400a51892
parentaff509a3a127f0f059f2da9ddcbf477a74585664
pwm: sun4i: Fix incorrect calculation of duty_cycle/period

[ Upstream commit 50cc7e3e4f26e3bf5ed74a8d061195c4d2161b8b ]

Since 5.4-rc1, pwm_apply_state calls ->get_state after ->apply
if available, and this revealed an issue with integer precision
when calculating duty_cycle and period for the currently set
state in ->get_state callback.

This issue manifested in broken backlight on several Allwinner
based devices.

Previously this worked, because ->apply updated the passed state
directly.

Fixes: deb9c462f4e53 ("pwm: sun4i: Don't update the state for the caller of pwm_apply_state")
Signed-off-by: Ondrej Jirman <megous@megous.com>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/pwm/pwm-sun4i.c