bcm53xx: backport forgotten spi-nor change
[openwrt/openwrt.git] / target / linux / bcm53xx / patches-3.14 / 500-UBI-Detect-EOF-mark-and-erase-all-remaining-blocks.patch
1 From f41f8b42db092e505382f7120994de21590dff48 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
3 Date: Thu, 16 Oct 2014 20:52:16 +0200
4 Subject: [PATCH] UBI: Detect EOF mark and erase all remaining blocks
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
10 ---
11 drivers/mtd/ubi/io.c | 5 +++++
12 1 file changed, 5 insertions(+)
13
14 diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
15 index d361349..f9bba3c 100644
16 --- a/drivers/mtd/ubi/io.c
17 +++ b/drivers/mtd/ubi/io.c
18 @@ -727,6 +727,7 @@ bad:
19 * o %UBI_IO_FF if only 0xFF bytes were read (the PEB is supposedly empty)
20 * o a negative error code in case of failure.
21 */
22 +static bool erase_all_next = false;
23 int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
24 struct ubi_ec_hdr *ec_hdr, int verbose)
25 {
26 @@ -753,6 +754,10 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
27 }
28
29 magic = be32_to_cpu(ec_hdr->magic);
30 + if (magic == 0xdeadc0de)
31 + erase_all_next = true;
32 + if (erase_all_next)
33 + return read_err ? UBI_IO_FF_BITFLIPS : UBI_IO_FF;
34 if (magic != UBI_EC_HDR_MAGIC) {
35 if (mtd_is_eccerr(read_err))
36 return UBI_IO_BAD_HDR_EBADMSG;
37 --
38 1.8.4.5
39