iio: imu: st_lsm6dsx: grab conf mutex in st_lsm6dsx_write_event_config
authorLorenzo Bianconi <lorenzo@kernel.org>
Sun, 6 Oct 2019 13:22:02 +0000 (15:22 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Tue, 15 Oct 2019 20:11:05 +0000 (21:11 +0100)
Always grub conf mutex in st_lsm6dsx_write_event_config since it can run
concurrently with FIFO configuration

Fixes: b5969abfa8b8 ("iio: imu: st_lsm6dsx: add motion events")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c

index a6d5a9e..0d5054a 100644 (file)
@@ -1619,7 +1619,9 @@ static int st_lsm6dsx_write_event_config(struct iio_dev *iio_dev,
        if (err < 0)
                return err;
 
+       mutex_lock(&hw->conf_lock);
        err = st_lsm6dsx_sensor_set_enable(sensor, state);
+       mutex_unlock(&hw->conf_lock);
        if (err < 0)
                return err;