ubi: Do not zero out EC and VID on ECC-ed NOR flashes
[sfrench/cifs-2.6.git] / drivers / mtd / ubi / io.c
index 14d890b00d2cb54d380c13fcb60011884241306a..2f3312c31e51c18b88dbc3bb63b3cefe064b2513 100644 (file)
@@ -535,7 +535,14 @@ int ubi_io_sync_erase(struct ubi_device *ubi, int pnum, int torture)
                return -EROFS;
        }
 
-       if (ubi->nor_flash) {
+       /*
+        * If the flash is ECC-ed then we have to erase the ECC block before we
+        * can write to it. But the write is in preparation to an erase in the
+        * first place. This means we cannot zero out EC and VID before the
+        * erase and we just have to hope the flash starts erasing from the
+        * start of the page.
+        */
+       if (ubi->nor_flash && ubi->mtd->writesize == 1) {
                err = nor_erase_prepare(ubi, pnum);
                if (err)
                        return err;