On Mon, 31 Jan 2022 12:46:56 +0000 Mario TESI <mario.tesi@xxxxxx> wrote: > Tested-by: Mario Tesi <mario.tesi@xxxxxx> > ________________________________________ > Da: Lorenzo Bianconi <lorenzo@xxxxxxxxxx> > Inviato: lunedì 31 gennaio 2022 12:08 > A: jic23@xxxxxxxxxx > Cc: lorenzo.bianconi@xxxxxxxxxx; linux-iio@xxxxxxxxxxxxxxx; Mario TESI > Oggetto: [PATCH] iio: imu: st_lsm6dsx: wait for settling time in st_lsm6dsx_read_oneshot > > We need to wait for sensor settling time (~ 3/ODR) before reading data > in st_lsm6dsx_read_oneshot routine in order to avoid corrupted samples. > > Reported-by: Mario Tesi <mario.tesi@xxxxxx> > Signed-off-by: Lorenzo Bianconi <lorenzo@xxxxxxxxxx> Fixes tag? This definitely looks like stable material to me so we want a clear record of when the issue was introduced. Thanks, Jonathan > --- > drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c > index 727b4b6ac696..93f0c6bce502 100644 > --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c > +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c > @@ -1374,8 +1374,12 @@ static int st_lsm6dsx_read_oneshot(struct st_lsm6dsx_sensor *sensor, > if (err < 0) > return err; > > + /* > + * we need to wait for sensor settling time before > + * reading data in order to avoid corrupted samples > + */ > delay = 1000000000 / sensor->odr; > - usleep_range(delay, 2 * delay); > + usleep_range(3 * delay, 4 * delay); > > err = st_lsm6dsx_read_locked(hw, addr, &data, sizeof(data)); > if (err < 0) > -- > 2.34.1 >