Patchwork [1/2] spi: dual and quad support(add single macro)

login
register
mail settings
Submitter 王宇航
Date Aug. 30, 2013, 10:05 a.m.
Message ID <1377857110-6882-1-git-send-email-wangyuhang2014@gmail.com>
Download mbox | patch
Permalink /patch/271212/
State New
Headers show

Comments

王宇航 - Aug. 30, 2013, 10:05 a.m.
fix using default value to specify single mode in patch:
commit id:f477b7fb13df2b843997559ff34e87d054ba6538

Using mode & ~(DUAL | QUAD) to specify SINGLE mode, instead
of using default value in mode. Which means if select neither
DUAL nor QUAD, SINGLE will be in use.

Signed-off-by: wangyuhang <wangyuhang2014@gmail.com>
---
 drivers/spi/spi.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Patch

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 8d191f2..6653913 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -872,10 +872,15 @@  static void of_register_spi_devices(struct spi_master *master)
 		/* Device DUAL/QUAD mode */
 		prop = of_get_property(nc, "spi-tmax-nbits", &len);
 		if (!prop || len < sizeof(*prop)) {
-			/* set tx mode in SINGLE as default */
+			/*
+			 * set tx mode in SINGLE as default
+			 * if select neither DUAL nor QUAD, regarded as single.
+			 */
+			spi->mode &= ~(SPI_TX_DUAL | SPI_TX_QUAD);
 		} else {
 			switch (be32_to_cpup(prop)) {
 			case SPI_NBITS_SINGLE:
+				spi->mode &= ~(SPI_TX_DUAL | SPI_TX_QUAD);
 				break;
 			case SPI_NBITS_DUAL:
 				spi->mode |= SPI_TX_DUAL;
@@ -893,9 +898,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_DUAL | SPI_RX_QUAD);
 		} else {
 			switch (be32_to_cpup(prop)) {
 			case SPI_NBITS_SINGLE:
+				spi->mode &= ~(SPI_RX_DUAL | SPI_RX_QUAD);
 				break;
 			case SPI_NBITS_DUAL:
 				spi->mode |= SPI_RX_DUAL;