All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: kbuild@lists.01.org
Subject: drivers/iio/adc/max1027.c:412:14: warning: The result of the left shift is undefined because the left operand is negative [clang-analyzer-core.UndefinedBinaryOperatorResult]
Date: Fri, 01 Oct 2021 07:59:11 +0800	[thread overview]
Message-ID: <202110010706.x8xrbRyX-lkp@intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 26693 bytes --]

CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Miquel Raynal <miquel.raynal@bootlin.com>
CC: 0day robot <lkp@intel.com>

tree:   https://github.com/0day-ci/linux/commits/Miquel-Raynal/Bring-external-triggers-support-to-MAX1027-like-ADCs/20210922-131741
head:   82403933ab13283e98041a4c285420988531362c
commit: 1e80dcadd79f6dec7346dc596fbafd508ea2844e iio: adc: max1027: Minimize the number of converted channels
date:   9 days ago
:::::: branch date: 9 days ago
:::::: commit date: 9 days ago
config: riscv-randconfig-c006-20210927 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project dc6e8dfdfe7efecfda318d43a06fae18b40eb498)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install riscv cross compiling tool for clang build
        # apt-get install binutils-riscv64-linux-gnu
        # https://github.com/0day-ci/linux/commit/1e80dcadd79f6dec7346dc596fbafd508ea2844e
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Miquel-Raynal/Bring-external-triggers-support-to-MAX1027-like-ADCs/20210922-131741
        git checkout 1e80dcadd79f6dec7346dc596fbafd508ea2844e
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv clang-analyzer 

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


