From: Artem Bityutskiy Date: Sun, 19 Jul 2009 11:09:46 +0000 (+0300) Subject: UBI: amend NOR flash pre-erase quirk X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=5b289b562f6d236108569a880cb38cc03d17a50d;p=linux-beck.git UBI: amend NOR flash pre-erase quirk In case of NOR flash, UBI zeroes EC and VID headers' magic, in order to detect interrupted erasures. It first zeroes out the EC magic, then VID magic. However, if a power cut happens in between, we'll end up with a corrupted EC header and a valid VID header, in which case UBI accepts the PEB, but prints a warning. This patch makes sure we first zero out the VID magic, then the EC magic, not vice versa. This is just a small amendment to prevent warning messages. Signed-off-by: Artem Bityutskiy --- diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c index 4cb69925d8d9..4e7bcb215075 100644 --- a/drivers/mtd/ubi/io.c +++ b/drivers/mtd/ubi/io.c @@ -480,20 +480,20 @@ static int nor_erase_prepare(struct ubi_device *ubi, int pnum) loff_t addr; uint32_t data = 0; - addr = (loff_t)pnum * ubi->peb_size; + addr = (loff_t)pnum * ubi->peb_size + ubi->vid_hdr_aloffset; err = ubi->mtd->write(ubi->mtd, addr, 4, &written, (void *)&data); if (err) { ubi_err("error %d while writing 4 bytes to PEB %d:%d, written " - "%zd bytes", err, pnum, 0, written); + "%zd bytes", err, pnum, ubi->vid_hdr_aloffset, written); ubi_dbg_dump_stack(); return err; } - addr += ubi->vid_hdr_aloffset; + addr -= ubi->vid_hdr_aloffset; err = ubi->mtd->write(ubi->mtd, addr, 4, &written, (void *)&data); if (err) { ubi_err("error %d while writing 4 bytes to PEB %d:%d, written " - "%zd bytes", err, pnum, ubi->vid_hdr_aloffset, written); + "%zd bytes", err, pnum, 0, written); ubi_dbg_dump_stack(); return err; }