提交 3db22a09 编写于 作者: L Lorenzo Bianconi 提交者: Zheng Zengkai

iio: imu: st_lsm6dsx: wait for settling time in st_lsm6dsx_read_oneshot

stable inclusion
from stable-v5.10.103
commit eabcc609cb8accf16a5c53fd9b91a827854b1ca9
bugzilla: https://gitee.com/openeuler/kernel/issues/I56NE7

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=eabcc609cb8accf16a5c53fd9b91a827854b1ca9

--------------------------------

commit ea85bf90 upstream.

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: 290a6ce1 ("iio: imu: add support to lsm6dsx driver")
Reported-by: NMario Tesi <mario.tesi@st.com>
Tested-by: NMario Tesi <mario.tesi@st.com>
Signed-off-by: NLorenzo Bianconi <lorenzo@kernel.org>
Link: https://lore.kernel.org/r/b41ebda5535895298716c76d939f9f165fcd2d13.1644098120.git.lorenzo@kernel.org
Cc: <Stable@vger.kernel.org>
Signed-off-by: NJonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NYu Liao <liaoyu15@huawei.com>
Reviewed-by: NWei Li <liwei391@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 5f89bf79
......@@ -1558,8 +1558,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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册