Patchwork mtd_dataflash: unbreak erase support

login
register
mail settings
Submitter Peter Korsgaard
Date May 13, 2009, 12:12 p.m.
Message ID <1242216722-7262-1-git-send-email-jacmet@sunsite.dk>
Download mbox | patch
Permalink /patch/27153/
State New
Headers show

Comments

Peter Korsgaard - May 13, 2009, 12:12 p.m.
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.

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
---
 drivers/mtd/devices/mtd_dataflash.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Artem Bityutskiy - May 13, 2009, 12:16 p.m.
ext Peter Korsgaard wrote:
> 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.
> 
> Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
> ---
>  drivers/mtd/devices/mtd_dataflash.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/mtd/devices/mtd_dataflash.c b/drivers/mtd/devices/mtd_dataflash.c
> index 62dee54..43976aa 100644
> --- a/drivers/mtd/devices/mtd_dataflash.c
> +++ b/drivers/mtd/devices/mtd_dataflash.c
> @@ -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.

Acked-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>

Patch

diff --git a/drivers/mtd/devices/mtd_dataflash.c b/drivers/mtd/devices/mtd_dataflash.c
index 62dee54..43976aa 100644
--- a/drivers/mtd/devices/mtd_dataflash.c
+++ b/drivers/mtd/devices/mtd_dataflash.c
@@ -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;