Skip to contentSkip to conversation

iio: mcp320x: Fix occasional incorrect readings

PATCH Superseded Michael Welling 2 participants 2 messages May 5, 2015 IIO

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: mcp320x: Fix occasional incorrect readings

Without the cacheline alignment, the readings will occasionally incorrectly return 0.

---
 drivers/iio/adc/mcp320x.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/mcp320x.c +1 -1
index efbfd12..46b98cf 100644
@@ -60,7 +60,7 @@ struct mcp320x {
 	struct spi_message msg;
 	struct spi_transfer transfer[2];
 
-	u8 tx_buf;
+	u8 tx_buf ____cacheline_aligned;
 	u8 rx_buf[2];
 
 	struct regulator *reg;
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 13 lines · Michael Welling

Without the cacheline alignment, the readings will occasionally incorrectly return 0.

---
  drivers/iio/adc/mcp320x.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/mcp320x.c +0 -0
index efbfd12..46b98cf 100644

drivers/iio/adc/mcp320x.c struct mcp320x { · line 64

Quoted 6 lines
drivers/iio/adc/mcp320x.c +1 -1
@@ -60,7 +60,7 @@ struct mcp320x {
  	struct spi_message msg;
  	struct spi_transfer transfer[2];
 
-	u8 tx_buf;
+	u8 tx_buf ____cacheline_aligned;
  	u8 rx_buf[2];

The buffers should probably be moved at the end, e.g. reg will still be on the same cacheline.

Quoted 2 lines
drivers/iio/adc/mcp320x.c +0 -0
  	struct regulator *reg;