CC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Miquel Raynal <[email protected]>
CC: 0day robot <[email protected]>

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:   6 weeks ago
:::::: branch date: 6 weeks ago
:::::: commit date: 6 weeks 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 <[email protected]>


clang-analyzer warnings: (new ones prefixed by >>)
           info.offset = plane << fls(nand->memorg.pagesize);
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/mtd/nand/spi/core.c:850:22: note: The result of the left shift is 
undefined due to shifting by '32', which is greater or equal to the width of 
type 'unsigned int'
           info.offset = plane << fls(nand->memorg.pagesize);
                               ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~
   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/usb/core/message.c:1709:2: warning: Value stored to 'retval' is 
never read [clang-analyzer-deadcode.DeadStores]
           retval = 0;
           ^        ~
   drivers/usb/core/message.c:1709:2: note: Value stored to 'retval' is never 
read
           retval = 0;
           ^        ~
   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/usb/core/driver.c:1675:2: warning: Value stored to 'status' is never 
read [clang-analyzer-deadcode.DeadStores]
           status = pm_runtime_put_sync_autosuspend(&udev->dev);
           ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/usb/core/driver.c:1675:2: note: Value stored to 'status' is never 
read
           status = pm_runtime_put_sync_autosuspend(&udev->dev);
           ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/usb/core/driver.c:1737:2: warning: Value stored to 'status' is never 
read [clang-analyzer-deadcode.DeadStores]
           status = pm_runtime_put_sync(&intf->dev);
           ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/usb/core/driver.c:1737:2: note: Value stored to 'status' is never 
read
           status = pm_runtime_put_sync(&intf->dev);
           ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/usb/core/driver.c:1765:2: warning: Value stored to 'status' is never 
read [clang-analyzer-deadcode.DeadStores]
           status = pm_runtime_put(&intf->dev);
           ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/usb/core/driver.c:1765:2: note: Value stored to 'status' is never 
read
           status = pm_runtime_put(&intf->dev);
           ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~
   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.
   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.
   8 warnings generated.
   drivers/usb/core/file.c:160:6: warning: Value stored to 'minor_base' during 
its initialization is never read [clang-analyzer-deadcode.DeadStores]
           int minor_base = class_driver->minor_base;
               ^~~~~~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/usb/core/file.c:160:6: note: Value stored to 'minor_base' during its 
initialization is never read
           int minor_base = class_driver->minor_base;
               ^~~~~~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~
   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.
   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.
   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.
   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.
   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.
   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.
   13 warnings generated.
   drivers/gpu/drm/amd/amdgpu/dce_v10_0.c:1259:3: warning: Value stored to 
'tmp' is never read [clang-analyzer-deadcode.DeadStores]
                   tmp = REG_SET_FIELD(0, 
AZALIA_F0_CODEC_PIN_CONTROL_RESPONSE_LIPSYNC,
                   ^
   drivers/gpu/drm/amd/amdgpu/dce_v10_0.c:1259:3: note: Value stored to 'tmp' 
is never read
   drivers/gpu/drm/amd/amdgpu/dce_v10_0.c:1264:3: warning: Value stored to 
'tmp' is never read [clang-analyzer-deadcode.DeadStores]
                   tmp = REG_SET_FIELD(0, 
AZALIA_F0_CODEC_PIN_CONTROL_RESPONSE_LIPSYNC,
                   ^
   drivers/gpu/drm/amd/amdgpu/dce_v10_0.c:1264:3: note: Value stored to 'tmp' 
is never read
   drivers/gpu/drm/amd/amdgpu/dce_v10_0.c:2970:3: warning: Value stored to 
'tmp' is never read [clang-analyzer-deadcode.DeadStores]
                   tmp = RREG32(mmSRBM_SOFT_RESET);
                   ^
   drivers/gpu/drm/amd/amdgpu/dce_v10_0.c:2970:3: note: Value stored to 'tmp' 
is never read
   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.
   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.
   9 warnings generated.
   drivers/w1/slaves/w1_therm.c:1252:5: warning: Value stored to 'ret' is never 
read [clang-analyzer-deadcode.DeadStores]
                                   ret = -EIO;
                                   ^     ~~~~
   drivers/w1/slaves/w1_therm.c:1252:5: note: Value stored to 'ret' is never 
read
                                   ret = -EIO;
                                   ^     ~~~~
   drivers/w1/slaves/w1_therm.c:1799:2: warning: Call to function 'strcpy' is 
insecure as it does not provide bounding of the memory buffer. Replace 
unbounded copy functions with analogous functions that support length arguments 
such as 'strlcpy'. CWE-119 [clang-analyzer-security.insecureAPI.strcpy]
           strcpy(p_args, buf);
           ^~~~~~
   drivers/w1/slaves/w1_therm.c:1799:2: note: Call to function 'strcpy' is 
insecure as it does not provide bounding of the memory buffer. Replace 
unbounded copy functions with analogous functions that support length arguments 
such as 'strlcpy'. CWE-119
           strcpy(p_args, buf);
           ^~~~~~
   drivers/w1/slaves/w1_therm.c:2090:22: warning: The right operand of '==' is 
a garbage value [clang-analyzer-core.UndefinedBinaryOperatorResult]
                   if (sl->reg_num.id == reg_num->id)
                                      ^  ~~~~~~~~~~~
   drivers/w1/slaves/w1_therm.c:2067:6: note: Assuming the condition is false
           if (w1_reset_bus(sl->master))
               ^~~~~~~~~~~~~~~~~~~~~~~~
   drivers/w1/slaves/w1_therm.c:2067:2: note: Taking false branch
           if (w1_reset_bus(sl->master))
           ^
   drivers/w1/slaves/w1_therm.c:2077:6: note: Assuming 'ack' is equal to 
W1_42_SUCCESS_CONFIRM_BYTE
           if (ack != W1_42_SUCCESS_CONFIRM_BYTE)
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/w1/slaves/w1_therm.c:2077:2: note: Taking false branch
           if (ack != W1_42_SUCCESS_CONFIRM_BYTE)
           ^
   drivers/w1/slaves/w1_therm.c:2081:2: note: Loop condition is true.  Entering 
loop body
           for (i = 0; i <= 64; i++) {
           ^
   drivers/w1/slaves/w1_therm.c:2082:7: note: Assuming the condition is false
                   if (w1_reset_bus(sl->master))
                       ^~~~~~~~~~~~~~~~~~~~~~~~
   drivers/w1/slaves/w1_therm.c:2082:3: note: Taking false branch
                   if (w1_reset_bus(sl->master))
                   ^
   drivers/w1/slaves/w1_therm.c:2088:7: note: Assuming field 'family' is not 
equal to W1_42_FINISHED_BYTE
                   if (reg_num->family == W1_42_FINISHED_BYTE)
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/w1/slaves/w1_therm.c:2088:3: note: Taking false branch
                   if (reg_num->family == W1_42_FINISHED_BYTE)
                   ^
   drivers/w1/slaves/w1_therm.c:2090:22: note: The right operand of '==' is a 
garbage value
                   if (sl->reg_num.id == reg_num->id)
                                      ^  ~~~~~~~~~~~
   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.
   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.
   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.
   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.
   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.
   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.
   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.

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/[email protected]

Attachment: .config.gz
Description: application/gzip

_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to