clang-analyzer warnings: (new ones prefixed by >>)
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   10 warnings generated.
   Suppressed 10 warnings (10 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   12 warnings generated.
   Suppressed 12 warnings (12 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   7 warnings generated.
   Suppressed 7 warnings (7 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   10 warnings generated.
   Suppressed 10 warnings (10 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   31 warnings generated.
   Suppressed 31 warnings (10 in non-user code, 21 with check filters).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   23 warnings generated.
   Suppressed 23 warnings (10 in non-user code, 13 with check filters).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   5 warnings generated.
   Suppressed 5 warnings (5 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   9 warnings generated.
   Suppressed 9 warnings (9 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   9 warnings generated.
   Suppressed 9 warnings (9 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   9 warnings generated.
   Suppressed 9 warnings (9 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   8 warnings generated.
   Suppressed 8 warnings (8 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   8 warnings generated.
   Suppressed 8 warnings (8 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   9 warnings generated.
   Suppressed 9 warnings (9 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   8 warnings generated.
   Suppressed 8 warnings (8 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   10 warnings generated.
   drivers/iio/accel/bma180.c:197:36: warning: The result of the left shift is undefined because the right operand is negative [clang-analyzer-core.UndefinedBinaryOperatorResult]
           u8 reg_val = (ret & ~mask) | (val << (ffs(mask) - 1));
                                             ^
   drivers/iio/accel/bma180.c:914:8: note: Calling 'bma180_reset_intr'
           ret = bma180_reset_intr(data);
                 ^~~~~~~~~~~~~~~~~~~~~~~
   drivers/iio/accel/bma180.c:207:12: note: Calling 'bma180_set_bits'
           int ret = bma180_set_bits(data, data->part_info->int_reset_reg,
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/iio/accel/bma180.c:197:36: note: The result of the left shift is undefined because the right operand is negative
           u8 reg_val = (ret & ~mask) | (val << (ffs(mask) - 1));
                                             ^  ~~~~~~~~~~~~~~~
   Suppressed 9 warnings (9 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   9 warnings generated.
   Suppressed 9 warnings (9 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   12 warnings generated.
   Suppressed 12 warnings (12 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   10 warnings generated.
   Suppressed 10 warnings (10 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   12 warnings generated.
   Suppressed 12 warnings (12 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   12 warnings generated.
   Suppressed 12 warnings (12 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   12 warnings generated.
   Suppressed 12 warnings (12 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   10 warnings generated.
   drivers/iio/adc/max1027.c:265:8: warning: Excessive padding in 'struct max1027_state' (99 padding bytes, where 35 is optimal). 
   Optimal fields order: 
   reg, 
   info, 
   spi, 
   trig, 
   buffer, 
   lock, 
   consider reordering the fields or adding explicit padding members [clang-analyzer-optin.performance.Padding]
   struct max1027_state {
   ~~~~~~~^~~~~~~~~~~~~~~
   drivers/iio/adc/max1027.c:265:8: note: Excessive padding in 'struct max1027_state' (99 padding bytes, where 35 is optimal). Optimal fields order: reg, info, spi, trig, buffer, lock, consider reordering the fields or adding explicit padding members
   struct max1027_state {
   ~~~~~~~^~~~~~~~~~~~~~~
>> drivers/iio/adc/max1027.c:412:14: warning: The result of the left shift is undefined because the left operand is negative [clang-analyzer-core.UndefinedBinaryOperatorResult]
                   st->reg |= MAX1027_CHAN(fls(*indio_dev->active_scan_mask) - 2);
                              ^
   drivers/iio/adc/max1027.c:38:32: note: expanded from macro 'MAX1027_CHAN'
   #define MAX1027_CHAN(n)   ((n) << 3)
                              ~~~ ^
   drivers/iio/adc/max1027.c:399:6: note: Assuming 'state' is true
           if (state) {
               ^~~~~
   drivers/iio/adc/max1027.c:399:2: note: Taking true branch
           if (state) {
           ^
   drivers/iio/adc/max1027.c:404:7: note: Assuming 'ret' is >= 0
                   if (ret < 0)
                       ^~~~~~~
   drivers/iio/adc/max1027.c:404:3: note: Taking false branch
                   if (ret < 0)
                   ^
   drivers/iio/adc/max1027.c:412:14: note: The result of the left shift is undefined because the left operand is negative
                   st->reg |= MAX1027_CHAN(fls(*indio_dev->active_scan_mask) - 2);
                              ^
   drivers/iio/adc/max1027.c:38:32: note: expanded from macro 'MAX1027_CHAN'
   #define MAX1027_CHAN(n)   ((n) << 3)
                              ~~~ ^
   Suppressed 8 warnings (8 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   11 warnings generated.
   drivers/iio/adc/max11100.c:31:8: warning: Excessive padding in 'struct max11100_state' (117 padding bytes, where 53 is optimal). 
   Optimal fields order: 
   buffer, 
   vref_reg, 
   spi, 
   consider reordering the fields or adding explicit padding members [clang-analyzer-optin.performance.Padding]
   struct max11100_state {
   ~~~~~~~^~~~~~~~~~~~~~~~
   drivers/iio/adc/max11100.c:31:8: note: Excessive padding in 'struct max11100_state' (117 padding bytes, where 53 is optimal). Optimal fields order: buffer, vref_reg, spi, consider reordering the fields or adding explicit padding members
   struct max11100_state {
   ~~~~~~~^~~~~~~~~~~~~~~~
   Suppressed 10 warnings (10 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   11 warnings generated.
   drivers/iio/adc/max1241.c:22:8: warning: Excessive padding in 'struct max1241' (98 padding bytes, where 34 is optimal). 
   Optimal fields order: 
   data, 
   spi, 
   vdd, 
   vref, 
   shutdown, 
   lock, 
   consider reordering the fields or adding explicit padding members [clang-analyzer-optin.performance.Padding]
   struct max1241 {
   ~~~~~~~^~~~~~~~~
   drivers/iio/adc/max1241.c:22:8: note: Excessive padding in 'struct max1241' (98 padding bytes, where 34 is optimal). Optimal fields order: data, spi, vdd, vref, shutdown, lock, consider reordering the fields or adding explicit padding members
   struct max1241 {
   ~~~~~~~^~~~~~~~~
   Suppressed 10 warnings (10 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   11 warnings generated.
   drivers/iio/dac/ti-dac7311.c:47:8: warning: Excessive padding in 'struct ti_dac_chip' (101 padding bytes, where 37 is optimal). 
   Optimal fields order: 
   buf, 
   val, 
   vref, 
   spi, 
   lock, 
   powerdown, 
   powerdown_mode, 
   resolution, 
   consider reordering the fields or adding explicit padding members [clang-analyzer-optin.performance.Padding]
   struct ti_dac_chip {
   ~~~~~~~^~~~~~~~~~~~~
   drivers/iio/dac/ti-dac7311.c:47:8: note: Excessive padding in 'struct ti_dac_chip' (101 padding bytes, where 37 is optimal). Optimal fields order: buf, val, vref, spi, lock, powerdown, powerdown_mode, resolution, consider reordering the fields or adding explicit padding members
   struct ti_dac_chip {
   ~~~~~~~^~~~~~~~~~~~~
   Suppressed 10 warnings (10 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   9 warnings generated.
   Suppressed 9 warnings (9 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   9 warnings generated.
   drivers/iio/gyro/adis16130.c:41:8: warning: Excessive padding in 'struct adis16130_state' (108 padding bytes, where 44 is optimal). 
   Optimal fields order: 
   buf, 
   us, 
   buf_lock, 
   consider reordering the fields or adding explicit padding members [clang-analyzer-optin.performance.Padding]
   struct adis16130_state {
   ~~~~~~~^~~~~~~~~~~~~~~~~
   drivers/iio/gyro/adis16130.c:41:8: note: Excessive padding in 'struct adis16130_state' (108 padding bytes, where 44 is optimal). Optimal fields order: buf, us, buf_lock, consider reordering the fields or adding explicit padding members
   struct adis16130_state {
   ~~~~~~~^~~~~~~~~~~~~~~~~
   Suppressed 8 warnings (8 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   9 warnings generated.
   Suppressed 9 warnings (9 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   9 warnings generated.
   Suppressed 9 warnings (9 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   6 warnings generated.
   Suppressed 6 warnings (6 in non-user code).

vim +412 drivers/iio/adc/max1027.c

fc167f62483325 Philippe Reynes 2014-06-14  264  
fc167f62483325 Philippe Reynes 2014-06-14 @265  struct max1027_state {
fc167f62483325 Philippe Reynes 2014-06-14  266  	const struct max1027_chip_info	*info;
fc167f62483325 Philippe Reynes 2014-06-14  267  	struct spi_device		*spi;
fc167f62483325 Philippe Reynes 2014-06-14  268  	struct iio_trigger		*trig;
fc167f62483325 Philippe Reynes 2014-06-14  269  	__be16				*buffer;
fc167f62483325 Philippe Reynes 2014-06-14  270  	struct mutex			lock;
fc167f62483325 Philippe Reynes 2014-06-14  271  
fc167f62483325 Philippe Reynes 2014-06-14  272  	u8				reg ____cacheline_aligned;
fc167f62483325 Philippe Reynes 2014-06-14  273  };
fc167f62483325 Philippe Reynes 2014-06-14  274  
fc167f62483325 Philippe Reynes 2014-06-14  275  static int max1027_read_single_value(struct iio_dev *indio_dev,
fc167f62483325 Philippe Reynes 2014-06-14  276  				     struct iio_chan_spec const *chan,
fc167f62483325 Philippe Reynes 2014-06-14  277  				     int *val)
fc167f62483325 Philippe Reynes 2014-06-14  278  {
fc167f62483325 Philippe Reynes 2014-06-14  279  	int ret;
fc167f62483325 Philippe Reynes 2014-06-14  280  	struct max1027_state *st = iio_priv(indio_dev);
fc167f62483325 Philippe Reynes 2014-06-14  281  
fc167f62483325 Philippe Reynes 2014-06-14  282  	if (iio_buffer_enabled(indio_dev)) {
fc167f62483325 Philippe Reynes 2014-06-14  283  		dev_warn(&indio_dev->dev, "trigger mode already enabled");
fc167f62483325 Philippe Reynes 2014-06-14  284  		return -EBUSY;
fc167f62483325 Philippe Reynes 2014-06-14  285  	}
fc167f62483325 Philippe Reynes 2014-06-14  286  
fc167f62483325 Philippe Reynes 2014-06-14  287  	/* Start acquisition on conversion register write */
fc167f62483325 Philippe Reynes 2014-06-14  288  	st->reg = MAX1027_SETUP_REG | MAX1027_REF_MODE2 | MAX1027_CKS_MODE2;
fc167f62483325 Philippe Reynes 2014-06-14  289  	ret = spi_write(st->spi, &st->reg, 1);
fc167f62483325 Philippe Reynes 2014-06-14  290  	if (ret < 0) {
fc167f62483325 Philippe Reynes 2014-06-14  291  		dev_err(&indio_dev->dev,
fc167f62483325 Philippe Reynes 2014-06-14  292  			"Failed to configure setup register\n");
fc167f62483325 Philippe Reynes 2014-06-14  293  		return ret;
fc167f62483325 Philippe Reynes 2014-06-14  294  	}
fc167f62483325 Philippe Reynes 2014-06-14  295  
fc167f62483325 Philippe Reynes 2014-06-14  296  	/* Configure conversion register with the requested chan */
fc167f62483325 Philippe Reynes 2014-06-14  297  	st->reg = MAX1027_CONV_REG | MAX1027_CHAN(chan->channel) |
58b90a8d2c397a Sandhya Bankar  2016-09-24  298  		  MAX1027_NOSCAN;
58b90a8d2c397a Sandhya Bankar  2016-09-24  299  	if (chan->type == IIO_TEMP)
58b90a8d2c397a Sandhya Bankar  2016-09-24  300  		st->reg |= MAX1027_TEMP;
fc167f62483325 Philippe Reynes 2014-06-14  301  	ret = spi_write(st->spi, &st->reg, 1);
fc167f62483325 Philippe Reynes 2014-06-14  302  	if (ret < 0) {
fc167f62483325 Philippe Reynes 2014-06-14  303  		dev_err(&indio_dev->dev,
fc167f62483325 Philippe Reynes 2014-06-14  304  			"Failed to configure conversion register\n");
fc167f62483325 Philippe Reynes 2014-06-14  305  		return ret;
fc167f62483325 Philippe Reynes 2014-06-14  306  	}
fc167f62483325 Philippe Reynes 2014-06-14  307  
fc167f62483325 Philippe Reynes 2014-06-14  308  	/*
fc167f62483325 Philippe Reynes 2014-06-14  309  	 * For an unknown reason, when we use the mode "10" (write
fc167f62483325 Philippe Reynes 2014-06-14  310  	 * conversion register), the interrupt doesn't occur every time.
fc167f62483325 Philippe Reynes 2014-06-14  311  	 * So we just wait 1 ms.
fc167f62483325 Philippe Reynes 2014-06-14  312  	 */
fc167f62483325 Philippe Reynes 2014-06-14  313  	mdelay(1);
fc167f62483325 Philippe Reynes 2014-06-14  314  
fc167f62483325 Philippe Reynes 2014-06-14  315  	/* Read result */
fc167f62483325 Philippe Reynes 2014-06-14  316  	ret = spi_read(st->spi, st->buffer, (chan->type == IIO_TEMP) ? 4 : 2);
fc167f62483325 Philippe Reynes 2014-06-14  317  	if (ret < 0)
fc167f62483325 Philippe Reynes 2014-06-14  318  		return ret;
fc167f62483325 Philippe Reynes 2014-06-14  319  
fc167f62483325 Philippe Reynes 2014-06-14  320  	*val = be16_to_cpu(st->buffer[0]);
fc167f62483325 Philippe Reynes 2014-06-14  321  
fc167f62483325 Philippe Reynes 2014-06-14  322  	return IIO_VAL_INT;
fc167f62483325 Philippe Reynes 2014-06-14  323  }
fc167f62483325 Philippe Reynes 2014-06-14  324  
fc167f62483325 Philippe Reynes 2014-06-14  325  static int max1027_read_raw(struct iio_dev *indio_dev,
fc167f62483325 Philippe Reynes 2014-06-14  326  			    struct iio_chan_spec const *chan,
fc167f62483325 Philippe Reynes 2014-06-14  327  			    int *val, int *val2, long mask)
fc167f62483325 Philippe Reynes 2014-06-14  328  {
fc167f62483325 Philippe Reynes 2014-06-14  329  	int ret = 0;
fc167f62483325 Philippe Reynes 2014-06-14  330  	struct max1027_state *st = iio_priv(indio_dev);
fc167f62483325 Philippe Reynes 2014-06-14  331  
fc167f62483325 Philippe Reynes 2014-06-14  332  	mutex_lock(&st->lock);
fc167f62483325 Philippe Reynes 2014-06-14  333  
fc167f62483325 Philippe Reynes 2014-06-14  334  	switch (mask) {
fc167f62483325 Philippe Reynes 2014-06-14  335  	case IIO_CHAN_INFO_RAW:
fc167f62483325 Philippe Reynes 2014-06-14  336  		ret = max1027_read_single_value(indio_dev, chan, val);
fc167f62483325 Philippe Reynes 2014-06-14  337  		break;
fc167f62483325 Philippe Reynes 2014-06-14  338  	case IIO_CHAN_INFO_SCALE:
fc167f62483325 Philippe Reynes 2014-06-14  339  		switch (chan->type) {
fc167f62483325 Philippe Reynes 2014-06-14  340  		case IIO_TEMP:
fc167f62483325 Philippe Reynes 2014-06-14  341  			*val = 1;
fc167f62483325 Philippe Reynes 2014-06-14  342  			*val2 = 8;
fc167f62483325 Philippe Reynes 2014-06-14  343  			ret = IIO_VAL_FRACTIONAL;
fc167f62483325 Philippe Reynes 2014-06-14  344  			break;
fc167f62483325 Philippe Reynes 2014-06-14  345  		case IIO_VOLTAGE:
fc167f62483325 Philippe Reynes 2014-06-14  346  			*val = 2500;
7af5257d84275c Miquel Raynal   2019-10-11  347  			*val2 = chan->scan_type.realbits;
fc167f62483325 Philippe Reynes 2014-06-14  348  			ret = IIO_VAL_FRACTIONAL_LOG2;
fc167f62483325 Philippe Reynes 2014-06-14  349  			break;
fc167f62483325 Philippe Reynes 2014-06-14  350  		default:
fc167f62483325 Philippe Reynes 2014-06-14  351  			ret = -EINVAL;
fc167f62483325 Philippe Reynes 2014-06-14  352  			break;
fc167f62483325 Philippe Reynes 2014-06-14  353  		}
fc167f62483325 Philippe Reynes 2014-06-14  354  		break;
fc167f62483325 Philippe Reynes 2014-06-14  355  	default:
fc167f62483325 Philippe Reynes 2014-06-14  356  		ret = -EINVAL;
fc167f62483325 Philippe Reynes 2014-06-14  357  		break;
fc167f62483325 Philippe Reynes 2014-06-14  358  	}
fc167f62483325 Philippe Reynes 2014-06-14  359  
fc167f62483325 Philippe Reynes 2014-06-14  360  	mutex_unlock(&st->lock);
fc167f62483325 Philippe Reynes 2014-06-14  361  
fc167f62483325 Philippe Reynes 2014-06-14  362  	return ret;
fc167f62483325 Philippe Reynes 2014-06-14  363  }
fc167f62483325 Philippe Reynes 2014-06-14  364  
fc167f62483325 Philippe Reynes 2014-06-14  365  static int max1027_debugfs_reg_access(struct iio_dev *indio_dev,
825ca5fefb8af9 Miquel Raynal   2021-09-21  366  				      unsigned int reg, unsigned int writeval,
825ca5fefb8af9 Miquel Raynal   2021-09-21  367  				      unsigned int *readval)
fc167f62483325 Philippe Reynes 2014-06-14  368  {
fc167f62483325 Philippe Reynes 2014-06-14  369  	struct max1027_state *st = iio_priv(indio_dev);
fc167f62483325 Philippe Reynes 2014-06-14  370  	u8 *val = (u8 *)st->buffer;
fc167f62483325 Philippe Reynes 2014-06-14  371  
038696f8bd2f2e Miquel Raynal   2019-10-11  372  	if (readval) {
038696f8bd2f2e Miquel Raynal   2019-10-11  373  		int ret = spi_read(st->spi, val, 2);
038696f8bd2f2e Miquel Raynal   2019-10-11  374  		*readval = be16_to_cpu(st->buffer[0]);
038696f8bd2f2e Miquel Raynal   2019-10-11  375  		return ret;
038696f8bd2f2e Miquel Raynal   2019-10-11  376  	}
fc167f62483325 Philippe Reynes 2014-06-14  377  
fc167f62483325 Philippe Reynes 2014-06-14  378  	*val = (u8)writeval;
fc167f62483325 Philippe Reynes 2014-06-14  379  	return spi_write(st->spi, val, 1);
fc167f62483325 Philippe Reynes 2014-06-14  380  }
fc167f62483325 Philippe Reynes 2014-06-14  381  
fc167f62483325 Philippe Reynes 2014-06-14  382  static int max1027_validate_trigger(struct iio_dev *indio_dev,
fc167f62483325 Philippe Reynes 2014-06-14  383  				    struct iio_trigger *trig)
fc167f62483325 Philippe Reynes 2014-06-14  384  {
fc167f62483325 Philippe Reynes 2014-06-14  385  	struct max1027_state *st = iio_priv(indio_dev);
fc167f62483325 Philippe Reynes 2014-06-14  386  
fc167f62483325 Philippe Reynes 2014-06-14  387  	if (st->trig != trig)
fc167f62483325 Philippe Reynes 2014-06-14  388  		return -EINVAL;
fc167f62483325 Philippe Reynes 2014-06-14  389  
fc167f62483325 Philippe Reynes 2014-06-14  390  	return 0;
fc167f62483325 Philippe Reynes 2014-06-14  391  }
fc167f62483325 Philippe Reynes 2014-06-14  392  
fc167f62483325 Philippe Reynes 2014-06-14  393  static int max1027_set_trigger_state(struct iio_trigger *trig, bool state)
fc167f62483325 Philippe Reynes 2014-06-14  394  {
fc167f62483325 Philippe Reynes 2014-06-14  395  	struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
fc167f62483325 Philippe Reynes 2014-06-14  396  	struct max1027_state *st = iio_priv(indio_dev);
fc167f62483325 Philippe Reynes 2014-06-14  397  	int ret;
fc167f62483325 Philippe Reynes 2014-06-14  398  
fc167f62483325 Philippe Reynes 2014-06-14  399  	if (state) {
fc167f62483325 Philippe Reynes 2014-06-14  400  		/* Start acquisition on cnvst */
fc167f62483325 Philippe Reynes 2014-06-14  401  		st->reg = MAX1027_SETUP_REG | MAX1027_CKS_MODE0 |
fc167f62483325 Philippe Reynes 2014-06-14  402  			  MAX1027_REF_MODE2;
fc167f62483325 Philippe Reynes 2014-06-14  403  		ret = spi_write(st->spi, &st->reg, 1);
fc167f62483325 Philippe Reynes 2014-06-14  404  		if (ret < 0)
fc167f62483325 Philippe Reynes 2014-06-14  405  			return ret;
fc167f62483325 Philippe Reynes 2014-06-14  406  
1e80dcadd79f6d Miquel Raynal   2021-09-21  407  		/*
1e80dcadd79f6d Miquel Raynal   2021-09-21  408  		 * Scan from chan 0 to the highest requested channel.
1e80dcadd79f6d Miquel Raynal   2021-09-21  409  		 * Include temperature on demand.
1e80dcadd79f6d Miquel Raynal   2021-09-21  410  		 */
1e80dcadd79f6d Miquel Raynal   2021-09-21  411  		st->reg = MAX1027_CONV_REG | MAX1027_SCAN_0_N;
1e80dcadd79f6d Miquel Raynal   2021-09-21 @412  		st->reg |= MAX1027_CHAN(fls(*indio_dev->active_scan_mask) - 2);
1e80dcadd79f6d Miquel Raynal   2021-09-21  413  		if (*indio_dev->active_scan_mask & MAX1X27_SCAN_MASK_TEMP)
1e80dcadd79f6d Miquel Raynal   2021-09-21  414  			st->reg |= MAX1027_TEMP;
1e80dcadd79f6d Miquel Raynal   2021-09-21  415  
fc167f62483325 Philippe Reynes 2014-06-14  416  		ret = spi_write(st->spi, &st->reg, 1);
fc167f62483325 Philippe Reynes 2014-06-14  417  		if (ret < 0)
fc167f62483325 Philippe Reynes 2014-06-14  418  			return ret;
fc167f62483325 Philippe Reynes 2014-06-14  419  	} else {
fc167f62483325 Philippe Reynes 2014-06-14  420  		/* Start acquisition on conversion register write */
fc167f62483325 Philippe Reynes 2014-06-14  421  		st->reg = MAX1027_SETUP_REG | MAX1027_CKS_MODE2	|
fc167f62483325 Philippe Reynes 2014-06-14  422  			  MAX1027_REF_MODE2;
fc167f62483325 Philippe Reynes 2014-06-14  423  		ret = spi_write(st->spi, &st->reg, 1);
fc167f62483325 Philippe Reynes 2014-06-14  424  		if (ret < 0)
fc167f62483325 Philippe Reynes 2014-06-14  425  			return ret;
fc167f62483325 Philippe Reynes 2014-06-14  426  	}
fc167f62483325 Philippe Reynes 2014-06-14  427  
fc167f62483325 Philippe Reynes 2014-06-14  428  	return 0;
fc167f62483325 Philippe Reynes 2014-06-14  429  }
fc167f62483325 Philippe Reynes 2014-06-14  430  

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

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 34184 bytes --]

             reply	other threads:[~2021-09-30 23:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-30 23:59 kernel test robot [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-11-06  9:20 drivers/iio/adc/max1027.c:412:14: warning: The result of the left shift is undefined because the left operand is negative [clang-analyzer-core.UndefinedBinaryOperatorResult] kernel test robot
2021-09-30  2:43 kernel test robot
2021-09-29  4:14 kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202110010706.x8xrbRyX-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=kbuild@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.