
In stmicro_erase() correctly calculate the high byte of the sector address.
Signed-off-by: Gary Jennejohn garyj@denx.de --- drivers/mtd/spi/stmicro.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/drivers/mtd/spi/stmicro.c b/drivers/mtd/spi/stmicro.c index 9b910c1..b5808c5 100644 --- a/drivers/mtd/spi/stmicro.c +++ b/drivers/mtd/spi/stmicro.c @@ -281,7 +281,13 @@ int stmicro_erase(struct spi_flash *flash, u32 offset, size_t len)
ret = 0; for (actual = 0; actual < len; actual++) { - cmd[1] = (offset / sector_size) + actual; + /* + * Correctly calculate the high byte of the address. + * + * Note that the new code basically does what the + * Linux driver does. + */ + cmd[1] = ((offset + actual * sector_size) >> 16) & 0xff;
ret = spi_flash_cmd(flash->spi, CMD_M25PXX_WREN, NULL, 0); if (ret < 0) {