[PATCH] [MTD] Correct partition failed erase address

David Woodhouse dwmw2 at infradead.org
Thu Mar 8 05:27:50 EST 2007


On Thu, 2007-03-08 at 12:20 +0200, Adrian Hunter wrote:
> If an erase operation fails, the address at which the
> failure occurred is returned by the driver.  The MTD
> partition must adjust this address (by subtracting the
> partition offset) before returning to the caller.
> This was not happening, which caused JFFS2 to mark
> the wrong block bad!
> 
> Signed-off-by: Adrian Hunter <ext-adrian.hunter at nokia.com>
> ---
>  drivers/mtd/mtdpart.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
> index 633def3..476fbb6 100644
> --- a/drivers/mtd/mtdpart.c
> +++ b/drivers/mtd/mtdpart.c
> @@ -200,6 +200,11 @@ static int part_erase (struct mtd_info *
>  		return -EINVAL;
>  	instr->addr += part->offset;
>  	ret = part->master->erase(part->master, instr);
> +	if (ret) {
> +		if (instr->fail_addr != 0xffffffff)
> +			instr->fail_addr -= part->offset;
> +		instr->addr -= part->offset;
> +	}
>  	return ret;
>  }
 
Erase isn't always synchronous. It can return success (i.e. erase queued
successfully) and later call the callback with an indication of failure.

-- 
dwmw2





More information about the linux-mtd mailing list