Skip to contentSkip to conversation

Make use of adis lock helpers

PATCH In review Nuno Sá 2 participants 4 messages May 20, 2021 – May 22, 2021

Subsystems (2)
lore
Share & tools
lore

Nuno Sá

author maintainer
#0 lore raw

cover Make use of adis lock helpers

In [1], some helpers were added to the adis lib to make things a bit more neater when users need to use the device lock. Somehow, these two users were left "behind". Let's make things consistent and make them use the helpers.

[1]: https://patchwork.kernel.org/project/linux-iio/patch/[email protected]/

Nuno Sá (2):
iio: adis16260: make use of adis lock helpers
iio: adis16136: make use of adis lock helpers

 drivers/iio/gyro/adis16136.c | 15 ++++++---------
 drivers/iio/gyro/adis16260.c |  4 ++--
 2 files changed, 8 insertions(+), 11 deletions(-)
Signature · 1 line
2.31.1
author maintainer
#1 lore raw

PATCH 1/2 iio: adis16260: make use of adis lock helpers

Use the adis lib lock helpers to lock the device. This makes things consistent with other users of the library.

---
 drivers/iio/gyro/adis16260.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/gyro/adis16260.c +2 -2
index e7c9a3e31c45..56f930bbd341 100644
@@ -293,7 +293,7 @@ static int adis16260_write_raw(struct iio_dev *indio_dev,
 		addr = adis16260_addresses[chan->scan_index][1];
 		return adis_write_reg_16(adis, addr, val);
 	case IIO_CHAN_INFO_SAMP_FREQ:
-		mutex_lock(&adis->state_lock);
+		adis_dev_lock(adis);
 		if (spi_get_device_id(adis->spi)->driver_data)
 			t = 256 / val;
 		else
@@ -310,7 +310,7 @@ static int adis16260_write_raw(struct iio_dev *indio_dev,
 			adis->spi->max_speed_hz = ADIS16260_SPI_FAST;
 		ret = __adis_write_reg_8(adis, ADIS16260_SMPL_PRD, t);
 
-		mutex_unlock(&adis->state_lock);
+		adis_dev_unlock(adis);
 		return ret;
 	}
 	return -EINVAL;
Signature · 1 line
2.31.1
author maintainer
#2 lore raw

PATCH 2/2 iio: adis16136: make use of adis lock helpers

In reply to Nuno Sá

Use the adis lib lock helpers to lock the device. This makes things consistent with other users of the library.

---
 drivers/iio/gyro/adis16136.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/iio/gyro/adis16136.c +6 -9
index a11ae9db0d11..d248c8a4a924 100644
@@ -223,13 +223,12 @@ static ssize_t adis16136_read_frequency(struct device *dev,
 {
 	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
 	struct adis16136 *adis16136 = iio_priv(indio_dev);
-	struct mutex *slock = &adis16136->adis.state_lock;
 	unsigned int freq;
 	int ret;
 
-	mutex_lock(slock);
+	adis_dev_lock(&adis16136->adis);
 	ret = __adis16136_get_freq(adis16136, &freq);
-	mutex_unlock(slock);
+	adis_dev_unlock(&adis16136->adis);
 	if (ret)
 		return ret;
 
@@ -254,11 +253,10 @@ static const unsigned adis16136_3db_divisors[] = {
 static int adis16136_set_filter(struct iio_dev *indio_dev, int val)
 {
 	struct adis16136 *adis16136 = iio_priv(indio_dev);
-	struct mutex *slock = &adis16136->adis.state_lock;
 	unsigned int freq;
 	int i, ret;
 
-	mutex_lock(slock);
+	adis_dev_lock(&adis16136->adis);
 	ret = __adis16136_get_freq(adis16136, &freq);
 	if (ret)
 		goto out_unlock;
@@ -270,7 +268,7 @@ static int adis16136_set_filter(struct iio_dev *indio_dev, int val)
 
 	ret = __adis_write_reg_16(&adis16136->adis, ADIS16136_REG_AVG_CNT, i);
 out_unlock:
-	mutex_unlock(slock);
+	adis_dev_unlock(&adis16136->adis);
 
 	return ret;
 }
@@ -278,12 +276,11 @@ static int adis16136_set_filter(struct iio_dev *indio_dev, int val)
 static int adis16136_get_filter(struct iio_dev *indio_dev, int *val)
 {
 	struct adis16136 *adis16136 = iio_priv(indio_dev);
-	struct mutex *slock = &adis16136->adis.state_lock;
 	unsigned int freq;
 	uint16_t val16;
 	int ret;
 
-	mutex_lock(slock);
+	adis_dev_lock(&adis16136->adis);
 
 	ret = __adis_read_reg_16(&adis16136->adis, ADIS16136_REG_AVG_CNT,
 				 &val16);
@@ -297,7 +294,7 @@ static int adis16136_get_filter(struct iio_dev *indio_dev, int *val)
 	*val = freq / adis16136_3db_divisors[val16 & 0x07];
 
 err_unlock:
-	mutex_unlock(slock);
+	adis_dev_unlock(&adis16136->adis);
 
 	return ret ? ret : IIO_VAL_INT;
 }
Signature · 1 line
2.31.1
maintainer
#3 lore raw
In reply to Nuno Sá
Quoted 7 lines · On Thu, 20 May 2021 13:59:07 +0200 Nuno Sá <[email protected]> wrote:

In [1], some helpers were added to the adis lib to make things a bit more neater when users need to use the device lock. Somehow, these two users were left "behind". Let's make things consistent and make them use the helpers.

[1]: https://patchwork.kernel.org/project/linux-iio/patch/[email protected]/

Quoted 8 lines

Nuno Sá (2):
iio: adis16260: make use of adis lock helpers
iio: adis16136: make use of adis lock helpers

 drivers/iio/gyro/adis16136.c | 15 ++++++---------
 drivers/iio/gyro/adis16260.c |  4 ++--
 2 files changed, 8 insertions(+), 11 deletions(-)

Applied to the togreg branch of iio.git and pushed out as testing for all the normal reasons.

Thanks,

Jonathan