]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
pwm: tiehrpwm: Fix corner case in clock divisor calculation
authorUwe Kleine-König <u.kleine-koenig@baylibre.com>
Mon, 11 Aug 2025 16:01:02 +0000 (18:01 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 15 Oct 2025 09:56:28 +0000 (11:56 +0200)
commit0c13b417fe581d5ebd966961bb0d7c118b3fea30
treeaefd7565887e94738211f0240ca83f0a7e4aa82f
parentb12bec995024634152974a8dae437bea4fb6751c
pwm: tiehrpwm: Fix corner case in clock divisor calculation

[ Upstream commit 00f83f0e07e44e2f1fb94b223e77ab7b18ee2d7d ]

The function set_prescale_div() is responsible for calculating the clock
divisor settings such that the input clock rate is divided down such that
the required period length is at most 0x10000 clock ticks. If period_cycles
is an integer multiple of 0x10000, the divisor period_cycles / 0x10000 is
good enough. So round up in the calculation of the required divisor and
compare it using >= instead of >.

Fixes: 19891b20e7c2 ("pwm: pwm-tiehrpwm: PWM driver support for EHRPWM")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/85488616d7bfcd9c32717651d0be7e330e761b9c.1754927682.git.u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/pwm/pwm-tiehrpwm.c