[U-Boot] Subject: [U-BOOT] [PATCH] In stmicro_erase() correctly calculate the high byte of the sector address.

Gary Jennejohn garyj at denx.de
Wed Nov 11 14:40:41 CET 2009


In stmicro_erase() correctly calculate the high byte of the sector address.

Signed-off-by: Gary Jennejohn <garyj at 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) {
-- 
1.6.2.5

---
Gary Jennejohn
*********************************************************************
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
*********************************************************************


More information about the U-Boot mailing list