Skip to content

Commit fe0b980

Browse files
LorenzoBianconijic23
authored andcommitted
iio: imu: st_lsm6dsx: set 10ms as min shub slave timeout
Set 10ms as minimum i2c slave configuration timeout since st_lsm6dsx relies on accel ODR for i2c master clock and at high sample rates (e.g. 833Hz or 416Hz) the slave sensor occasionally may need more cycles than i2c master timeout (2s/833Hz + 1 ~ 3ms) to apply the configuration resulting in an uncomplete slave configuration and a constant reading from the i2c slave connected to st_lsm6dsx i2c master. Fixes: 8f9a524 ("iio: imu: st_lsm6dsx: enable 833Hz sample frequency for tagged sensors") Fixes: c91c1c8 ("iio: imu: st_lsm6dsx: add i2c embedded controller support") Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Cc: <Stable@vger.kernel.org> Link: https://lore.kernel.org/r/a69c8236bf16a1569966815ed71710af2722ed7d.1604247274.git.lorenzo@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 271b339 commit fe0b980

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,13 @@ static const struct st_lsm6dsx_ext_dev_settings st_lsm6dsx_ext_dev_table[] = {
156156
static void st_lsm6dsx_shub_wait_complete(struct st_lsm6dsx_hw *hw)
157157
{
158158
struct st_lsm6dsx_sensor *sensor;
159-
u32 odr;
159+
u32 odr, timeout;
160160

161161
sensor = iio_priv(hw->iio_devs[ST_LSM6DSX_ID_ACC]);
162162
odr = (hw->enable_mask & BIT(ST_LSM6DSX_ID_ACC)) ? sensor->odr : 12500;
163-
msleep((2000000U / odr) + 1);
163+
/* set 10ms as minimum timeout for i2c slave configuration */
164+
timeout = max_t(u32, 2000000U / odr + 1, 10);
165+
msleep(timeout);
164166
}
165167

166168
/*

0 commit comments

Comments
 (0)