clean_bar() function selecting bank zero but not setting the
flash current bank to zero. After erase operation, bank zero is selected
but the flash current bank is pointing to bank one. So, during
write operation, while trying to write bank one, it actually writes in
bank zero.
This patch fixed this issue by setting the current bank of flash
to zero after doing clear_bar() after erase, write and read operations.
Signed-off-by: Vipul Kumar <vipul.kumar@xilinx.com>
Signed-off-by: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
static int clean_bar(struct spi_flash *flash)
{
u8 cmd, bank_sel = 0;
+ int ret;
if (flash->bank_curr == 0)
return 0;
cmd = flash->bank_write_cmd;
- return spi_flash_write_common(flash, &cmd, 1, &bank_sel, 1);
+ ret = spi_flash_write_common(flash, &cmd, 1, &bank_sel, 1);
+ if (ret) {
+ debug("SF: fail to write bank register\n");
+ return ret;
+ }
+
+ flash->bank_curr = bank_sel;
+
+ return ret;
}
static int write_bar(struct spi_flash *flash, u32 offset)