Merge tag 'iio-fixes-for-5.2a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23...
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 20 May 2019 07:15:14 +0000 (09:15 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 20 May 2019 07:15:14 +0000 (09:15 +0200)
Jonathan writes:

First set of IIO fixes for the 5.2 cycle.

* ads124
  - Avoid a buffer overrun when setting an array to 0.
* ads8688
  - Don't use the pollfunc timestamp as it isn't set and would be wrong
    anyway for a device that does sampling on demand.
* ds4422
  - Fix masking on register used for chip verification. Wrong address
    was being read.
* mpu6050
  - Fix the fifo layout for ICM20602 to avoid underreading and hence failure
    to move on to the next record in the fifo.
* NPCM ADC
  - Make sure there is actually a valid regulator before reading its voltage.

* tag 'iio-fixes-for-5.2a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio:
  iio: adc: ti-ads8688: fix timestamp is not updated in buffer
  iio: dac: ds4422/ds4424 fix chip verification
  iio: imu: mpu6050: Fix FIFO layout for ICM20602
  iio: adc: ads124: avoid buffer overflow
  iio: adc: modify NPCM ADC read reference voltage

1  2 
drivers/iio/adc/ti-ads8688.c
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c

index f9461070a74af7400fe36932b20dd46465c9add7,7f16c77b99fb4aea62c902ceb05473012b3b9821..8cb7a20349820d2fbe4a4ea1238000e632a3fcfd
@@@ -397,7 -397,7 +397,7 @@@ static irqreturn_t ads8688_trigger_hand
        }
  
        iio_push_to_buffers_with_timestamp(indio_dev, buffer,
-                       pf->timestamp);
+                       iio_get_time_ns(indio_dev));
  
        iio_trigger_notify_done(indio_dev->trig);
  
@@@ -523,6 -523,6 +523,6 @@@ static struct spi_driver ads8688_drive
  };
  module_spi_driver(ads8688_driver);
  
 -MODULE_AUTHOR("Sean Nyekjaer <sean.nyekjaer@prevas.dk>");
 +MODULE_AUTHOR("Sean Nyekjaer <sean@geanix.dk>");
  MODULE_DESCRIPTION("Texas Instruments ADS8688 driver");
  MODULE_LICENSE("GPL v2");
index 6138a6d86afb7a62b5680215771a09e35af50623,385f14a4d5a79d34b794361883a0a2104b61231e..c2916d2d552cb5788c88aeeb340805d287c79f80
@@@ -471,7 -471,10 +471,10 @@@ inv_mpu6050_read_raw(struct iio_dev *in
                        return IIO_VAL_INT_PLUS_MICRO;
                case IIO_TEMP:
                        *val = 0;
-                       *val2 = INV_MPU6050_TEMP_SCALE;
+                       if (st->chip_type == INV_ICM20602)
+                               *val2 = INV_ICM20602_TEMP_SCALE;
+                       else
+                               *val2 = INV_MPU6050_TEMP_SCALE;
  
                        return IIO_VAL_INT_PLUS_MICRO;
                default:
        case IIO_CHAN_INFO_OFFSET:
                switch (chan->type) {
                case IIO_TEMP:
-                       *val = INV_MPU6050_TEMP_OFFSET;
+                       if (st->chip_type == INV_ICM20602)
+                               *val = INV_ICM20602_TEMP_OFFSET;
+                       else
+                               *val = INV_MPU6050_TEMP_OFFSET;
  
                        return IIO_VAL_INT;
                default:
@@@ -796,14 -802,12 +802,14 @@@ static const struct iio_mount_matrix 
  inv_get_mount_matrix(const struct iio_dev *indio_dev,
                     const struct iio_chan_spec *chan)
  {
 -      return &((struct inv_mpu6050_state *)iio_priv(indio_dev))->orientation;
 +      struct inv_mpu6050_state *data = iio_priv(indio_dev);
 +
 +      return &data->orientation;
  }
  
  static const struct iio_chan_spec_ext_info inv_ext_info[] = {
        IIO_MOUNT_MATRIX(IIO_SHARED_BY_TYPE, inv_get_mount_matrix),
 -      { },
 +      { }
  };
  
  #define INV_MPU6050_CHAN(_type, _channel2, _index)                    \
@@@ -847,6 -851,32 +853,32 @@@ static const struct iio_chan_spec inv_m
        INV_MPU6050_CHAN(IIO_ACCEL, IIO_MOD_Z, INV_MPU6050_SCAN_ACCL_Z),
  };
  
+ static const struct iio_chan_spec inv_icm20602_channels[] = {
+       IIO_CHAN_SOFT_TIMESTAMP(INV_ICM20602_SCAN_TIMESTAMP),
+       {
+               .type = IIO_TEMP,
+               .info_mask_separate = BIT(IIO_CHAN_INFO_RAW)
+                               | BIT(IIO_CHAN_INFO_OFFSET)
+                               | BIT(IIO_CHAN_INFO_SCALE),
+               .scan_index = INV_ICM20602_SCAN_TEMP,
+               .scan_type = {
+                               .sign = 's',
+                               .realbits = 16,
+                               .storagebits = 16,
+                               .shift = 0,
+                               .endianness = IIO_BE,
+                            },
+       },
+       INV_MPU6050_CHAN(IIO_ANGL_VEL, IIO_MOD_X, INV_ICM20602_SCAN_GYRO_X),
+       INV_MPU6050_CHAN(IIO_ANGL_VEL, IIO_MOD_Y, INV_ICM20602_SCAN_GYRO_Y),
+       INV_MPU6050_CHAN(IIO_ANGL_VEL, IIO_MOD_Z, INV_ICM20602_SCAN_GYRO_Z),
+       INV_MPU6050_CHAN(IIO_ACCEL, IIO_MOD_Y, INV_ICM20602_SCAN_ACCL_Y),
+       INV_MPU6050_CHAN(IIO_ACCEL, IIO_MOD_X, INV_ICM20602_SCAN_ACCL_X),
+       INV_MPU6050_CHAN(IIO_ACCEL, IIO_MOD_Z, INV_ICM20602_SCAN_ACCL_Z),
+ };
  /*
   * The user can choose any frequency between INV_MPU6050_MIN_FIFO_RATE and
   * INV_MPU6050_MAX_FIFO_RATE, but only these frequencies are matched by the
@@@ -1023,8 -1053,8 +1055,8 @@@ int inv_mpu_core_probe(struct regmap *r
  
        pdata = dev_get_platdata(dev);
        if (!pdata) {
 -              result = of_iio_read_mount_matrix(dev, "mount-matrix",
 -                                                &st->orientation);
 +              result = iio_read_mount_matrix(dev, "mount-matrix",
 +                                             &st->orientation);
                if (result) {
                        dev_err(dev, "Failed to retrieve mounting matrix %d\n",
                                result);
                indio_dev->name = name;
        else
                indio_dev->name = dev_name(dev);
-       indio_dev->channels = inv_mpu_channels;
-       indio_dev->num_channels = ARRAY_SIZE(inv_mpu_channels);
+       if (chip_type == INV_ICM20602) {
+               indio_dev->channels = inv_icm20602_channels;
+               indio_dev->num_channels = ARRAY_SIZE(inv_icm20602_channels);
+       } else {
+               indio_dev->channels = inv_mpu_channels;
+               indio_dev->num_channels = ARRAY_SIZE(inv_mpu_channels);
+       }
  
        indio_dev->info = &mpu_info;
        indio_dev->modes = INDIO_BUFFER_TRIGGERED;