Updated bank configuration code to more readable.

Signed-off-by: Jagannadha Sutradharudu Teki <jaga...@xilinx.com>
---
 drivers/mtd/spi/sf_probe.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c
index a5f3046..10d183d 100644
--- a/drivers/mtd/spi/sf_probe.c
+++ b/drivers/mtd/spi/sf_probe.c
@@ -217,21 +217,23 @@ static struct spi_flash *spi_flash_validate_params(struct 
spi_slave *spi,
 
        /* Configure the BAR - discover bank cmds and read current bank */
 #ifdef CONFIG_SPI_FLASH_BAR
-       u8 curr_bank = 0;
+       flash->bank_curr = 0;
        if (flash->size > SPI_FLASH_16MB_BOUN) {
-               flash->bank_read_cmd = (idcode[0] == 0x01) ?
-                                       CMD_BANKADDR_BRRD : CMD_EXTNADDR_RDEAR;
-               flash->bank_write_cmd = (idcode[0] == 0x01) ?
-                                       CMD_BANKADDR_BRWR : CMD_EXTNADDR_WREAR;
+               switch (idcode[0]) {
+               case SPI_FLASH_CFI_MFR_SPANSION:
+                       flash->bank_read_cmd = CMD_BANKADDR_BRRD;
+                       flash->bank_write_cmd = CMD_BANKADDR_BRWR;
+                       break;
+               default:
+                       flash->bank_read_cmd = CMD_EXTNADDR_RDEAR;
+                       flash->bank_write_cmd = CMD_EXTNADDR_WREAR;
+               }
 
                if (spi_flash_read_common(flash, &flash->bank_read_cmd, 1,
-                                         &curr_bank, 1)) {
-                       debug("SF: fail to read bank addr register\n");
+                                       &flash->bank_curr, 1)) {
+                       debug("SF: Fail to read bank addr register\n");
                        return NULL;
                }
-               flash->bank_curr = curr_bank;
-       } else {
-               flash->bank_curr = curr_bank;
        }
 #endif
 
-- 
1.8.3


_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to