linux/drivers/pwm
Uwe Kleine-König bb72e1dbae pwm: keembay: Fix build failure with -Os
The driver used this construct:

	#define KMB_PWM_LEADIN_MASK             GENMASK(30, 0)

	static inline void keembay_pwm_update_bits(struct keembay_pwm *priv, u32 mask,
						   u32 val, u32 offset)
	{
		u32 buff = readl(priv->base + offset);

		buff = u32_replace_bits(buff, val, mask);
		writel(buff, priv->base + offset);
	}

	...
	keembay_pwm_update_bits(priv, KMB_PWM_LEADIN_MASK, 0,
					KMB_PWM_LEADIN_OFFSET(pwm->hwpwm));

With CONFIG_CC_OPTIMIZE_FOR_SIZE the compiler (here: gcc 10.2.0) this
triggers:

	In file included from /home/uwe/gsrc/linux/drivers/pwm/pwm-keembay.c:16:
	In function ‘field_multiplier’,
	    inlined from ‘keembay_pwm_update_bits’ at /home/uwe/gsrc/linux/include/linux/bitfield.h:124:17:
	/home/uwe/gsrc/linux/include/linux/bitfield.h:119:3: error: call to ‘__bad_mask’ declared with attribute error: bad bitfield mask
	  119 |   __bad_mask();
	      |   ^~~~~~~~~~~~
	In function ‘field_multiplier’,
	    inlined from ‘keembay_pwm_update_bits’ at /home/uwe/gsrc/linux/include/linux/bitfield.h:154:1:
	/home/uwe/gsrc/linux/include/linux/bitfield.h:119:3: error: call to ‘__bad_mask’ declared with attribute error: bad bitfield mask
	  119 |   __bad_mask();
	      |   ^~~~~~~~~~~~

The compiler doesn't seem to be able to notice that with field being
0x3ffffff the expression

	if ((field | (field - 1)) & ((field | (field - 1)) + 1))
		__bad_mask();

can be optimized away.

