linux-stable/drivers/pwm
Uwe Kleine-König e47685ec4c pwm: iqs620a: Fix overflow and optimize calculations
[ Upstream commit 72d6b2459d ]

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: 6f0841a819 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-03-04 11:38:17 +01:00
..
core.c pwm: Convert to use DEFINE_SEQ_ATTRIBUTE macro 2020-09-24 09:18:09 +02:00
Kconfig ARM: SoC platform updates 2020-10-24 10:33:08 -07:00
Makefile pwm: Add support for sl28cpld PWM controller 2020-09-17 15:59:34 +01:00
pwm-ab8500.c
pwm-atmel-hlcdc.c
pwm-atmel-tcb.c
pwm-atmel.c
pwm-bcm-iproc.c pwm: bcm-iproc: handle clk_get_rate() return 2020-07-30 11:27:13 +02:00
pwm-bcm-kona.c pwm: bcm-kona: Remove impossible comparison when validating duty cycle 2020-07-30 11:27:12 +02:00
pwm-bcm2835.c pwm: bcm2835: Simplify with dev_err_probe() 2020-09-24 09:18:10 +02:00
pwm-berlin.c
pwm-brcmstb.c
pwm-clps711x.c pwm: clps711x: Use 64-bit division macro 2020-06-16 11:16:08 +02:00
pwm-crc.c pwm: crc: Implement get_state() method 2020-09-06 15:38:05 +02:00
pwm-cros-ec.c pwm: cros-ec: Simplify EC error handling 2020-08-24 11:37:34 +02:00
pwm-ep93xx.c
pwm-fsl-ftm.c
pwm-hibvt.c
pwm-img.c pwm: img: Fix null pointer access in probe 2020-09-24 09:18:13 +02:00
pwm-imx-tpm.c pwm: imx-tpm: Use 64-bit division macro 2020-06-16 11:16:08 +02:00
pwm-imx1.c
pwm-imx27.c pwm: imx27: Fix overflow for bigger periods 2020-12-30 11:53:59 +01:00
pwm-iqs620a.c pwm: iqs620a: Fix overflow and optimize calculations 2021-03-04 11:38:17 +01:00
pwm-jz4740.c pwm: jz4740: Simplify with dev_err_probe() 2020-09-24 09:18:10 +02:00
pwm-lp3943.c pwm: lp3943: Dynamically allocate PWM chip base 2020-12-30 11:53:59 +01:00
pwm-lpc18xx-sct.c
pwm-lpc32xx.c
pwm-lpss-pci.c
pwm-lpss-platform.c pwm: lpss: Remove suspend/resume handlers 2020-09-06 15:38:01 +02:00
pwm-lpss.c pwm: lpss: Remove suspend/resume handlers 2020-09-06 15:38:01 +02:00
pwm-lpss.h pwm: lpss: Remove suspend/resume handlers 2020-09-06 15:38:01 +02:00
pwm-mediatek.c pwm: mediatek: Provide missing kerneldoc description for 'soc' arg 2020-07-30 11:27:12 +02:00
pwm-meson.c pwm: meson: Remove redundant assignment to variable fin_freq 2020-04-03 21:40:56 +02:00
pwm-mtk-disp.c
pwm-mxs.c
pwm-omap-dmtimer.c pwm: Replace HTTP links with HTTPS ones 2020-07-30 11:27:13 +02:00
pwm-pca9685.c pwm: pca9685: Disable unused alternative addresses 2020-09-24 09:18:13 +02:00
pwm-pxa.c
pwm-rcar.c
pwm-renesas-tpu.c
pwm-rockchip.c pwm: rockchip: Eliminate potential race condition when probing 2021-03-04 11:38:11 +01:00
pwm-samsung.c
pwm-sifive.c pwm: sifive: Simplify with dev_err_probe() 2020-09-24 09:18:11 +02:00
pwm-sl28cpld.c pwm: sl28cpld: fix getting driver data in pwm callbacks 2020-12-03 09:57:37 -08:00
pwm-spear.c
pwm-sprd.c pwm: sprd: Simplify with dev_err_probe() 2020-09-24 09:18:11 +02:00
pwm-sti.c
pwm-stm32-lp.c pwm: Convert period and duty cycle to u64 2020-06-17 20:42:11 +02:00
pwm-stm32.c
pwm-stmpe.c
pwm-sun4i.c pwm: sun4i: Remove erroneous else branch 2020-12-30 11:53:59 +01:00
pwm-tegra.c pwm: tegra: Support dynamic clock frequency configuration 2020-06-02 14:25:37 +02:00
pwm-tiecap.c pwm: Replace HTTP links with HTTPS ones 2020-07-30 11:27:13 +02:00
pwm-tiehrpwm.c pwm: Replace HTTP links with HTTPS ones 2020-07-30 11:27:13 +02:00
pwm-twl-led.c
pwm-twl.c
pwm-vt8500.c
pwm-zx.c pwm: zx: Add missing cleanup in error path 2020-12-30 11:53:58 +01:00
sysfs.c pwm: Allow store 64-bit duty cycle from sysfs interface 2020-09-24 09:18:14 +02:00