drivers/iio/adc/ad7949.c:286:3: error: call to '__compiletime_assert_579' declared with 'error' attribute: FIELD_PREP: value too large for the field

kernel test robot <[email protected]> Mon, 20 Jul 2026 03:37:08 +0800
Newsgroups dev.linux.lists.oe-kbuild
Message-ID <[email protected]>
:::::: 
:::::: Manual check reason: "__compiletime_assert_NNN"
:::::: 

BCC: [email protected]
CC: [email protected]
CC: [email protected]
TO: "Thomas Weißschuh" <[email protected]>
CC: Shuah Khan <[email protected]>
CC: Johannes Berg <[email protected]>
CC: David Gow <[email protected]>

Hi Thomas,

First bad commit (maybe != root cause):

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   94515f3a7d4256a5062176b7d6ed0471938cd51a
commit: 031cdd3bc3f369553933c1b0f4cb18000162c8ff kunit: Enable PCI on UML without triggering WARN()
date:   10 months ago
:::::: branch date: 2 days ago
:::::: commit date: 10 months ago
config: um-randconfig-r113-20260719 (https://download.01.org/0day-ci/archive/20260720/[email protected]/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
sparse: v0.6.5-rc1
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260720/[email protected]/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
| Fixes: 031cdd3bc3f3 ("kunit: Enable PCI on UML without triggering WARN()")
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

All errors (new ones prefixed by >>):

   In file included from drivers/iio/adc/ad7949.c:12:
   In file included from include/linux/regulator/consumer.h:35:
   In file included from include/linux/suspend.h:5:
   In file included from include/linux/swap.h:9:
   In file included from include/linux/memcontrol.h:13:
   In file included from include/linux/cgroup.h:27:
   In file included from include/linux/kernel_stat.h:8:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:11:
   In file included from arch/um/include/asm/hardirq.h:5:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:12:
   In file included from arch/um/include/asm/io.h:24:
   include/asm-generic/io.h:1175:55: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
    1175 |         return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port;
         |                                                   ~~~~~~~~~~ ^
>> drivers/iio/adc/ad7949.c:286:3: error: call to '__compiletime_assert_579' declared with 'error' attribute: FIELD_PREP: value too large for the field
     286 |                 FIELD_PREP(AD7949_CFG_MASK_INX, ad7949_adc->current_channel) |
         |                 ^
   include/linux/bitfield.h:115:3: note: expanded from macro 'FIELD_PREP'
     115 |                 __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: ");    \
         |                 ^
   include/linux/bitfield.h:68:3: note: expanded from macro '__BF_FIELD_CHECK'
      68 |                 BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ?           \
         |                 ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
      39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:560:2: note: expanded from macro '_compiletime_assert'
     560 |         __compiletime_assert(condition, msg, prefix, suffix)
         |         ^
   include/linux/compiler_types.h:553:4: note: expanded from macro '__compiletime_assert'
     553 |                         prefix ## suffix();                             \
         |                         ^
   <scratch space>:15:1: note: expanded from here
      15 | __compiletime_assert_579
         | ^
   1 warning and 1 error generated.


vim +286 drivers/iio/adc/ad7949.c

7f40e0614317f2 Charles-Antoine Couret 2018-10-22  275  
7f40e0614317f2 Charles-Antoine Couret 2018-10-22  276  static int ad7949_spi_init(struct ad7949_adc_chip *ad7949_adc)
7f40e0614317f2 Charles-Antoine Couret 2018-10-22  277  {
7f40e0614317f2 Charles-Antoine Couret 2018-10-22  278  	int ret;
7f40e0614317f2 Charles-Antoine Couret 2018-10-22  279  	int val;
595a0590f4fbcb Liam Beguin            2021-08-15  280  	u16 cfg;
7f40e0614317f2 Charles-Antoine Couret 2018-10-22  281  
7f40e0614317f2 Charles-Antoine Couret 2018-10-22  282  	ad7949_adc->current_channel = 0;
595a0590f4fbcb Liam Beguin            2021-08-15  283  
595a0590f4fbcb Liam Beguin            2021-08-15  284  	cfg = FIELD_PREP(AD7949_CFG_MASK_OVERWRITE, 1) |
595a0590f4fbcb Liam Beguin            2021-08-15  285  		FIELD_PREP(AD7949_CFG_MASK_INCC, AD7949_CFG_VAL_INCC_UNIPOLAR_GND) |
595a0590f4fbcb Liam Beguin            2021-08-15 @286  		FIELD_PREP(AD7949_CFG_MASK_INX, ad7949_adc->current_channel) |
595a0590f4fbcb Liam Beguin            2021-08-15  287  		FIELD_PREP(AD7949_CFG_MASK_BW_FULL, 1) |
37930650604982 Liam Beguin            2021-08-15  288  		FIELD_PREP(AD7949_CFG_MASK_REF, ad7949_adc->refsel) |
595a0590f4fbcb Liam Beguin            2021-08-15  289  		FIELD_PREP(AD7949_CFG_MASK_SEQ, 0x0) |
595a0590f4fbcb Liam Beguin            2021-08-15  290  		FIELD_PREP(AD7949_CFG_MASK_RBN, 1);
595a0590f4fbcb Liam Beguin            2021-08-15  291  
595a0590f4fbcb Liam Beguin            2021-08-15  292  	ret = ad7949_spi_write_cfg(ad7949_adc, cfg, AD7949_CFG_MASK_TOTAL);
7f40e0614317f2 Charles-Antoine Couret 2018-10-22  293  
7f40e0614317f2 Charles-Antoine Couret 2018-10-22  294  	/*
7f40e0614317f2 Charles-Antoine Couret 2018-10-22  295  	 * Do two dummy conversions to apply the first configuration setting.
7f40e0614317f2 Charles-Antoine Couret 2018-10-22  296  	 * Required only after the start up of the device.
7f40e0614317f2 Charles-Antoine Couret 2018-10-22  297  	 */
7f40e0614317f2 Charles-Antoine Couret 2018-10-22  298  	ad7949_spi_read_channel(ad7949_adc, &val, ad7949_adc->current_channel);
7f40e0614317f2 Charles-Antoine Couret 2018-10-22  299  	ad7949_spi_read_channel(ad7949_adc, &val, ad7949_adc->current_channel);
7f40e0614317f2 Charles-Antoine Couret 2018-10-22  300  
7f40e0614317f2 Charles-Antoine Couret 2018-10-22  301  	return ret;
7f40e0614317f2 Charles-Antoine Couret 2018-10-22  302  }
7f40e0614317f2 Charles-Antoine Couret 2018-10-22  303  

:::::: The code at line 286 was first introduced by commit
:::::: 595a0590f4fbcb39d73a7c55c79a7e7921ec1614 iio: adc: ad7949: define and use bitfield names

:::::: TO: Liam Beguin <[email protected]>
:::::: CC: Jonathan Cameron <[email protected]>

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