aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/spilib.c
diff options
context:
space:
mode:
authorRui Miguel Silva <rui.silva@linaro.org>2016-05-16 10:33:21 +0100
committerGreg Kroah-Hartman <gregkh@google.com>2016-05-16 20:02:58 -0700
commit3a238fc7844f93c799283d8b822178af9638ff0c (patch)
treeba91a6f0908155ea222c59e9bbbe39e078b0f56b /drivers/staging/greybus/spilib.c
parentgreybus: spi: rename rdwr field to xfer_flags (diff)
downloadlinux-dev-3a238fc7844f93c799283d8b822178af9638ff0c.tar.xz
linux-dev-3a238fc7844f93c799283d8b822178af9638ff0c.zip
greybus: spi: add inprogress bit to xfer_flags
When a SPI transfer needs to be split by more than one greybus spi transfer operation, we need to indicate it so the controller can handle the chip select lines correctly. Add a new bit to indicate it, GB_SPI_XFER_INPROGRESS, and create an helper function to calculate when the transfer is done. As we need this information also in other places. Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/spilib.c')
-rw-r--r--drivers/staging/greybus/spilib.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/staging/greybus/spilib.c b/drivers/staging/greybus/spilib.c
index 9eecbf391259..79ae044b78f3 100644
--- a/drivers/staging/greybus/spilib.c
+++ b/drivers/staging/greybus/spilib.c
@@ -102,6 +102,17 @@ static void clean_xfer_state(struct gb_spilib *spi)
spi->op_timeout = 0;
}
+static bool is_last_xfer_done(struct gb_spilib *spi)
+{
+ struct spi_transfer *last_xfer = spi->last_xfer;
+
+ if ((spi->tx_xfer_offset + spi->last_xfer_size == last_xfer->len) ||
+ (spi->rx_xfer_offset + spi->last_xfer_size == last_xfer->len))
+ return true;
+
+ return false;
+}
+
static int setup_next_xfer(struct gb_spilib *spi, struct spi_message *msg)
{
struct spi_transfer *last_xfer = spi->last_xfer;
@@ -113,8 +124,7 @@ static int setup_next_xfer(struct gb_spilib *spi, struct spi_message *msg)
* if we transferred all content of the last transfer, reset values and
* check if this was the last transfer in the message
*/
- if ((spi->tx_xfer_offset + spi->last_xfer_size == last_xfer->len) ||
- (spi->rx_xfer_offset + spi->last_xfer_size == last_xfer->len)) {
+ if (is_last_xfer_done(spi)) {
spi->tx_xfer_offset = 0;
spi->rx_xfer_offset = 0;
spi->op_timeout = 0;
@@ -265,6 +275,8 @@ static struct gb_operation *gb_spi_operation_create(struct gb_spilib *spi,
gb_xfer->xfer_flags |= GB_SPI_XFER_READ;
if (xfer == spi->last_xfer) {
+ if (!is_last_xfer_done(spi))
+ gb_xfer->xfer_flags |= GB_SPI_XFER_INPROGRESS;
msg->state = GB_SPI_STATE_OP_DONE;
continue;
}