* drivers/iio/adc/axp20x_adc.c:572:26: sparse: sparse: dubious: x & !y
@ 2023-05-02 4:56 kernel test robot
0 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2023-05-02 4:56 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp
::::::
:::::: Manual check reason: "low confidence static check warning: drivers/iio/adc/axp20x_adc.c:572:26: sparse: sparse: dubious: x & !y"
::::::
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>
CC: Jonathan Cameron <Jonathan.Cameron@huawei.com>
CC: "Chen-Yu Tsai" <wens@csie.org>
CC: Andy Shevchenko <andy.shevchenko@gmail.com>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 865fdb08197e657c59e74a35fa32362b12397f58
commit: 8957e5344353e9cd3f6b1e3004942e35449fa0e8 iio: adc: axp20x_adc: Minor code cleanups
date: 7 weeks ago
:::::: branch date: 5 hours ago
:::::: commit date: 7 weeks ago
config: powerpc-randconfig-s042-20230501 (https://download.01.org/0day-ci/archive/20230502/202305021214.Ljg7QiRH-lkp@intel.com/config)
compiler: powerpc-linux-gcc (GCC) 12.1.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-39-gce1a6720-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8957e5344353e9cd3f6b1e3004942e35449fa0e8
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 8957e5344353e9cd3f6b1e3004942e35449fa0e8
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=powerpc olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=powerpc SHELL=/bin/bash drivers/iio/adc/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/r/202305021214.Ljg7QiRH-lkp@intel.com/
sparse warnings: (new ones prefixed by >>)
>> drivers/iio/adc/axp20x_adc.c:572:26: sparse: sparse: dubious: x & !y
drivers/iio/adc/axp20x_adc.c:577:26: sparse: sparse: dubious: x & !y
vim +572 drivers/iio/adc/axp20x_adc.c
1a3f6755649dd4 Quentin Schulz 2018-01-15 551
0e34d5de961d5a Quentin Schulz 2017-04-04 552 static int axp20x_write_raw(struct iio_dev *indio_dev,
0e34d5de961d5a Quentin Schulz 2017-04-04 553 struct iio_chan_spec const *chan, int val, int val2,
0e34d5de961d5a Quentin Schulz 2017-04-04 554 long mask)
0e34d5de961d5a Quentin Schulz 2017-04-04 555 {
0e34d5de961d5a Quentin Schulz 2017-04-04 556 struct axp20x_adc_iio *info = iio_priv(indio_dev);
8957e5344353e9 Aidan MacDonald 2023-02-17 557 unsigned int regmask, regval;
0e34d5de961d5a Quentin Schulz 2017-04-04 558
0e34d5de961d5a Quentin Schulz 2017-04-04 559 /*
0e34d5de961d5a Quentin Schulz 2017-04-04 560 * The AXP20X PMIC allows the user to choose between 0V and 0.7V offsets
0e34d5de961d5a Quentin Schulz 2017-04-04 561 * for (independently) GPIO0 and GPIO1 when in ADC mode.
0e34d5de961d5a Quentin Schulz 2017-04-04 562 */
0e34d5de961d5a Quentin Schulz 2017-04-04 563 if (mask != IIO_CHAN_INFO_OFFSET)
0e34d5de961d5a Quentin Schulz 2017-04-04 564 return -EINVAL;
0e34d5de961d5a Quentin Schulz 2017-04-04 565
0e34d5de961d5a Quentin Schulz 2017-04-04 566 if (val != 0 && val != 700000)
0e34d5de961d5a Quentin Schulz 2017-04-04 567 return -EINVAL;
0e34d5de961d5a Quentin Schulz 2017-04-04 568
0e34d5de961d5a Quentin Schulz 2017-04-04 569 switch (chan->channel) {
0e34d5de961d5a Quentin Schulz 2017-04-04 570 case AXP20X_GPIO0_V:
8957e5344353e9 Aidan MacDonald 2023-02-17 571 regmask = AXP20X_GPIO10_IN_RANGE_GPIO0;
8957e5344353e9 Aidan MacDonald 2023-02-17 @572 regval = FIELD_PREP(AXP20X_GPIO10_IN_RANGE_GPIO0, !!val);
0e34d5de961d5a Quentin Schulz 2017-04-04 573 break;
0e34d5de961d5a Quentin Schulz 2017-04-04 574
0e34d5de961d5a Quentin Schulz 2017-04-04 575 case AXP20X_GPIO1_V:
8957e5344353e9 Aidan MacDonald 2023-02-17 576 regmask = AXP20X_GPIO10_IN_RANGE_GPIO1;
8957e5344353e9 Aidan MacDonald 2023-02-17 577 regval = FIELD_PREP(AXP20X_GPIO10_IN_RANGE_GPIO1, !!val);
0e34d5de961d5a Quentin Schulz 2017-04-04 578 break;
0e34d5de961d5a Quentin Schulz 2017-04-04 579
0e34d5de961d5a Quentin Schulz 2017-04-04 580 default:
0e34d5de961d5a Quentin Schulz 2017-04-04 581 return -EINVAL;
0e34d5de961d5a Quentin Schulz 2017-04-04 582 }
0e34d5de961d5a Quentin Schulz 2017-04-04 583
8957e5344353e9 Aidan MacDonald 2023-02-17 584 return regmap_update_bits(info->regmap, AXP20X_GPIO10_IN_RANGE, regmask, regval);
0e34d5de961d5a Quentin Schulz 2017-04-04 585 }
0e34d5de961d5a Quentin Schulz 2017-04-04 586
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
^ permalink raw reply [flat|nested] 7+ messages in thread
* drivers/iio/adc/axp20x_adc.c:572:26: sparse: sparse: dubious: x & !y
@ 2023-11-15 22:27 kernel test robot
0 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2023-11-15 22:27 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp
::::::
:::::: Manual check reason: "low confidence static check warning: drivers/iio/adc/axp20x_adc.c:572:26: sparse: sparse: dubious: x & !y"
::::::
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>
CC: Jonathan Cameron <Jonathan.Cameron@huawei.com>
CC: "Chen-Yu Tsai" <wens@csie.org>
CC: Andy Shevchenko <andy.shevchenko@gmail.com>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: c42d9eeef8e5ba9292eda36fd8e3c11f35ee065c
commit: 8957e5344353e9cd3f6b1e3004942e35449fa0e8 iio: adc: axp20x_adc: Minor code cleanups
date: 8 months ago
:::::: branch date: 18 hours ago
:::::: commit date: 8 months ago
config: x86_64-randconfig-x001-20230717 (https://download.01.org/0day-ci/archive/20231116/202311160621.VPrVjwB9-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231116/202311160621.VPrVjwB9-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/r/202311160621.VPrVjwB9-lkp@intel.com/
sparse warnings: (new ones prefixed by >>)
>> drivers/iio/adc/axp20x_adc.c:572:26: sparse: sparse: dubious: x & !y
drivers/iio/adc/axp20x_adc.c:577:26: sparse: sparse: dubious: x & !y
vim +572 drivers/iio/adc/axp20x_adc.c
1a3f6755649dd4 Quentin Schulz 2018-01-15 551
0e34d5de961d5a Quentin Schulz 2017-04-04 552 static int axp20x_write_raw(struct iio_dev *indio_dev,
0e34d5de961d5a Quentin Schulz 2017-04-04 553 struct iio_chan_spec const *chan, int val, int val2,
0e34d5de961d5a Quentin Schulz 2017-04-04 554 long mask)
0e34d5de961d5a Quentin Schulz 2017-04-04 555 {
0e34d5de961d5a Quentin Schulz 2017-04-04 556 struct axp20x_adc_iio *info = iio_priv(indio_dev);
8957e5344353e9 Aidan MacDonald 2023-02-17 557 unsigned int regmask, regval;
0e34d5de961d5a Quentin Schulz 2017-04-04 558
0e34d5de961d5a Quentin Schulz 2017-04-04 559 /*
0e34d5de961d5a Quentin Schulz 2017-04-04 560 * The AXP20X PMIC allows the user to choose between 0V and 0.7V offsets
0e34d5de961d5a Quentin Schulz 2017-04-04 561 * for (independently) GPIO0 and GPIO1 when in ADC mode.
0e34d5de961d5a Quentin Schulz 2017-04-04 562 */
0e34d5de961d5a Quentin Schulz 2017-04-04 563 if (mask != IIO_CHAN_INFO_OFFSET)
0e34d5de961d5a Quentin Schulz 2017-04-04 564 return -EINVAL;
0e34d5de961d5a Quentin Schulz 2017-04-04 565
0e34d5de961d5a Quentin Schulz 2017-04-04 566 if (val != 0 && val != 700000)
0e34d5de961d5a Quentin Schulz 2017-04-04 567 return -EINVAL;
0e34d5de961d5a Quentin Schulz 2017-04-04 568
0e34d5de961d5a Quentin Schulz 2017-04-04 569 switch (chan->channel) {
0e34d5de961d5a Quentin Schulz 2017-04-04 570 case AXP20X_GPIO0_V:
8957e5344353e9 Aidan MacDonald 2023-02-17 571 regmask = AXP20X_GPIO10_IN_RANGE_GPIO0;
8957e5344353e9 Aidan MacDonald 2023-02-17 @572 regval = FIELD_PREP(AXP20X_GPIO10_IN_RANGE_GPIO0, !!val);
0e34d5de961d5a Quentin Schulz 2017-04-04 573 break;
0e34d5de961d5a Quentin Schulz 2017-04-04 574
0e34d5de961d5a Quentin Schulz 2017-04-04 575 case AXP20X_GPIO1_V:
8957e5344353e9 Aidan MacDonald 2023-02-17 576 regmask = AXP20X_GPIO10_IN_RANGE_GPIO1;
8957e5344353e9 Aidan MacDonald 2023-02-17 577 regval = FIELD_PREP(AXP20X_GPIO10_IN_RANGE_GPIO1, !!val);
0e34d5de961d5a Quentin Schulz 2017-04-04 578 break;
0e34d5de961d5a Quentin Schulz 2017-04-04 579
0e34d5de961d5a Quentin Schulz 2017-04-04 580 default:
0e34d5de961d5a Quentin Schulz 2017-04-04 581 return -EINVAL;
0e34d5de961d5a Quentin Schulz 2017-04-04 582 }
0e34d5de961d5a Quentin Schulz 2017-04-04 583
8957e5344353e9 Aidan MacDonald 2023-02-17 584 return regmap_update_bits(info->regmap, AXP20X_GPIO10_IN_RANGE, regmask, regval);
0e34d5de961d5a Quentin Schulz 2017-04-04 585 }
0e34d5de961d5a Quentin Schulz 2017-04-04 586
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 7+ messages in thread
* drivers/iio/adc/axp20x_adc.c:572:26: sparse: sparse: dubious: x & !y
@ 2023-11-18 1:24 kernel test robot
0 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2023-11-18 1:24 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp
::::::
:::::: Manual check reason: "low confidence static check warning: drivers/iio/adc/axp20x_adc.c:572:26: sparse: sparse: dubious: x & !y"
::::::
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>
CC: Jonathan Cameron <Jonathan.Cameron@huawei.com>
CC: "Chen-Yu Tsai" <wens@csie.org>
CC: Andy Shevchenko <andy.shevchenko@gmail.com>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 791c8ab095f71327899023223940dd52257a4173
commit: 8957e5344353e9cd3f6b1e3004942e35449fa0e8 iio: adc: axp20x_adc: Minor code cleanups
date: 8 months ago
:::::: branch date: 3 hours ago
:::::: commit date: 8 months ago
config: x86_64-randconfig-x001-20230717 (https://download.01.org/0day-ci/archive/20231118/202311180939.iYu7ELDX-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231118/202311180939.iYu7ELDX-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/r/202311180939.iYu7ELDX-lkp@intel.com/
sparse warnings: (new ones prefixed by >>)
>> drivers/iio/adc/axp20x_adc.c:572:26: sparse: sparse: dubious: x & !y
drivers/iio/adc/axp20x_adc.c:577:26: sparse: sparse: dubious: x & !y
vim +572 drivers/iio/adc/axp20x_adc.c
1a3f6755649dd4 Quentin Schulz 2018-01-15 551
0e34d5de961d5a Quentin Schulz 2017-04-04 552 static int axp20x_write_raw(struct iio_dev *indio_dev,
0e34d5de961d5a Quentin Schulz 2017-04-04 553 struct iio_chan_spec const *chan, int val, int val2,
0e34d5de961d5a Quentin Schulz 2017-04-04 554 long mask)
0e34d5de961d5a Quentin Schulz 2017-04-04 555 {
0e34d5de961d5a Quentin Schulz 2017-04-04 556 struct axp20x_adc_iio *info = iio_priv(indio_dev);
8957e5344353e9 Aidan MacDonald 2023-02-17 557 unsigned int regmask, regval;
0e34d5de961d5a Quentin Schulz 2017-04-04 558
0e34d5de961d5a Quentin Schulz 2017-04-04 559 /*
0e34d5de961d5a Quentin Schulz 2017-04-04 560 * The AXP20X PMIC allows the user to choose between 0V and 0.7V offsets
0e34d5de961d5a Quentin Schulz 2017-04-04 561 * for (independently) GPIO0 and GPIO1 when in ADC mode.
0e34d5de961d5a Quentin Schulz 2017-04-04 562 */
0e34d5de961d5a Quentin Schulz 2017-04-04 563 if (mask != IIO_CHAN_INFO_OFFSET)
0e34d5de961d5a Quentin Schulz 2017-04-04 564 return -EINVAL;
0e34d5de961d5a Quentin Schulz 2017-04-04 565
0e34d5de961d5a Quentin Schulz 2017-04-04 566 if (val != 0 && val != 700000)
0e34d5de961d5a Quentin Schulz 2017-04-04 567 return -EINVAL;
0e34d5de961d5a Quentin Schulz 2017-04-04 568
0e34d5de961d5a Quentin Schulz 2017-04-04 569 switch (chan->channel) {
0e34d5de961d5a Quentin Schulz 2017-04-04 570 case AXP20X_GPIO0_V:
8957e5344353e9 Aidan MacDonald 2023-02-17 571 regmask = AXP20X_GPIO10_IN_RANGE_GPIO0;
8957e5344353e9 Aidan MacDonald 2023-02-17 @572 regval = FIELD_PREP(AXP20X_GPIO10_IN_RANGE_GPIO0, !!val);
0e34d5de961d5a Quentin Schulz 2017-04-04 573 break;
0e34d5de961d5a Quentin Schulz 2017-04-04 574
0e34d5de961d5a Quentin Schulz 2017-04-04 575 case AXP20X_GPIO1_V:
8957e5344353e9 Aidan MacDonald 2023-02-17 576 regmask = AXP20X_GPIO10_IN_RANGE_GPIO1;
8957e5344353e9 Aidan MacDonald 2023-02-17 577 regval = FIELD_PREP(AXP20X_GPIO10_IN_RANGE_GPIO1, !!val);
0e34d5de961d5a Quentin Schulz 2017-04-04 578 break;
0e34d5de961d5a Quentin Schulz 2017-04-04 579
0e34d5de961d5a Quentin Schulz 2017-04-04 580 default:
0e34d5de961d5a Quentin Schulz 2017-04-04 581 return -EINVAL;
0e34d5de961d5a Quentin Schulz 2017-04-04 582 }
0e34d5de961d5a Quentin Schulz 2017-04-04 583
8957e5344353e9 Aidan MacDonald 2023-02-17 584 return regmap_update_bits(info->regmap, AXP20X_GPIO10_IN_RANGE, regmask, regval);
0e34d5de961d5a Quentin Schulz 2017-04-04 585 }
0e34d5de961d5a Quentin Schulz 2017-04-04 586
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 7+ messages in thread
* drivers/iio/adc/axp20x_adc.c:572:26: sparse: sparse: dubious: x & !y
@ 2024-01-07 1:28 kernel test robot
2024-01-07 5:37 ` Chen-Yu Tsai
0 siblings, 1 reply; 7+ messages in thread
From: kernel test robot @ 2024-01-07 1:28 UTC (permalink / raw)
To: Aidan MacDonald
Cc: oe-kbuild-all, linux-kernel, Jonathan Cameron, Chen-Yu Tsai,
Andy Shevchenko
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 52b1853b080a082ec3749c3a9577f6c71b1d4a90
commit: 8957e5344353e9cd3f6b1e3004942e35449fa0e8 iio: adc: axp20x_adc: Minor code cleanups
date: 10 months ago
config: x86_64-randconfig-121-20240106 (https://download.01.org/0day-ci/archive/20240107/202401070901.68H00NFa-lkp@intel.com/config)
compiler: ClangBuiltLinux clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240107/202401070901.68H00NFa-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/202401070901.68H00NFa-lkp@intel.com/
sparse warnings: (new ones prefixed by >>)
>> drivers/iio/adc/axp20x_adc.c:572:26: sparse: sparse: dubious: x & !y
drivers/iio/adc/axp20x_adc.c:577:26: sparse: sparse: dubious: x & !y
vim +572 drivers/iio/adc/axp20x_adc.c
551
552 static int axp20x_write_raw(struct iio_dev *indio_dev,
553 struct iio_chan_spec const *chan, int val, int val2,
554 long mask)
555 {
556 struct axp20x_adc_iio *info = iio_priv(indio_dev);
557 unsigned int regmask, regval;
558
559 /*
560 * The AXP20X PMIC allows the user to choose between 0V and 0.7V offsets
561 * for (independently) GPIO0 and GPIO1 when in ADC mode.
562 */
563 if (mask != IIO_CHAN_INFO_OFFSET)
564 return -EINVAL;
565
566 if (val != 0 && val != 700000)
567 return -EINVAL;
568
569 switch (chan->channel) {
570 case AXP20X_GPIO0_V:
571 regmask = AXP20X_GPIO10_IN_RANGE_GPIO0;
> 572 regval = FIELD_PREP(AXP20X_GPIO10_IN_RANGE_GPIO0, !!val);
573 break;
574
575 case AXP20X_GPIO1_V:
576 regmask = AXP20X_GPIO10_IN_RANGE_GPIO1;
577 regval = FIELD_PREP(AXP20X_GPIO10_IN_RANGE_GPIO1, !!val);
578 break;
579
580 default:
581 return -EINVAL;
582 }
583
584 return regmap_update_bits(info->regmap, AXP20X_GPIO10_IN_RANGE, regmask, regval);
585 }
586
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: drivers/iio/adc/axp20x_adc.c:572:26: sparse: sparse: dubious: x & !y
2024-01-07 1:28 drivers/iio/adc/axp20x_adc.c:572:26: sparse: sparse: dubious: x & !y kernel test robot
@ 2024-01-07 5:37 ` Chen-Yu Tsai
2024-01-07 19:46 ` Andy Shevchenko
0 siblings, 1 reply; 7+ messages in thread
From: Chen-Yu Tsai @ 2024-01-07 5:37 UTC (permalink / raw)
To: kernel test robot
Cc: Aidan MacDonald, oe-kbuild-all, linux-kernel, Jonathan Cameron,
Andy Shevchenko
On Sun, Jan 7, 2024 at 9:30 AM kernel test robot <lkp@intel.com> wrote:
>
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: 52b1853b080a082ec3749c3a9577f6c71b1d4a90
> commit: 8957e5344353e9cd3f6b1e3004942e35449fa0e8 iio: adc: axp20x_adc: Minor code cleanups
> date: 10 months ago
> config: x86_64-randconfig-121-20240106 (https://download.01.org/0day-ci/archive/20240107/202401070901.68H00NFa-lkp@intel.com/config)
> compiler: ClangBuiltLinux clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240107/202401070901.68H00NFa-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/202401070901.68H00NFa-lkp@intel.com/
>
> sparse warnings: (new ones prefixed by >>)
> >> drivers/iio/adc/axp20x_adc.c:572:26: sparse: sparse: dubious: x & !y
> drivers/iio/adc/axp20x_adc.c:577:26: sparse: sparse: dubious: x & !y
This looks like a false positive. The code is doing exactly what we want:
val = val ? 1 : 0, but in a shorter format.
ChenYu
>
> vim +572 drivers/iio/adc/axp20x_adc.c
>
> 551
> 552 static int axp20x_write_raw(struct iio_dev *indio_dev,
> 553 struct iio_chan_spec const *chan, int val, int val2,
> 554 long mask)
> 555 {
> 556 struct axp20x_adc_iio *info = iio_priv(indio_dev);
> 557 unsigned int regmask, regval;
> 558
> 559 /*
> 560 * The AXP20X PMIC allows the user to choose between 0V and 0.7V offsets
> 561 * for (independently) GPIO0 and GPIO1 when in ADC mode.
> 562 */
> 563 if (mask != IIO_CHAN_INFO_OFFSET)
> 564 return -EINVAL;
> 565
> 566 if (val != 0 && val != 700000)
> 567 return -EINVAL;
> 568
> 569 switch (chan->channel) {
> 570 case AXP20X_GPIO0_V:
> 571 regmask = AXP20X_GPIO10_IN_RANGE_GPIO0;
> > 572 regval = FIELD_PREP(AXP20X_GPIO10_IN_RANGE_GPIO0, !!val);
> 573 break;
> 574
> 575 case AXP20X_GPIO1_V:
> 576 regmask = AXP20X_GPIO10_IN_RANGE_GPIO1;
> 577 regval = FIELD_PREP(AXP20X_GPIO10_IN_RANGE_GPIO1, !!val);
> 578 break;
> 579
> 580 default:
> 581 return -EINVAL;
> 582 }
> 583
> 584 return regmap_update_bits(info->regmap, AXP20X_GPIO10_IN_RANGE, regmask, regval);
> 585 }
> 586
>
> --
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: drivers/iio/adc/axp20x_adc.c:572:26: sparse: sparse: dubious: x & !y
2024-01-07 5:37 ` Chen-Yu Tsai
@ 2024-01-07 19:46 ` Andy Shevchenko
0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2024-01-07 19:46 UTC (permalink / raw)
To: wens
Cc: kernel test robot, Aidan MacDonald, oe-kbuild-all, linux-kernel,
Jonathan Cameron
On Sun, Jan 7, 2024 at 7:37 AM Chen-Yu Tsai <wens@csie.org> wrote:
> On Sun, Jan 7, 2024 at 9:30 AM kernel test robot <lkp@intel.com> wrote:
...
> > sparse warnings: (new ones prefixed by >>)
> > >> drivers/iio/adc/axp20x_adc.c:572:26: sparse: sparse: dubious: x & !y
> > drivers/iio/adc/axp20x_adc.c:577:26: sparse: sparse: dubious: x & !y
>
> This looks like a false positive. The code is doing exactly what we want:
> val = val ? 1 : 0, but in a shorter format.
Yes, but the problem is that FIELD_PREP() is a macro.
You can replace these by ternary (here and in other cases) to satisfy
sparse. Compiler will optimize that anyway, so no branch is expected
in the generated code.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 7+ messages in thread
* drivers/iio/adc/axp20x_adc.c:572:26: sparse: sparse: dubious: x & !y
@ 2024-01-10 17:53 kernel test robot
0 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2024-01-10 17:53 UTC (permalink / raw)
To: Aidan MacDonald
Cc: oe-kbuild-all, linux-kernel, Jonathan Cameron, Chen-Yu Tsai,
Andy Shevchenko
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: ab27740f76654ed58dd32ac0ba0031c18a6dea3b
commit: 8957e5344353e9cd3f6b1e3004942e35449fa0e8 iio: adc: axp20x_adc: Minor code cleanups
date: 10 months ago
config: csky-buildonly-randconfig-r006-20230413 (https://download.01.org/0day-ci/archive/20240111/202401110159.j4qEZUPp-lkp@intel.com/config)
compiler: csky-linux-gcc (GCC) 12.3.0
reproduce: (https://download.01.org/0day-ci/archive/20240111/202401110159.j4qEZUPp-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/202401110159.j4qEZUPp-lkp@intel.com/
sparse warnings: (new ones prefixed by >>)
>> drivers/iio/adc/axp20x_adc.c:572:26: sparse: sparse: dubious: x & !y
drivers/iio/adc/axp20x_adc.c:577:26: sparse: sparse: dubious: x & !y
drivers/iio/adc/axp20x_adc.c: note: in included file (through include/linux/mmzone.h, include/linux/topology.h, include/linux/irq.h, ...):
include/linux/page-flags.h:246:46: sparse: sparse: self-comparison always evaluates to false
vim +572 drivers/iio/adc/axp20x_adc.c
551
552 static int axp20x_write_raw(struct iio_dev *indio_dev,
553 struct iio_chan_spec const *chan, int val, int val2,
554 long mask)
555 {
556 struct axp20x_adc_iio *info = iio_priv(indio_dev);
557 unsigned int regmask, regval;
558
559 /*
560 * The AXP20X PMIC allows the user to choose between 0V and 0.7V offsets
561 * for (independently) GPIO0 and GPIO1 when in ADC mode.
562 */
563 if (mask != IIO_CHAN_INFO_OFFSET)
564 return -EINVAL;
565
566 if (val != 0 && val != 700000)
567 return -EINVAL;
568
569 switch (chan->channel) {
570 case AXP20X_GPIO0_V:
571 regmask = AXP20X_GPIO10_IN_RANGE_GPIO0;
> 572 regval = FIELD_PREP(AXP20X_GPIO10_IN_RANGE_GPIO0, !!val);
573 break;
574
575 case AXP20X_GPIO1_V:
576 regmask = AXP20X_GPIO10_IN_RANGE_GPIO1;
577 regval = FIELD_PREP(AXP20X_GPIO10_IN_RANGE_GPIO1, !!val);
578 break;
579
580 default:
581 return -EINVAL;
582 }
583
584 return regmap_update_bits(info->regmap, AXP20X_GPIO10_IN_RANGE, regmask, regval);
585 }
586
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-01-10 17:54 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-07 1:28 drivers/iio/adc/axp20x_adc.c:572:26: sparse: sparse: dubious: x & !y kernel test robot
2024-01-07 5:37 ` Chen-Yu Tsai
2024-01-07 19:46 ` Andy Shevchenko
-- strict thread matches above, loose matches on Subject: below --
2024-01-10 17:53 kernel test robot
2023-11-18 1:24 kernel test robot
2023-11-15 22:27 kernel test robot
2023-05-02 4:56 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.