Skip to contentSkip to conversation

spi-nor: Correct the logic to detect flash rw mode

PATCH Superseded Bin Meng 1 participant 1 message Feb 18, 2016

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

PATCH 1/1 spi-nor: Correct the logic to detect flash rw mode

spi->mode includes all available modes for operating on SPI flashes, and we should test each bit instead of a switch..case statement to make the detection logic correct.

---

 drivers/mtd/spi-nor/m25p80.c | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)
drivers/mtd/spi-nor/m25p80.c +5 -15
index 4e0a53c..9d17449 100644
@@ -178,26 +178,16 @@ static int m25p80_spi_nor(struct spi_nor *nor)
 		return ret;
 	}
 
-	switch (spi->mode) {
-	case SPI_RX_SLOW:
+	if (spi->mode & SPI_RX_SLOW)
 		nor->read_mode = SNOR_READ;
-		break;
-	case SPI_RX_DUAL:
+	else if (spi->mode & SPI_RX_DUAL)
 		nor->read_mode = SNOR_READ_1_1_2;
-		break;
-	case SPI_RX_QUAD:
+	else if (spi->mode & SPI_RX_QUAD)
 		nor->read_mode = SNOR_READ_1_1_4;
-		break;
-	}
-
-	switch (spi->mode) {
-	case SPI_TX_BYTE:
+	else if (spi->mode & SPI_TX_BYTE)
 		nor->mode = SNOR_WRITE_1_1_BYTE;
-		break;
-	case SPI_TX_QUAD:
+	else if (spi->mode & SPI_TX_QUAD)
 		nor->mode = SNOR_WRITE_1_1_4;
-		break;
-	}
 
 	nor->memory_map = spi->memory_map;
 	nor->max_write_size = spi->max_write_size;
Signature · 1 line
1.8.2.1