Patchwork spi: dual and quad support(add single macro)

login
register
mail settings
Submitter 王宇航
Date Aug. 28, 2013, 1 a.m.
Message ID <1377651642-3988-1-git-send-email-wangyuhang2014@gmail.com>
Download mbox | patch
Permalink /patch/270308/
State New
Headers show

Comments

王宇航 - Aug. 28, 2013, 1 a.m.
fix using default value to specify SINGLE mode in patch:
commit id:f477b7fb13df2b843997559ff34e87d054ba6538

Add SPI_TX_SINGLE and SPI_RX_SINGLE to specify SINGLE mode.

Signed-off-by: wangyuhang <wangyuhang2014@gmail.com>
---
 drivers/spi/spi.c       |    4 ++++
 include/linux/spi/spi.h |    4 ++++
 2 files changed, 8 insertions(+)

Patch

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 8d191f2..dbcd406 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -873,9 +873,11 @@  static void of_register_spi_devices(struct spi_master *master)
 		prop = of_get_property(nc, "spi-tmax-nbits", &len);
 		if (!prop || len < sizeof(*prop)) {
 			/* set tx mode in SINGLE as default */
+			spi->mode &= SPI_TX_SINGLE;
 		} else {
 			switch (be32_to_cpup(prop)) {
 			case SPI_NBITS_SINGLE:
+				spi->mode &= SPI_TX_SINGLE;
 				break;
 			case SPI_NBITS_DUAL:
 				spi->mode |= SPI_TX_DUAL;
@@ -893,9 +895,11 @@  static void of_register_spi_devices(struct spi_master *master)
 		prop = of_get_property(nc, "spi-rmax-nbits", &len);
 		if (!prop || len < sizeof(*prop)) {
 			/* set rx mode in SINGLE as default */
+			spi->mode &= SPI_RX_SINGLE;
 		} else {
 			switch (be32_to_cpup(prop)) {
 			case SPI_NBITS_SINGLE:
+				spi->mode &= SPI_RX_SINGLE;
 				break;
 			case SPI_NBITS_DUAL:
 				spi->mode |= SPI_RX_DUAL;
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index ccd7840..faa138c 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -89,8 +89,12 @@  struct spi_device {
 #define	SPI_READY	0x80			/* slave pulls low to pause */
 #define	SPI_TX_DUAL	0x100			/* transmit with 2 wires */
 #define	SPI_TX_QUAD	0x200			/* transmit with 4 wires */
+/* transmit with 1 wire(not using dual-tx and quad-tx) */
+#define	SPI_TX_SINGLE	~(SPI_TX_DUAL | SPI_TX_QUAD)
 #define	SPI_RX_DUAL	0x400			/* receive with 2 wires */
 #define	SPI_RX_QUAD	0x800			/* receive with 4 wires */
+/* receive with 1 wire(not using dual-rx and quad-rx) */
+#define	SPI_RX_SINGLE	~(SPI_RX_DUAL | SPI_RX_QUAD)
 	u8			bits_per_word;
 	int			irq;
 	void			*controller_state;