diff mbox series

[08/13] iio: imu: st_lsm6dsx: grab conf mutex in st_lsm6dsx_write_event_config

Message ID b9761bf79a087f1699c5df049e9f2a10c9ad66ea.1570367532.git.lorenzo@kernel.org (mailing list archive)
State New, archived
Headers show
Series various st_lsm6dsx fixes and missing bits | expand

Commit Message

Lorenzo Bianconi Oct. 6, 2019, 1:22 p.m. UTC
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>
---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Jonathan Cameron Oct. 12, 2019, 12:23 p.m. UTC | #1
On Sun,  6 Oct 2019 15:22:02 +0200
Lorenzo Bianconi <lorenzo@kernel.org> wrote:

> 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>
applied.

> ---
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> index 023646762b4a..04231710ab9c 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> @@ -1604,7 +1604,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;
>
diff mbox series

Patch

diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
index 023646762b4a..04231710ab9c 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
@@ -1604,7 +1604,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;