summaryrefslogtreecommitdiff
path: root/drivers/pwm/pwm-tiehrpwm.c
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2021-01-15 10:32:39 +0300
committerThierry Reding <thierry.reding@gmail.com>2021-02-22 17:18:36 +0300
commit72d6b2459dbd539c1369149e501fdc3dc8ddef16 (patch)
tree31546bd1adaf63df7e85f393ecf55b59468c7dee /drivers/pwm/pwm-tiehrpwm.c
parent11be938ae003c1cf157f0e80d5c9ad29a0f4c34c (diff)
downloadlinux-72d6b2459dbd539c1369149e501fdc3dc8ddef16.tar.xz
pwm: iqs620a: Fix overflow and optimize calculations
If state->duty_cycle is 0x100000000000000, the previous calculation of duty_scale overflows and yields a duty cycle ratio of 0% instead of 100%. Fix this by clamping the requested duty cycle to the maximal possible duty cycle first. This way it is possible to use a native integer division instead of a (depending on the architecture) more expensive 64bit division. With this change in place duty_scale cannot be bigger than 256 which allows to simplify the calculation of duty_val. Fixes: 6f0841a8197b ("pwm: Add support for Azoteq IQS620A PWM generator") Tested-by: Jeff LaBundy <jeff@labundy.com> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Diffstat (limited to 'drivers/pwm/pwm-tiehrpwm.c')
0 files changed, 0 insertions, 0 deletions