So use __always_inline and document the problem in a comment to fix
this.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Tested-by: Vijayakannan Ayyathurai <vijayakannan.ayyathurai@intel.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-12-17 14:19:00 +01:00
..
core.c pwm: core: Use octal permission 2020-12-17 14:19:00 +01:00
Kconfig pwm: lpss: Make compilable with COMPILE_TEST 2020-12-17 14:19:00 +01:00
Makefile pwm: Add PWM fan controller driver for LGM SoC 2020-12-17 14:18:59 +01:00
pwm-ab8500.c pwm: ab8500: Explicitly allocate pwm chip base dynamically 2020-12-17 14:18:48 +01:00
pwm-atmel-hlcdc.c pwm: Ensure pwm_apply_state() doesn't modify the state argument 2019-09-21 03:25:10 +02:00
pwm-atmel-tcb.c pwm: atmel-tcb: Add sama5d2 support 2020-12-17 14:18:55 +01:00
pwm-atmel.c pwm: atmel: Convert to devm_platform_ioremap_resource() 2020-12-17 14:18:46 +01:00
pwm-bcm2835.c pwm: bcm2835: Convert to devm_platform_ioremap_resource() 2020-12-17 14:18:44 +01:00
pwm-bcm-iproc.c pwm: bcm-iproc: Convert to devm_platform_ioremap_resource() 2020-12-17 14:18:42 +01:00
pwm-bcm-kona.c pwm: bcm-kona: Convert to devm_platform_ioremap_resource() 2020-12-17 14:18:41 +01:00
pwm-berlin.c pwm: berlin: Convert to devm_platform_ioremap_resource() 2020-12-17 14:18:44 +01:00
pwm-brcmstb.c pwm: brcmstb: Convert to devm_platform_ioremap_resource() 2020-12-17 14:18:44 +01:00
pwm-clps711x.c pwm: clps711x: Convert to devm_platform_ioremap_resource() 2020-12-17 14:18:45 +01:00
pwm-crc.c pwm: Use -EINVAL for unsupported polarity 2020-12-17 14:18:59 +01:00
pwm-cros-ec.c pwm: cros-ec: Simplify EC error handling 2020-08-24 11:37:34 +02:00
pwm-dwc.c pwm: Add DesignWare PWM Controller Driver 2020-12-17 14:18:58 +01:00
pwm-ep93xx.c pwm: ep93xx: Convert to devm_platform_ioremap_resource() 2020-12-17 14:18:39 +01:00
pwm-fsl-ftm.c pwm: fsl-ftm: Convert to devm_platform_ioremap_resource() 2020-12-17 14:18:38 +01:00
pwm-hibvt.c pwm: hibvt: Convert to devm_platform_ioremap_resource() 2020-12-17 14:18:46 +01:00
pwm-img.c pwm: img: Convert to devm_platform_ioremap_resource() 2020-12-17 14:18:45 +01:00
pwm-imx1.c pwm: imx1: Use dev_err_probe() to simplify error handling 2020-12-17 14:18:47 +01:00
pwm-imx27.c pwm: imx27: Use dev_err_probe() to simplify error handling 2020-12-17 14:18:47 +01:00
pwm-imx-tpm.c pwm: imx-tpm: Use dev_err_probe() to simplify error handling 2020-12-17 14:18:47 +01:00
pwm-intel-lgm.c pwm: Add PWM fan controller driver for LGM SoC 2020-12-17 14:18:59 +01:00
pwm-iqs620a.c pwm: Use -EINVAL for unsupported polarity 2020-12-17 14:18:59 +01:00
pwm-jz4740.c pwm: jz4740: Simplify with dev_err_probe() 2020-09-24 09:18:10 +02:00
pwm-keembay.c pwm: keembay: Fix build failure with -Os 2020-12-17 14:19:00 +01:00
pwm-lp3943.c pwm: lp3943: Dynamically allocate PWM chip base 2020-12-17 14:18:55 +01:00
pwm-lpc18xx-sct.c pwm: lpc18xx-sct: Convert to devm_platform_ioremap_resource() 2020-12-17 14:18:46 +01:00
pwm-lpc32xx.c pwm: lpc32xx: Convert to devm_platform_ioremap_resource() 2020-12-17 14:18:42 +01:00
pwm-lpss-pci.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
pwm-lpss-platform.c pwm: lpss: Set DPM_FLAG_SMART_SUSPEND on Cherry Trail devices 2020-12-17 14:18:49 +01:00
pwm-lpss.c pwm: lpss: Log error from pwm_lpss_is_updating() if the update bit is still set 2020-12-17 14:18:48 +01:00
pwm-lpss.h pwm: lpss: Remove suspend/resume handlers 2020-09-06 15:38:01 +02:00
pwm-mediatek.c pwm: mediatek: Add MT8183 SoC support 2020-12-17 14:18:58 +01:00
pwm-meson.c pwm: meson: Convert to devm_platform_ioremap_resource() 2020-12-17 14:18:42 +01:00
pwm-mtk-disp.c pwm: mtk-disp: Convert to devm_platform_ioremap_resource() 2020-12-17 14:18:44 +01:00
pwm-mxs.c pwm: mxs: Remove unused include of of_address.h 2020-03-30 16:55:27 +02:00
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: pxa: Convert to devm_platform_ioremap_resource() 2020-12-17 14:18:40 +01:00
pwm-rcar.c pwm: Use -EINVAL for unsupported polarity 2020-12-17 14:18:59 +01:00
pwm-renesas-tpu.c pwm: renesas-tpu: Convert to devm_platform_ioremap_resource() 2020-12-17 14:18:38 +01:00
pwm-rockchip.c pwm: rockchip: Convert to devm_platform_ioremap_resource() 2020-12-17 14:18:42 +01:00
pwm-samsung.c pwm: samsung: Convert to devm_platform_ioremap_resource() 2020-12-17 14:18:43 +01:00
pwm-sifive.c pwm: sifive: Convert to devm_platform_ioremap_resource() 2020-12-17 14:18:46 +01:00
pwm-sl28cpld.c pwm: Add support for sl28cpld PWM controller 2020-09-17 15:59:34 +01:00
pwm-spear.c pwm: spear: Convert to devm_platform_ioremap_resource() 2020-12-17 14:18:41 +01:00
pwm-sprd.c pwm: sprd: Simplify with dev_err_probe() 2020-09-24 09:18:11 +02:00
pwm-sti.c pwm: sti: Remove unnecessary blank line 2020-12-17 14:18:59 +01:00
pwm-stm32-lp.c pwm: Convert period and duty cycle to u64 2020-06-17 20:42:11 +02:00
pwm-stm32.c pwm: stm32: Remove automatic output enable 2020-01-20 13:47:36 +01:00
pwm-stmpe.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
pwm-sun4i.c pwm: sun4i: Convert to devm_platform_ioremap_resource() 2020-12-17 14:18:37 +01:00
pwm-tegra.c pwm: tegra: Convert to devm_platform_ioremap_resource() 2020-12-17 14:18:39 +01:00
pwm-tiecap.c pwm: tiecap: Convert to devm_platform_ioremap_resource() 2020-12-17 14:18:44 +01:00
pwm-tiehrpwm.c pwm: tiehrpwm: Handle deferred probe with dev_err_probe() 2020-12-17 14:18:49 +01:00
pwm-twl-led.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 234 2019-06-19 17:09:07 +02:00
pwm-twl.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 234 2019-06-19 17:09:07 +02:00
pwm-vt8500.c pwm: vt8500: Convert to devm_platform_ioremap_resource() 2020-12-17 14:18:44 +01:00
pwm-zx.c pwm: zx: Add missing cleanup in error path 2020-12-17 14:18:48 +01:00
sysfs.c pwm: Allow store 64-bit duty cycle from sysfs interface 2020-09-24 09:18:14 +02:00