Skip to contentSkip to conversation

atmel_spi.c - let transfers through if not changing bits_per_word

PATCH Applied Matthias Brugger 2 participants 2 messages Oct 13, 2010 – Oct 14, 2010

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

PATCH 1/1 atmel_spi.c - let transfers through if not changing bits_per_word

- bits_per_word option in spi_transfer are allowed if it does not change the csr register.

This is necessary for the driver in drivers/staging/iio/adis16260_core.c, as it uses this option.

---
 drivers/spi/atmel_spi.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
drivers/spi/atmel_spi.c +0 -0
index c4e0442..5c03a5b 100644
@@ -654,6 +654,8 @@ static int atmel_spi_transfer(struct spi_device

*spi, struct spi_message *msg)
struct spi_transfer *xfer;
unsigned long flags;
struct device *controller = spi->master->dev.parent;
+ u8 bits;
+ struct atmel_spi_device *asd;

as = spi_master_get_devdata(spi->master);

@@ -672,8 +674,18 @@ static int atmel_spi_transfer(struct spi_device *spi, struct spi_message *msg)
return -EINVAL;
}

+ if (xfer->bits_per_word) {
+ asd = spi->controller_state;
+ bits = (asd->csr >> 4) & 0xf;
+ if (bits != xfer->bits_per_word - 8) {
+ dev_dbg(&spi->dev, "you can't yet change "
+ "bit_per_word in transfers\n");
+ return -ENOPROTOOPT;
+ }
+ }
+
/* FIXME implement these protocol options!! */
- if (xfer->bits_per_word || xfer->speed_hz) {
+ if (xfer->speed_hz) {
dev_dbg(&spi->dev, "no protocol options yet\n"); return -ENOPROTOOPT;
}

Signature · 1 line
1.5.6.5
Applied
#1 lore raw
Quoted 7 lines · Matthias Brugger

- bits_per_word option in spi_transfer are allowed if it does not change the csr register.

This is necessary for the driver in drivers/staging/iio/adis16260_core.c, as it uses this option.

Applied, thanks.

However, the patch is line-wrap damaged and I needed to fix it up by hand. Please check your email client configuration.

g.

Quoted 41 lines
---
 drivers/spi/atmel_spi.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
drivers/spi/atmel_spi.c +13 -1
index c4e0442..5c03a5b 100644
@@ -654,6 +654,8 @@ static int atmel_spi_transfer(struct spi_device
 *spi, struct spi_message *msg)
 	struct spi_transfer	*xfer;
 	unsigned long		flags;
 	struct device		*controller = spi->master->dev.parent;
+	u8			bits;
+	struct atmel_spi_device	*asd;
 
 	as = spi_master_get_devdata(spi->master);
@@ -672,8 +674,18 @@ static int atmel_spi_transfer(struct spi_device
 *spi, struct spi_message *msg)
 			return -EINVAL;
 		}
 
+		if (xfer->bits_per_word) {
+			asd = spi->controller_state;
+			bits = (asd->csr >> 4) & 0xf;
+			if (bits != xfer->bits_per_word - 8) {
+				dev_dbg(&spi->dev, "you can't yet change "
+					 "bit_per_word in transfers\n");
+				return -ENOPROTOOPT;
+			}
+		}
+
 		/* FIXME implement these protocol options!! */
-		if (xfer->bits_per_word || xfer->speed_hz) {
+		if (xfer->speed_hz) {
 			dev_dbg(&spi->dev, "no protocol options yet\n");
 			return -ENOPROTOOPT;

}

Signature · 1 line
1.5.6.5