[U-Boot] [PATCH v2] spi-nor: Correct the logic to detect flash rw mode
Bin Meng
bmeng.cn at gmail.com
Thu Feb 18 06:25:45 CET 2016
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 at gmail.com>
---
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(-)
diff --git a/drivers/mtd/spi-nor/m25p80.c b/drivers/mtd/spi-nor/m25p80.c
index 4e0a53c..8edc481 100644
--- a/drivers/mtd/spi-nor/m25p80.c
+++ b/drivers/mtd/spi-nor/m25p80.c
@@ -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;
--
1.8.2.1
More information about the U-Boot
mailing list