bcm53xx: initial support for kernel 3.18
[15.05/openwrt.git] / target / linux / bcm53xx / patches-3.18 / 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 --- a/drivers/mtd/ubi/io.c
15 +++ b/drivers/mtd/ubi/io.c
16 @@ -727,6 +727,7 @@ bad:
17   * o %UBI_IO_FF if only 0xFF bytes were read (the PEB is supposedly empty)
18   * o a negative error code in case of failure.
19   */
20 +static bool erase_all_next = false;
21  int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
22                        struct ubi_ec_hdr *ec_hdr, int verbose)
23  {
24 @@ -753,6 +754,10 @@ int ubi_io_read_ec_hdr(struct ubi_device
25         }
26  
27         magic = be32_to_cpu(ec_hdr->magic);
28 +       if (magic == 0xdeadc0de)
29 +               erase_all_next = true;
30 +       if (erase_all_next)
31 +               return read_err ? UBI_IO_FF_BITFLIPS : UBI_IO_FF;
32         if (magic != UBI_EC_HDR_MAGIC) {
33                 if (mtd_is_eccerr(read_err))
34                         return UBI_IO_BAD_HDR_EBADMSG;