UBI: fix NOR erase preparation quirk
authorHolger Brunck <[email protected]>
Tue, 25 Jan 2011 11:04:11 +0000 (13:04 +0200)
committerArtem Bityutskiy <[email protected]>
Wed, 26 Jan 2011 08:13:52 +0000 (10:13 +0200)
In 'nor_erase_prepare()' we want to make sure the UBI headers are
corrupted. But it is possible that one of the headers just contains
all 0xFFs, which is also OK, because UBI will erase it in case of
a power cut.

Signed-off-by: Holger Brunck <[email protected]>
Signed-off-by: Artem Bityutskiy <[email protected]>
drivers/mtd/ubi/io.c

index 811775aa8ee80082aa5803a13b3537f2022e5936..668d24005106ceb05452cb09021723d101fcb5ce 100644 (file)
@@ -507,11 +507,13 @@ static int nor_erase_prepare(struct ubi_device *ubi, int pnum)
         * PEB.
         */
        err1 = ubi_io_read_vid_hdr(ubi, pnum, &vid_hdr, 0);
-       if (err1 == UBI_IO_BAD_HDR_EBADMSG || err1 == UBI_IO_BAD_HDR) {
+       if (err1 == UBI_IO_BAD_HDR_EBADMSG || err1 == UBI_IO_BAD_HDR ||
+           err1 == UBI_IO_FF) {
                struct ubi_ec_hdr ec_hdr;
 
                err1 = ubi_io_read_ec_hdr(ubi, pnum, &ec_hdr, 0);
-               if (err1 == UBI_IO_BAD_HDR_EBADMSG || err1 == UBI_IO_BAD_HDR)
+               if (err1 == UBI_IO_BAD_HDR_EBADMSG || err1 == UBI_IO_BAD_HDR ||
+                   err1 == UBI_IO_FF)
                        /*
                         * Both VID and EC headers are corrupted, so we can
                         * safely erase this PEB and not afraid that it will be