spi-nor: Correct the logic to detect flash rw mode
Subsystems (2)
PATCH v2 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.
Signed-off-by Bin Meng <[email protected]>
---
Changes in v2:
- Write mode detection should not be in a 'else' branch
drivers/mtd/spi-nor/m25p80.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-)
drivers/mtd/spi-nor/m25p80.c +5 -14
@@ -178,26 +178,17 @@ 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 : +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