Skip to contentSkip to conversation

Proposal for meter ade* patches

PATCH In review Gargi Sharma 2 participants 2 messages Mar 25, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Proposal for meter ade* patches

The driver needs to insure atomicity during frequency changes of bus and device. The iiodev->mlock as used was not doing that. Replace it with the drivers existing buffer lock and execute spi_write directly.

---
 drivers/staging/iio/meter/ade7754.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/staging/iio/meter/ade7754.c +6 -3
index c8d2d4c..48339e9a 100644
@@ -513,7 +513,7 @@ static ssize_t ade7754_write_frequency(struct device *dev,
 	if (!val)
 		return -EINVAL;
 
-	mutex_lock(&indio_dev->mlock);
+	mutex_lock(&st->buf_lock);
 
 	t = 26000 / val;
 	if (t > 0)
@@ -531,10 +531,13 @@ static ssize_t ade7754_write_frequency(struct device *dev,
 	reg &= ~(3 << 3);
 	reg |= t << 3;
 
-	ret = ade7754_spi_write_reg_8(dev, ADE7754_WAVMODE, reg);
+	st->tx[0] = ADE7754_WRITE_REG(ADE7754_WAVMODE);
+	st->tx[1] = reg;
+
+	ret = spi_write(st->us, st->tx, 2);
 
 out:
-	mutex_unlock(&indio_dev->mlock);
+	mutex_unlock(&st->buf_lock);
 
 	return ret ? ret : len;
 }
Signature · 1 line
2.7.4
#1 lore raw
Quoted 6 lines · Gargi Sharma

The driver needs to insure atomicity during frequency changes of bus and device. The iiodev->mlock as used was not doing that. Replace it with the drivers existing buffer lock and execute spi_write directly.

Hi Gargi,

It's certainly a clean, simple patch! It's good that you're running it by Sayli, Simran, and Arushi. Some consensus that this flavor of fix will work in their drivers would be good before forwarding it on for 'official' review.

An RFC tag might have been appropriate here, but no worries now. It's only in our Outreachy tree.

alisons

Quoted 36 lines
---
 drivers/staging/iio/meter/ade7754.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/staging/iio/meter/ade7754.c +6 -3
index c8d2d4c..48339e9a 100644
@@ -513,7 +513,7 @@ static ssize_t ade7754_write_frequency(struct device *dev,
 	if (!val)
 		return -EINVAL;
 
-	mutex_lock(&indio_dev->mlock);
+	mutex_lock(&st->buf_lock);
 
 	t = 26000 / val;
 	if (t > 0)
@@ -531,10 +531,13 @@ static ssize_t ade7754_write_frequency(struct device *dev,
 	reg &= ~(3 << 3);
 	reg |= t << 3;
 
-	ret = ade7754_spi_write_reg_8(dev, ADE7754_WAVMODE, reg);
+	st->tx[0] = ADE7754_WRITE_REG(ADE7754_WAVMODE);
+	st->tx[1] = reg;
+
+	ret = spi_write(st->us, st->tx, 2);
 
 out:
-	mutex_unlock(&indio_dev->mlock);
+	mutex_unlock(&st->buf_lock);
 
 	return ret ? ret : len;
 }
Signature · 1 line
2.7.4