diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2009-07-19 07:09:46 -0400 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2009-08-14 13:01:36 -0400 |
commit | 5b289b562f6d236108569a880cb38cc03d17a50d (patch) | |
tree | 74b3bcc3e1aa4632c5ea51e45769c11b9a0e7c1f /drivers/mtd/ubi | |
parent | 29a88c99d29834fb3314e0144900b187ede83106 (diff) |
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 <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'drivers/mtd/ubi')
-rw-r--r-- | drivers/mtd/ubi/io.c | 8 |
1 files changed, 4 insertions, 4 deletions
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) | |||
480 | loff_t addr; | 480 | loff_t addr; |
481 | uint32_t data = 0; | 481 | uint32_t data = 0; |
482 | 482 | ||
483 | addr = (loff_t)pnum * ubi->peb_size; | 483 | addr = (loff_t)pnum * ubi->peb_size + ubi->vid_hdr_aloffset; |
484 | err = ubi->mtd->write(ubi->mtd, addr, 4, &written, (void *)&data); | 484 | err = ubi->mtd->write(ubi->mtd, addr, 4, &written, (void *)&data); |
485 | if (err) { | 485 | if (err) { |
486 | ubi_err("error %d while writing 4 bytes to PEB %d:%d, written " | 486 | ubi_err("error %d while writing 4 bytes to PEB %d:%d, written " |
487 | "%zd bytes", err, pnum, 0, written); | 487 | "%zd bytes", err, pnum, ubi->vid_hdr_aloffset, written); |
488 | ubi_dbg_dump_stack(); | 488 | ubi_dbg_dump_stack(); |
489 | return err; | 489 | return err; |
490 | } | 490 | } |
491 | 491 | ||
492 | addr += ubi->vid_hdr_aloffset; | 492 | addr -= ubi->vid_hdr_aloffset; |
493 | err = ubi->mtd->write(ubi->mtd, addr, 4, &written, (void *)&data); | 493 | err = ubi->mtd->write(ubi->mtd, addr, 4, &written, (void *)&data); |
494 | if (err) { | 494 | if (err) { |
495 | ubi_err("error %d while writing 4 bytes to PEB %d:%d, written " | 495 | ubi_err("error %d while writing 4 bytes to PEB %d:%d, written " |
496 | "%zd bytes", err, pnum, ubi->vid_hdr_aloffset, written); | 496 | "%zd bytes", err, pnum, 0, written); |
497 | ubi_dbg_dump_stack(); | 497 | ubi_dbg_dump_stack(); |
498 | return err; | 498 | return err; |
499 | } | 499 | } |