diff options
| author | Jon Hunter <[email protected]> | 2022-10-28 12:33:55 +0000 |
|---|---|---|
| committer | Thierry Reding <[email protected]> | 2022-11-09 17:30:52 +0000 |
| commit | f271946117dde2ca8741b8138b347b2d68e6ad56 (patch) | |
| tree | d0c3269fc8dfc57ff93f8531e6767720721ada8e /drivers/pwm/pwm-stm32.c | |
| parent | Linux 6.1-rc1 (diff) | |
| download | kernel-f271946117dde2ca8741b8138b347b2d68e6ad56.tar.gz kernel-f271946117dde2ca8741b8138b347b2d68e6ad56.zip | |
pwm: tegra: Improve required rate calculation
For the case where dev_pm_opp_set_rate() is called to set the PWM clock
rate, the requested rate is calculated as ...
required_clk_rate = (NSEC_PER_SEC / period_ns) << PWM_DUTY_WIDTH;
The above calculation may lead to rounding errors because the
NSEC_PER_SEC is divided by 'period_ns' before applying the
PWM_DUTY_WIDTH multiplication factor. For example, if the period is
45334ns, the above calculation yields a rate of 5646848Hz instead of
5646976Hz. Fix this by applying the multiplication factor before
dividing and using the DIV_ROUND_UP macro which yields the expected
result of 5646976Hz.
Fixes: 1d7796bdb63a ("pwm: tegra: Support dynamic clock frequency configuration")
Signed-off-by: Jon Hunter <[email protected]>
Reviewed-by: Uwe Kleine-König <[email protected]>
Signed-off-by: Thierry Reding <[email protected]>
Diffstat (limited to 'drivers/pwm/pwm-stm32.c')
0 files changed, 0 insertions, 0 deletions
