Skip to content

Commit d11f14a

Browse files
jmaneyrol-invngregkh
authored andcommitted
iio: invensense: fix multiple odr switch when FIFO is off
commit ef5f5e7 upstream. When multiple ODR switch happens during FIFO off, the change could not be taken into account if you get back to previous FIFO on value. For example, if you run sensor buffer at 50Hz, stop, change to 200Hz, then back to 50Hz and restart buffer, data will be timestamped at 200Hz. This due to testing against mult and not new_mult. To prevent this, let's just run apply_odr automatically when FIFO is off. It will also simplify driver code. Update inv_mpu6050 and inv_icm42600 to delete now useless apply_odr. Fixes: 95444b9 ("iio: invensense: fix odr switching to same value") Cc: [email protected] Signed-off-by: Jean-Baptiste Maneyrol <[email protected]> Link: https://patch.msgid.link/20241021-invn-inv-sensors-timestamp-fix-switch-fifo-off-v2-1-39ffd43edcc4@tdk.com Signed-off-by: Jonathan Cameron <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent ed968a1 commit d11f14a

File tree

4 files changed

+4
-5
lines changed

4 files changed

+4
-5
lines changed

drivers/iio/common/inv_sensors/inv_sensors_timestamp.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ int inv_sensors_timestamp_update_odr(struct inv_sensors_timestamp *ts,
7070
if (mult != ts->mult)
7171
ts->new_mult = mult;
7272

73+
/* When FIFO is off, directly apply the new ODR */
74+
if (!fifo)
75+
inv_sensors_timestamp_apply_odr(ts, 0, 0, 0);
76+
7377
return 0;
7478
}
7579
EXPORT_SYMBOL_NS_GPL(inv_sensors_timestamp_update_odr, IIO_INV_SENSORS_TIMESTAMP);

drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ static int inv_icm42600_accel_update_scan_mode(struct iio_dev *indio_dev,
9999
const unsigned long *scan_mask)
100100
{
101101
struct inv_icm42600_state *st = iio_device_get_drvdata(indio_dev);
102-
struct inv_sensors_timestamp *ts = iio_priv(indio_dev);
103102
struct inv_icm42600_sensor_conf conf = INV_ICM42600_SENSOR_CONF_INIT;
104103
unsigned int fifo_en = 0;
105104
unsigned int sleep_temp = 0;
@@ -127,7 +126,6 @@ static int inv_icm42600_accel_update_scan_mode(struct iio_dev *indio_dev,
127126
}
128127

129128
/* update data FIFO write */
130-
inv_sensors_timestamp_apply_odr(ts, 0, 0, 0);
131129
ret = inv_icm42600_buffer_set_fifo_en(st, fifo_en | st->fifo.en);
132130

133131
out_unlock:

drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ static int inv_icm42600_gyro_update_scan_mode(struct iio_dev *indio_dev,
9999
const unsigned long *scan_mask)
100100
{
101101
struct inv_icm42600_state *st = iio_device_get_drvdata(indio_dev);
102-
struct inv_sensors_timestamp *ts = iio_priv(indio_dev);
103102
struct inv_icm42600_sensor_conf conf = INV_ICM42600_SENSOR_CONF_INIT;
104103
unsigned int fifo_en = 0;
105104
unsigned int sleep_gyro = 0;
@@ -127,7 +126,6 @@ static int inv_icm42600_gyro_update_scan_mode(struct iio_dev *indio_dev,
127126
}
128127

129128
/* update data FIFO write */
130-
inv_sensors_timestamp_apply_odr(ts, 0, 0, 0);
131129
ret = inv_icm42600_buffer_set_fifo_en(st, fifo_en | st->fifo.en);
132130

133131
out_unlock:

drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ int inv_mpu6050_prepare_fifo(struct inv_mpu6050_state *st, bool enable)
111111
if (enable) {
112112
/* reset timestamping */
113113
inv_sensors_timestamp_reset(&st->timestamp);
114-
inv_sensors_timestamp_apply_odr(&st->timestamp, 0, 0, 0);
115114
/* reset FIFO */
116115
d = st->chip_config.user_ctrl | INV_MPU6050_BIT_FIFO_RST;
117116
ret = regmap_write(st->map, st->reg->user_ctrl, d);

0 commit comments

Comments
 (0)