mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-18 15:09:53 +00:00
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>
This commit is contained in:
parent
29a88c99d2
commit
5b289b562f
@ -480,16 +480,7 @@ 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;
|
||||
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);
|
||||
ubi_dbg_dump_stack();
|
||||
return err;
|
||||
}
|
||||
|
||||
addr += ubi->vid_hdr_aloffset;
|
||||
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 "
|
||||
@ -498,6 +489,15 @@ static int nor_erase_prepare(struct ubi_device *ubi, int pnum)
|
||||
return err;
|
||||
}
|
||||
|
||||
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, 0, written);
|
||||
ubi_dbg_dump_stack();
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user