All of lore.kernel.org
 help / color / mirror / Atom feed
* [jic23-iio:sparse-friendly-direct-mode 103/166] drivers/iio/adc/at91-sama5d2_adc.c:1879:6: warning: variable 'vtemp' is used uninitialized whenever 'if' condition is true
@ 2025-02-03  1:47 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2025-02-03  1:47 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: llvm, oe-kbuild-all

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git sparse-friendly-direct-mode
head:   bada9cd0235b288b74ee2bd65fd4223d71f62b02
commit: 3f20f57fed31f1e13f80158afd57f926a9efcdb0 [103/166] iio: adc: at91-sama5d2: Move claim of direct mode up a level and use guard()
config: x86_64-buildonly-randconfig-004-20250203 (https://download.01.org/0day-ci/archive/20250203/202502030940.8HsH3Cft-lkp@intel.com/config)
compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250203/202502030940.8HsH3Cft-lkp@intel.com/reproduce)

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/202502030940.8HsH3Cft-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/iio/adc/at91-sama5d2_adc.c:1879:6: warning: variable 'vtemp' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
    1879 |         if (ret < 0)
         |             ^~~~~~~
   drivers/iio/adc/at91-sama5d2_adc.c:1897:37: note: uninitialized use occurs here
    1897 |         div1 = DIV_ROUND_CLOSEST_ULL(((u64)vtemp * clb->p6), vbg);
         |                                            ^~~~~
   include/linux/math.h:104:29: note: expanded from macro 'DIV_ROUND_CLOSEST_ULL'
     104 |         unsigned long long _tmp = (x) + (__d) / 2;      \
         |                                    ^
   drivers/iio/adc/at91-sama5d2_adc.c:1879:2: note: remove the 'if' if its condition is always false
    1879 |         if (ret < 0)
         |         ^~~~~~~~~~~~
    1880 |                 goto restore_config;
         |                 ~~~~~~~~~~~~~~~~~~~
   drivers/iio/adc/at91-sama5d2_adc.c:1864:21: note: initialize the variable 'vtemp' to silence this warning
    1864 |         int ret, vbg, vtemp;
         |                            ^
         |                             = 0
   1 warning generated.


vim +1879 drivers/iio/adc/at91-sama5d2_adc.c

