drivers/iio/adc/meson_saradc.c:371:14: note: in expansion of macro 'GENMASK'

From: kernel test robot
Date: Mon Jun 22 2020 - 05:38:25 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 625d3449788f85569096780592549d0340e9c0c7
commit: 295bcca84916cb5079140a89fccb472bb8d1f6e2 linux/bits.h: add compile time sanity check of GENMASK inputs
date: 3 months ago
config: i386-randconfig-r012-20200622 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-13) 9.3.0
reproduce (this is a W=1 build):
git checkout 295bcca84916cb5079140a89fccb472bb8d1f6e2
# save the attached .config to linux build tree
make W=1 ARCH=i386

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>, old ones prefixed by <<):

In file included from include/linux/bitfield.h:10,
from drivers/iio/adc/meson_saradc.c:8:
drivers/iio/adc/meson_saradc.c: In function 'meson_sar_adc_read_raw_sample':
include/linux/bits.h:26:28: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
26 | __builtin_constant_p((l) > (h)), (l) > (h), 0)))
| ^
include/linux/build_bug.h:16:62: note: in definition of macro 'BUILD_BUG_ON_ZERO'
16 | #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); })))
| ^
include/linux/bits.h:39:3: note: in expansion of macro 'GENMASK_INPUT_CHECK'
39 | (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l))
| ^~~~~~~~~~~~~~~~~~~
>> drivers/iio/adc/meson_saradc.c:371:14: note: in expansion of macro 'GENMASK'
371 | fifo_val &= GENMASK(priv->param->resolution - 1, 0);
| ^~~~~~~
include/linux/bits.h:26:40: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
26 | __builtin_constant_p((l) > (h)), (l) > (h), 0)))
| ^
include/linux/build_bug.h:16:62: note: in definition of macro 'BUILD_BUG_ON_ZERO'
16 | #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); })))
| ^
include/linux/bits.h:39:3: note: in expansion of macro 'GENMASK_INPUT_CHECK'
39 | (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l))
| ^~~~~~~~~~~~~~~~~~~
>> drivers/iio/adc/meson_saradc.c:371:14: note: in expansion of macro 'GENMASK'
371 | fifo_val &= GENMASK(priv->param->resolution - 1, 0);
| ^~~~~~~

vim +/GENMASK +371 drivers/iio/adc/meson_saradc.c

3adbf34273306f Martin Blumenstingl 2017-01-22 342
3adbf34273306f Martin Blumenstingl 2017-01-22 343 static int meson_sar_adc_read_raw_sample(struct iio_dev *indio_dev,
3adbf34273306f Martin Blumenstingl 2017-01-22 344 const struct iio_chan_spec *chan,
3adbf34273306f Martin Blumenstingl 2017-01-22 345 int *val)
3adbf34273306f Martin Blumenstingl 2017-01-22 346 {
3adbf34273306f Martin Blumenstingl 2017-01-22 347 struct meson_sar_adc_priv *priv = iio_priv(indio_dev);
6a882a2cbeb09b Heiner Kallweit 2017-02-15 348 int regval, fifo_chan, fifo_val, count;
3adbf34273306f Martin Blumenstingl 2017-01-22 349
3af109131b7eb8 Heiner Kallweit 2017-02-15 350 if(!wait_for_completion_timeout(&priv->done,
3af109131b7eb8 Heiner Kallweit 2017-02-15 351 msecs_to_jiffies(MESON_SAR_ADC_TIMEOUT)))
3af109131b7eb8 Heiner Kallweit 2017-02-15 352 return -ETIMEDOUT;
3adbf34273306f Martin Blumenstingl 2017-01-22 353
6a882a2cbeb09b Heiner Kallweit 2017-02-15 354 count = meson_sar_adc_get_fifo_count(indio_dev);
6a882a2cbeb09b Heiner Kallweit 2017-02-15 355 if (count != 1) {
6a882a2cbeb09b Heiner Kallweit 2017-02-15 356 dev_err(&indio_dev->dev,
6a882a2cbeb09b Heiner Kallweit 2017-02-15 357 "ADC FIFO has %d element(s) instead of one\n", count);
6a882a2cbeb09b Heiner Kallweit 2017-02-15 358 return -EINVAL;
3adbf34273306f Martin Blumenstingl 2017-01-22 359 }
3adbf34273306f Martin Blumenstingl 2017-01-22 360
6a882a2cbeb09b Heiner Kallweit 2017-02-15 361 regmap_read(priv->regmap, MESON_SAR_ADC_FIFO_RD, &regval);
6a882a2cbeb09b Heiner Kallweit 2017-02-15 362 fifo_chan = FIELD_GET(MESON_SAR_ADC_FIFO_RD_CHAN_ID_MASK, regval);
827df0571fb32d Martin Blumenstingl 2018-09-25 363 if (fifo_chan != chan->address) {
6a882a2cbeb09b Heiner Kallweit 2017-02-15 364 dev_err(&indio_dev->dev,
827df0571fb32d Martin Blumenstingl 2018-09-25 365 "ADC FIFO entry belongs to channel %d instead of %lu\n",
827df0571fb32d Martin Blumenstingl 2018-09-25 366 fifo_chan, chan->address);
6a882a2cbeb09b Heiner Kallweit 2017-02-15 367 return -EINVAL;
6a882a2cbeb09b Heiner Kallweit 2017-02-15 368 }
3adbf34273306f Martin Blumenstingl 2017-01-22 369
6a882a2cbeb09b Heiner Kallweit 2017-02-15 370 fifo_val = FIELD_GET(MESON_SAR_ADC_FIFO_RD_SAMPLE_VALUE_MASK, regval);
057e5a1109faa0 Martin Blumenstingl 2018-09-23 @371 fifo_val &= GENMASK(priv->param->resolution - 1, 0);
48ba7c3c0b3736 Heiner Kallweit 2017-03-18 372 *val = meson_sar_adc_calib_val(indio_dev, fifo_val);
3adbf34273306f Martin Blumenstingl 2017-01-22 373
3adbf34273306f Martin Blumenstingl 2017-01-22 374 return 0;
3adbf34273306f Martin Blumenstingl 2017-01-22 375 }
3adbf34273306f Martin Blumenstingl 2017-01-22 376

:::::: The code at line 371 was first introduced by commit
:::::: 057e5a1109faa01091a989c224833e2df6003b2e iio: adc: meson-saradc: simplify access to meson_sar_adc_param

:::::: TO: Martin Blumenstingl <martin.blumenstingl@xxxxxxxxxxxxxx>
:::::: CC: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip