[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1390317009-8292-4-git-send-email-geert@linux-m68k.org>
Date: Tue, 21 Jan 2014 16:10:08 +0100
From: Geert Uytterhoeven <geert@...ux-m68k.org>
To: Mark Brown <broonie@...nel.org>
Cc: linux-spi@...r.kernel.org, linux-kernel@...r.kernel.org,
Geert Uytterhoeven <geert+renesas@...ux-m68k.org>
Subject: [PATCH 4/5] spi: Check that Quad/Dual is half duplex
From: Geert Uytterhoeven <geert+renesas@...ux-m68k.org>
Quad and Dual SPI Transfers use all available data lines (incl. MOSI/MISO),
hence they must be half duplex. Add a check that verify that.
Signed-off-by: Geert Uytterhoeven <geert+renesas@...ux-m68k.org>
---
I think this check is done nowhere else. Please correct me if I missed it.
drivers/spi/spi.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 7f77f82bf95e..4afcdb4851fa 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -1672,6 +1672,7 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message)
/* check transfer tx/rx_nbits:
* 1. check the value matches one of single, dual and quad
* 2. check tx/rx_nbits match the mode in spi_device
+ * 3. check dual or quad is half duplex
*/
if (xfer->tx_buf) {
if (xfer->tx_nbits != SPI_NBITS_SINGLE &&
@@ -1684,6 +1685,8 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message)
if ((xfer->tx_nbits == SPI_NBITS_QUAD) &&
!(spi->mode & SPI_TX_QUAD))
return -EINVAL;
+ if (xfer->tx_nbits > SPI_NBITS_SINGLE && xfer->rx_buf)
+ return -EINVAL;
}
/* check transfer rx_nbits */
if (xfer->rx_buf) {
@@ -1697,6 +1700,8 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message)
if ((xfer->rx_nbits == SPI_NBITS_QUAD) &&
!(spi->mode & SPI_RX_QUAD))
return -EINVAL;
+ if (xfer->rx_nbits > SPI_NBITS_SINGLE && xfer->tx_buf)
+ return -EINVAL;
}
}
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists