* [PATCH v2] iio: imu: st_lsm6dsx: wait for settling time in st_lsm6dsx_read_oneshot
@ 2022-02-05 21:57 Lorenzo Bianconi
2022-02-06 15:32 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Lorenzo Bianconi @ 2022-02-05 21:57 UTC (permalink / raw)
To: jic23; +Cc: lorenzo.bianconi, linux-iio, mario.tesi
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.
Fixes: 290a6ce11d938 ("iio: imu: add support to lsm6dsx driver")
Reported-by: Mario Tesi <mario.tesi@st.com>
Tested-by: Mario Tesi <mario.tesi@st.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
Changes since v1:
- add missing Fixes tag.
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] iio: imu: st_lsm6dsx: wait for settling time in st_lsm6dsx_read_oneshot
2022-02-05 21:57 [PATCH v2] iio: imu: st_lsm6dsx: wait for settling time in st_lsm6dsx_read_oneshot Lorenzo Bianconi
@ 2022-02-06 15:32 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2022-02-06 15:32 UTC (permalink / raw)
To: Lorenzo Bianconi; +Cc: lorenzo.bianconi, linux-iio, mario.tesi
On Sat, 5 Feb 2022 22:57:42 +0100
Lorenzo Bianconi <lorenzo@kernel.org> wrote:
> 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.
>
> Fixes: 290a6ce11d938 ("iio: imu: add support to lsm6dsx driver")
> Reported-by: Mario Tesi <mario.tesi@st.com>
> Tested-by: Mario Tesi <mario.tesi@st.com>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Thanks for the quick update.
Applied to the fixes-togreg branch of iio.git and marked for stable.
> ---
> Changes since v1:
> - add missing Fixes tag.
> ---
> 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)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-02-06 15:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-05 21:57 [PATCH v2] iio: imu: st_lsm6dsx: wait for settling time in st_lsm6dsx_read_oneshot Lorenzo Bianconi
2022-02-06 15:32 ` Jonathan Cameron
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.