[PATCH 1/6] SPI: add ability to say we want a cs change after every transfer.

From: Jonathan Cameron
Date: Wed Sep 07 2011 - 12:13:43 EST


This allows a number of drivers to make use of utility functions
such spi_write_then_read as well as making use of regmap possible.

Signed-off-by: Jonathan Cameron <jic23@xxxxxxxxx>
---
drivers/spi/spi.c | 8 ++++++++
include/linux/spi/spi.h | 2 ++
2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 4d1b9f5..bee8aee 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -781,6 +781,14 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message)
}
}

+ if (spi->cs_between_transfers) {
+ struct spi_transfer *xfer;
+ list_for_each_entry(xfer, &message->transfers, transfer_list) {
+ if (!list_is_last(&xfer->transfer_list, &message->transfers))
+ xfer->cs_change = 1;
+ }
+ }
+
message->spi = spi;
message->status = -EINPROGRESS;
return master->transfer(spi, message);
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index bb4f5fb..f1e378d 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -90,6 +90,8 @@ struct spi_device {
void *controller_data;
char modalias[SPI_NAME_SIZE];

+ unsigned cs_between_transfers:1;
+
/*
* likely need more hooks for more protocol options affecting how
* the controller talks to each chip, like:
--
1.7.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/