5ab38b81895c86 Claudiu Beznea   2022-08-03  1856  
5ab38b81895c86 Claudiu Beznea   2022-08-03  1857  static int at91_adc_read_temp(struct iio_dev *indio_dev,
5ab38b81895c86 Claudiu Beznea   2022-08-03  1858  			      struct iio_chan_spec const *chan, int *val)
5ab38b81895c86 Claudiu Beznea   2022-08-03  1859  {
5ab38b81895c86 Claudiu Beznea   2022-08-03  1860  	struct at91_adc_state *st = iio_priv(indio_dev);
5ab38b81895c86 Claudiu Beznea   2022-08-03  1861  	struct at91_adc_temp_sensor_clb *clb = &st->soc_info.temp_sensor_clb;
5ab38b81895c86 Claudiu Beznea   2022-08-03  1862  	u64 div1, div2;
5ab38b81895c86 Claudiu Beznea   2022-08-03  1863  	u32 tmp;
5ab38b81895c86 Claudiu Beznea   2022-08-03  1864  	int ret, vbg, vtemp;
5ab38b81895c86 Claudiu Beznea   2022-08-03  1865  
3f20f57fed31f1 Jonathan Cameron 2025-02-02  1866  	guard(mutex)(&st->lock);
5ab38b81895c86 Claudiu Beznea   2022-08-03  1867  
75d7556ac0e4bf Claudiu Beznea   2022-08-03  1868  	ret = pm_runtime_resume_and_get(st->dev);
75d7556ac0e4bf Claudiu Beznea   2022-08-03  1869  	if (ret < 0)
3f20f57fed31f1 Jonathan Cameron 2025-02-02  1870  		return ret;
75d7556ac0e4bf Claudiu Beznea   2022-08-03  1871  
5ab38b81895c86 Claudiu Beznea   2022-08-03  1872  	at91_adc_temp_sensor_configure(st, true);
5ab38b81895c86 Claudiu Beznea   2022-08-03  1873  
5ab38b81895c86 Claudiu Beznea   2022-08-03  1874  	/* Read VBG. */
5ab38b81895c86 Claudiu Beznea   2022-08-03  1875  	tmp = at91_adc_readl(st, ACR);
5ab38b81895c86 Claudiu Beznea   2022-08-03  1876  	tmp |= AT91_SAMA5D2_ACR_SRCLCH;
5ab38b81895c86 Claudiu Beznea   2022-08-03  1877  	at91_adc_writel(st, ACR, tmp);
5ab38b81895c86 Claudiu Beznea   2022-08-03  1878  	ret = at91_adc_read_info_raw(indio_dev, chan, &vbg);
5ab38b81895c86 Claudiu Beznea   2022-08-03 @1879  	if (ret < 0)
5ab38b81895c86 Claudiu Beznea   2022-08-03  1880  		goto restore_config;
5ab38b81895c86 Claudiu Beznea   2022-08-03  1881  
5ab38b81895c86 Claudiu Beznea   2022-08-03  1882  	/* Read VTEMP. */
5ab38b81895c86 Claudiu Beznea   2022-08-03  1883  	tmp &= ~AT91_SAMA5D2_ACR_SRCLCH;
5ab38b81895c86 Claudiu Beznea   2022-08-03  1884  	at91_adc_writel(st, ACR, tmp);
5ab38b81895c86 Claudiu Beznea   2022-08-03  1885  	ret = at91_adc_read_info_raw(indio_dev, chan, &vtemp);
5ab38b81895c86 Claudiu Beznea   2022-08-03  1886  
5ab38b81895c86 Claudiu Beznea   2022-08-03  1887  restore_config:
5ab38b81895c86 Claudiu Beznea   2022-08-03  1888  	/* Revert previous settings. */
5ab38b81895c86 Claudiu Beznea   2022-08-03  1889  	at91_adc_temp_sensor_configure(st, false);
75d7556ac0e4bf Claudiu Beznea   2022-08-03  1890  	pm_runtime_mark_last_busy(st->dev);
75d7556ac0e4bf Claudiu Beznea   2022-08-03  1891  	pm_runtime_put_autosuspend(st->dev);
5ab38b81895c86 Claudiu Beznea   2022-08-03  1892  
5ab38b81895c86 Claudiu Beznea   2022-08-03  1893  	/*
5ab38b81895c86 Claudiu Beznea   2022-08-03  1894  	 * Temp[milli] = p1[milli] + (vtemp * clb->p6 - clb->p4 * vbg)/
5ab38b81895c86 Claudiu Beznea   2022-08-03  1895  	 *			     (vbg * AT91_ADC_TS_VTEMP_DT)
5ab38b81895c86 Claudiu Beznea   2022-08-03  1896  	 */
5ab38b81895c86 Claudiu Beznea   2022-08-03  1897  	div1 = DIV_ROUND_CLOSEST_ULL(((u64)vtemp * clb->p6), vbg);
5ab38b81895c86 Claudiu Beznea   2022-08-03  1898  	div1 = DIV_ROUND_CLOSEST_ULL((div1 * 1000), AT91_ADC_TS_VTEMP_DT);
5ab38b81895c86 Claudiu Beznea   2022-08-03  1899  	div2 = DIV_ROUND_CLOSEST_ULL((u64)clb->p4, AT91_ADC_TS_VTEMP_DT);
5ab38b81895c86 Claudiu Beznea   2022-08-03  1900  	div2 *= 1000;
5ab38b81895c86 Claudiu Beznea   2022-08-03  1901  	*val = clb->p1 + (int)div1 - (int)div2;
5ab38b81895c86 Claudiu Beznea   2022-08-03  1902  
5ab38b81895c86 Claudiu Beznea   2022-08-03  1903  	return ret;
5ab38b81895c86 Claudiu Beznea   2022-08-03  1904  }
5ab38b81895c86 Claudiu Beznea   2022-08-03  1905  

:::::: The code at line 1879 was first introduced by commit
:::::: 5ab38b81895c869fb72eab5b528d5ef13a741c66 iio: adc: at91-sama5d2_adc: add support for temperature sensor

:::::: TO: Claudiu Beznea <claudiu.beznea@microchip.com>
:::::: CC: Jonathan Cameron <Jonathan.Cameron@huawei.com>

-- 
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:[~2025-02-03  1:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-03  1:47 [jic23-iio:sparse-friendly-direct-mode 103/166] drivers/iio/adc/at91-sama5d2_adc.c:1879:6: warning: variable 'vtemp' is used uninitialized whenever 'if' condition is true kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.