Skip to content

Commit bbaae0c

Browse files
jmaneyrol-invnjic23
authored andcommitted
iio: imu: inv_icm42600: fix timestamp reset
Timestamp reset is not done in the correct place. It must be done before enabling buffer. The reason is that interrupt timestamping is always happening when the chip is on, even if the corresponding sensor is off. When the sensor restarts, timestamp is wrong if you don't do a reset first. Fixes: ec74ae9 ("iio: imu: inv_icm42600: add accurate timestamping") Signed-off-by: Jean-Baptiste Maneyrol <[email protected]> Cc: <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 626d312 commit bbaae0c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/iio/imu/inv_icm42600/inv_icm42600_buffer.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,14 @@ static int inv_icm42600_buffer_preenable(struct iio_dev *indio_dev)
275275
{
276276
struct inv_icm42600_state *st = iio_device_get_drvdata(indio_dev);
277277
struct device *dev = regmap_get_device(st->map);
278+
struct inv_icm42600_timestamp *ts = iio_priv(indio_dev);
278279

279280
pm_runtime_get_sync(dev);
280281

282+
mutex_lock(&st->lock);
283+
inv_icm42600_timestamp_reset(ts);
284+
mutex_unlock(&st->lock);
285+
281286
return 0;
282287
}
283288

@@ -375,7 +380,6 @@ static int inv_icm42600_buffer_postdisable(struct iio_dev *indio_dev)
375380
struct device *dev = regmap_get_device(st->map);
376381
unsigned int sensor;
377382
unsigned int *watermark;
378-
struct inv_icm42600_timestamp *ts;
379383
struct inv_icm42600_sensor_conf conf = INV_ICM42600_SENSOR_CONF_INIT;
380384
unsigned int sleep_temp = 0;
381385
unsigned int sleep_sensor = 0;
@@ -385,11 +389,9 @@ static int inv_icm42600_buffer_postdisable(struct iio_dev *indio_dev)
385389
if (indio_dev == st->indio_gyro) {
386390
sensor = INV_ICM42600_SENSOR_GYRO;
387391
watermark = &st->fifo.watermark.gyro;
388-
ts = iio_priv(st->indio_gyro);
389392
} else if (indio_dev == st->indio_accel) {
390393
sensor = INV_ICM42600_SENSOR_ACCEL;
391394
watermark = &st->fifo.watermark.accel;
392-
ts = iio_priv(st->indio_accel);
393395
} else {
394396
return -EINVAL;
395397
}
@@ -417,8 +419,6 @@ static int inv_icm42600_buffer_postdisable(struct iio_dev *indio_dev)
417419
if (!st->fifo.on)
418420
ret = inv_icm42600_set_temp_conf(st, false, &sleep_temp);
419421

420-
inv_icm42600_timestamp_reset(ts);
421-
422422
out_unlock:
423423
mutex_unlock(&st->lock);
424424

0 commit comments

Comments
 (0)