@@ -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;
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 <bmeng.cn@gmail.com> --- drivers/mtd/spi-nor/m25p80.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-)