[MTD] Correct partition failed erase address
authorAdrian Hunter <ext-adrian.hunter@nokia.com>
Thu, 8 Mar 2007 10:20:12 +0000 (12:20 +0200)
committerDavid Woodhouse <dwmw2@infradead.org>
Thu, 8 Mar 2007 10:45:04 +0000 (10:45 +0000)
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@nokia.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
drivers/mtd/mtdpart.c

index 01e4afff42b04c758907ad407296c81783030f76..1af989023c6644ca89c8e4107c21fcde8137904d 100644 (file)
@@ -200,6 +200,11 @@ static int part_erase (struct mtd_info *mtd, struct erase_info *instr)
                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;
 }
 
@@ -560,4 +565,3 @@ EXPORT_SYMBOL_GPL(deregister_mtd_parser);
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Nicolas Pitre <nico@cam.org>");
 MODULE_DESCRIPTION("Generic support for partitioning of MTD devices");
-