drivers/pwm/pwm-stm32.c:818:14-15: WARNING opportunity for min()

kernel test robot <[email protected]>
Newsgroups dev.linux.lists.oe-kbuild
Message-ID <[email protected]>
BCC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Fabrice Gasnier <[email protected]>
CC: "Uwe Kleine-König" <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   0e35b9b6ec0ffcc5e23cbdec09f5c622ad532b53
commit: fd0b06972a8f92d57358e62267f5925721c73c6e pwm: stm32: add support for stm32mp25
date:   1 year ago
:::::: branch date: 3 days ago
:::::: commit date: 1 year ago
config: hexagon-randconfig-r051-20260709 (https://download.01.org/0day-ci/archive/20260710/[email protected]/config)
compiler: clang version 23.0.0git (https://github.com/llvm/llvm-project c279890c85da307abe34f10333442bbf72a60644)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Fixes: fd0b06972a8f ("pwm: stm32: add support for stm32mp25")
| Reported-by: kernel test robot <[email protected]>
| Reported-by: Julia Lawall <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

cocci warnings: (new ones prefixed by >>)
>> drivers/pwm/pwm-stm32.c:818:14-15: WARNING opportunity for min()

vim +818 drivers/pwm/pwm-stm32.c

7edf7369205baa1 Benjamin Gaignard 2017-01-20  795  
fd0b06972a8f92d Fabrice Gasnier   2025-01-10  796  static unsigned int stm32_pwm_detect_channels(struct stm32_timers *ddata,
19f1016ea9600ed Philipp Zabel     2023-10-19  797  					      unsigned int *num_enabled)
7edf7369205baa1 Benjamin Gaignard 2017-01-20  798  {
fd0b06972a8f92d Fabrice Gasnier   2025-01-10  799  	struct regmap *regmap = ddata->regmap;
19f1016ea9600ed Philipp Zabel     2023-10-19  800  	u32 ccer, ccer_backup;
7edf7369205baa1 Benjamin Gaignard 2017-01-20  801  
fd0b06972a8f92d Fabrice Gasnier   2025-01-10  802  	regmap_read(regmap, TIM_CCER, &ccer_backup);
fd0b06972a8f92d Fabrice Gasnier   2025-01-10  803  	*num_enabled = hweight32(ccer_backup & TIM_CCER_CCXE);
fd0b06972a8f92d Fabrice Gasnier   2025-01-10  804  
fd0b06972a8f92d Fabrice Gasnier   2025-01-10  805  	if (ddata->ipidr) {
fd0b06972a8f92d Fabrice Gasnier   2025-01-10  806  		u32 hwcfgr;
fd0b06972a8f92d Fabrice Gasnier   2025-01-10  807  		unsigned int npwm;
fd0b06972a8f92d Fabrice Gasnier   2025-01-10  808  
fd0b06972a8f92d Fabrice Gasnier   2025-01-10  809  		/* Deduce from HWCFGR the number of outputs (MP25). */
fd0b06972a8f92d Fabrice Gasnier   2025-01-10  810  		regmap_read(regmap, TIM_HWCFGR1, &hwcfgr);
fd0b06972a8f92d Fabrice Gasnier   2025-01-10  811  
fd0b06972a8f92d Fabrice Gasnier   2025-01-10  812  		/*
fd0b06972a8f92d Fabrice Gasnier   2025-01-10  813  		 * Timers may have more capture/compare channels than the
fd0b06972a8f92d Fabrice Gasnier   2025-01-10  814  		 * actual number of PWM channel outputs (e.g. TIM_CH[1..4]).
fd0b06972a8f92d Fabrice Gasnier   2025-01-10  815  		 */
fd0b06972a8f92d Fabrice Gasnier   2025-01-10  816  		npwm = FIELD_GET(TIM_HWCFGR1_NB_OF_CC, hwcfgr);
fd0b06972a8f92d Fabrice Gasnier   2025-01-10  817  
fd0b06972a8f92d Fabrice Gasnier   2025-01-10 @818  		return npwm < STM32_MAX_PWM_OUTPUT ? npwm : STM32_MAX_PWM_OUTPUT;
fd0b06972a8f92d Fabrice Gasnier   2025-01-10  819  	}
fd0b06972a8f92d Fabrice Gasnier   2025-01-10  820  
7edf7369205baa1 Benjamin Gaignard 2017-01-20  821  	/*
7edf7369205baa1 Benjamin Gaignard 2017-01-20  822  	 * If channels enable bits don't exist writing 1 will have no
7edf7369205baa1 Benjamin Gaignard 2017-01-20  823  	 * effect so we can detect and count them.
7edf7369205baa1 Benjamin Gaignard 2017-01-20  824  	 */
e315bf700b404c3 Uwe Kleine-König  2024-02-14  825  	regmap_set_bits(regmap, TIM_CCER, TIM_CCER_CCXE);
e315bf700b404c3 Uwe Kleine-König  2024-02-14  826  	regmap_read(regmap, TIM_CCER, &ccer);
e315bf700b404c3 Uwe Kleine-König  2024-02-14  827  	regmap_write(regmap, TIM_CCER, ccer_backup);
19f1016ea9600ed Philipp Zabel     2023-10-19  828  
41fa8f57c0d2692 Philipp Zabel     2023-10-19  829  	return hweight32(ccer & TIM_CCER_CCXE);
7edf7369205baa1 Benjamin Gaignard 2017-01-20  830  }
7edf7369205baa1 Benjamin Gaignard 2017-01-20  831  

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.