pwm: stm32: Fix for settings using period > UINT32_MAX
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Sun, 17 Mar 2024 21:52:15 +0000 (22:52 +0100)
committerUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Tue, 30 Apr 2024 16:57:08 +0000 (18:57 +0200)
commitd44d635635a7192c773a75e674a8590a163e879e
treea6eb087428fc566755a92aad16d0451c425d4aca
parente419617847b688799a91126eb6c94b936bfb35ff
pwm: stm32: Fix for settings using period > UINT32_MAX

stm32_pwm_config() took the duty_cycle and period values with the type
int, however stm32_pwm_apply() passed u64 values there. Expand the
function parameters to u64 to not discard relevant bits and adapt the
calculations to the wider type.

To ensure the calculations won't overflow, check in .probe() the input
clk doesn't run faster than 1 GHz.

Link: https://lore.kernel.org/r/06b4a650a608d0887d934c1b2b8919e0f78e4db2.1710711976.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
drivers/pwm/pwm-stm32.c