]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
iio: imu: st_lsm6dsx: fix waitime for st_lsm6dsx i2c controller
authorLorenzo Bianconi <lorenzo@kernel.org>
Mon, 16 Sep 2019 22:01:29 +0000 (00:01 +0200)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 12 Nov 2019 17:47:13 +0000 (18:47 +0100)
BugLink: https://bugs.launchpad.net/bugs/1851550
[ Upstream commit fdb828e2c71a09bb9e865f41b015597c5f671705 ]

i2c controller available in st_lsm6dsx series performs i2c slave
configuration using accel clock as trigger.
st_lsm6dsx_shub_wait_complete routine is used to wait the controller has
carried out the requested configuration. However if the accel sensor is not
enabled we should not use its configured odr to estimate a proper timeout

Fixes: c91c1c844ebd ("iio: imu: st_lsm6dsx: add i2c embedded controller support")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Connor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c

index 66fbcd94642d42237476d537e2c5e563556be004..4c754a02717b36605094309067791b32d4f0157a 100644 (file)
@@ -92,9 +92,11 @@ static const struct st_lsm6dsx_ext_dev_settings st_lsm6dsx_ext_dev_table[] = {
 static void st_lsm6dsx_shub_wait_complete(struct st_lsm6dsx_hw *hw)
 {
        struct st_lsm6dsx_sensor *sensor;
+       u16 odr;
 
        sensor = iio_priv(hw->iio_devs[ST_LSM6DSX_ID_ACC]);
-       msleep((2000U / sensor->odr) + 1);
+       odr = (hw->enable_mask & BIT(ST_LSM6DSX_ID_ACC)) ? sensor->odr : 13;
+       msleep((2000U / odr) + 1);
 }
 
 /**