Skip to contentSkip to conversation

mtd_dataflash: unbreak erase support

PATCH In review Peter Korsgaard 2 participants 2 messages May 13, 2009 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd_dataflash: unbreak erase support

Commit 5b7f3a50 (fix dataflash 64-bit divisions) unfortunately introduced a typo. Erase addr and len were swapped in the pageaddr calculation, causing the wrong sectors to get erased.

Please consider for 2.6.29-stable as well.

---
 drivers/mtd/devices/mtd_dataflash.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/mtd/devices/mtd_dataflash.c +1 -1
index 62dee54..43976aa 100644
@@ -178,7 +178,7 @@ static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr)
 		/* Calculate flash page address; use block erase (for speed) if
 		 * we're at a block boundary and need to erase the whole block.
 		 */
-		pageaddr = div_u64(instr->len, priv->page_size);
+		pageaddr = div_u64(instr->addr, priv->page_size);
 		do_block = (pageaddr & 0x7) == 0 && instr->len >= blocksize;
 		pageaddr = pageaddr << priv->page_offset;
 
Signature · 1 line
1.6.2
Acked-by on v1 1/1
#1 lore raw
Quoted 16 lines · ext Peter Korsgaard

Commit 5b7f3a50 (fix dataflash 64-bit divisions) unfortunately introduced a typo. Erase addr and len were swapped in the pageaddr calculation, causing the wrong sectors to get erased.

Please consider for 2.6.29-stable as well.

---
 drivers/mtd/devices/mtd_dataflash.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/mtd/devices/mtd_dataflash.c +0 -0
index 62dee54..43976aa 100644

drivers/mtd/devices/mtd_dataflash.c static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr) · line 183

Quoted 7 lines
drivers/mtd/devices/mtd_dataflash.c +1 -1
@@ -178,7 +178,7 @@ static int dataflash_erase(struct mtd_info *mtd, struct erase_info *instr)
 		/* Calculate flash page address; use block erase (for speed) if
 		 * we're at a block boundary and need to erase the whole block.
 		 */
-		pageaddr = div_u64(instr->len, priv->page_size);
+		pageaddr = div_u64(instr->addr, priv->page_size);
 		do_block = (pageaddr & 0x7) == 0 && instr->len >= blocksize;
 		pageaddr = pageaddr << priv->page_offset;

Oh, sorry for that.

Signature · 2 lines
Best Regards,
Artem Bityutskiy (Артём Битюцкий)