Skip to contentSkip to conversation

iio: adis16475: fix deadlock on frequency set

PATCH Applied Nuno Sá 3 participants 3 messages Sep 20, 2021 – Sep 25, 2021

Subsystems (3)
lore
Share & tools
lore

Nuno Sá

author maintainer
#0 lore raw

PATCH 1/1 iio: adis16475: fix deadlock on frequency set

With commit 39c024b51b560
("iio: adis16475: improve sync scale mode handling"), two deadlocks were introduced:
1) The call to 'adis_write_reg_16()' was not changed to it's unlocked version.
2) The lock was not being released on the success path of the function.

This change fixes both these issues.

Fixes 39c024b51b560 ("iio: adis16475: improve sync scale mode handling")
---
 drivers/iio/imu/adis16475.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/imu/adis16475.c +2 -1
index eb48102f9424..287fff39a927 100644
@@ -353,10 +353,11 @@ static int adis16475_set_freq(struct adis16475 *st, const u32 freq)
 	if (dec > st->info->max_dec)
 		dec = st->info->max_dec;
 
-	ret = adis_write_reg_16(&st->adis, ADIS16475_REG_DEC_RATE, dec);
+	ret = __adis_write_reg_16(&st->adis, ADIS16475_REG_DEC_RATE, dec);
 	if (ret)
 		goto error;
 
+	adis_dev_unlock(&st->adis);
 	/*
 	 * If decimation is used, then gyro and accel data will have meaningful
 	 * bits on the LSB registers. This info is used on the trigger handler.
Signature · 1 line
2.33.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Nuno Sá

With commit 39c024b51b560
("iio: adis16475: improve sync scale mode handling"), two deadlocks were introduced:
1) The call to 'adis_write_reg_16()' was not changed to it's unlocked version.
2) The lock was not being released on the success path of the function.

This change fixes both these issues.

Quoted 26 lines
Fixes 39c024b51b560 ("iio: adis16475: improve sync scale mode handling")
---
 drivers/iio/imu/adis16475.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/imu/adis16475.c +2 -2
index eb48102f9424..287fff39a927 100644
@@ -353,10 +353,11 @@ static int adis16475_set_freq(struct adis16475 *st, const u32 freq)
        if (dec > st->info->max_dec)
                dec = st->info->max_dec;
 
-       ret = adis_write_reg_16(&st->adis, ADIS16475_REG_DEC_RATE, dec);
+       ret = __adis_write_reg_16(&st->adis, ADIS16475_REG_DEC_RATE, dec);
        if (ret)
                goto error;
 
+       adis_dev_unlock(&st->adis);
        /*
         * If decimation is used, then gyro and accel data will have meaningful
         * bits on the LSB registers. This info is used on the trigger handler.
--

2.33.0

maintainer Applied
#2 lore raw
Quoted 9 lines · On Mon, 20 Sep 2021 14:42:25 +0300 Alexandru Ardelean <[email protected]>…
Quoted 8 lines · Nuno Sá

With commit 39c024b51b560
("iio: adis16475: improve sync scale mode handling"), two deadlocks were introduced:
1) The call to 'adis_write_reg_16()' was not changed to it's unlocked version.
2) The lock was not being released on the success path of the function.

Quoted 4 lines
Quoted 2 lines

This change fixes both these issues.

Applied to the fixes-togreg branch of iio.git and marked for stable.

Thanks,

Jonathan

Quoted 27 lines
Quoted 27 lines
Fixes 39c024b51b560 ("iio: adis16475: improve sync scale mode handling")
---
 drivers/iio/imu/adis16475.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/imu/adis16475.c +2 -2
index eb48102f9424..287fff39a927 100644
@@ -353,10 +353,11 @@ static int adis16475_set_freq(struct adis16475 *st, const u32 freq)
        if (dec > st->info->max_dec)
                dec = st->info->max_dec;
 
-       ret = adis_write_reg_16(&st->adis, ADIS16475_REG_DEC_RATE, dec);
+       ret = __adis_write_reg_16(&st->adis, ADIS16475_REG_DEC_RATE, dec);
        if (ret)
                goto error;
 
+       adis_dev_unlock(&st->adis);
        /*
         * If decimation is used, then gyro and accel data will have meaningful
         * bits on the LSB registers. This info is used on the trigger handler.
--

2.33.0