public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* drivers/clk/clk-eyeq.c:131 eqc_pll_downshift_factors() warn: always true condition '(*mult <= (~0)) => (0-u32max <= u32max)'
@ 2024-12-09  4:30 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2024-12-09  4:30 UTC (permalink / raw)
  To: Théo Lebrun; +Cc: oe-kbuild-all, linux-kernel, Stephen Boyd

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   7503345ac5f5e82fd9a36d6e6b447c016376403a
commit: 25d904946a0baf08b16204d95dc3624096d99c38 clk: eyeq: add driver
date:   6 weeks ago
config: nios2-randconfig-r073-20241206 (https://download.01.org/0day-ci/archive/20241208/202412080533.Inh1JBwa-lkp@intel.com/config)
compiler: nios2-linux-gcc (GCC) 14.2.0

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
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202412080533.Inh1JBwa-lkp@intel.com/

smatch warnings:
drivers/clk/clk-eyeq.c:131 eqc_pll_downshift_factors() warn: always true condition '(*mult <= (~0)) => (0-u32max <= u32max)'
drivers/clk/clk-eyeq.c:131 eqc_pll_downshift_factors() warn: always true condition '(*div <= (~0)) => (0-u32max <= u32max)'
drivers/clk/clk-eyeq.c:374 eqc_probe() warn: 'base' from ioremap() not released on lines: 358.

vim +131 drivers/clk/clk-eyeq.c

   112	
   113	/*
   114	 * Both factors (mult and div) must fit in 32 bits. When an operation overflows,
   115	 * this function throws away low bits so that factors still fit in 32 bits.
   116	 *
   117	 * Precision loss depends on amplitude of mult and div. Worst theorical
   118	 * loss is: (UINT_MAX+1) / UINT_MAX - 1 = 2.3e-10.
   119	 * This is 1Hz every 4.3GHz.
   120	 */
   121	static void eqc_pll_downshift_factors(unsigned long *mult, unsigned long *div)
   122	{
   123		unsigned long biggest;
   124		unsigned int shift;
   125	
   126		/* This function can be removed if mult/div switch to unsigned long. */
   127		static_assert(sizeof_field(struct clk_fixed_factor, mult) == sizeof(unsigned int));
   128		static_assert(sizeof_field(struct clk_fixed_factor, div) == sizeof(unsigned int));
   129	
   130		/* No overflow, nothing to be done. */
 > 131		if (*mult <= UINT_MAX && *div <= UINT_MAX)
   132			return;
   133	
   134		/*
   135		 * Compute the shift required to bring the biggest factor into unsigned
   136		 * int range. That is, shift its highest set bit to the unsigned int
   137		 * most significant bit.
   138		 */
   139		biggest = max(*mult, *div);
   140		shift = __fls(biggest) - (BITS_PER_BYTE * sizeof(unsigned int)) + 1;
   141	
   142		*mult >>= shift;
   143		*div >>= shift;
   144	}
   145	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-12-09  4:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-09  4:30 drivers/clk/clk-eyeq.c:131 eqc_pll_downshift_factors() warn: always true condition '(*mult <= (~0)) => (0-u32max <= u32max)' kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox