1 From: Gabor Juhos <juhosg@openwrt.org>
2 Subject: mtd: add EOF marker support to the UBI layer
4 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
6 drivers/mtd/ubi/attach.c | 25 ++++++++++++++++++++++---
7 drivers/mtd/ubi/ubi.h | 1 +
8 2 files changed, 23 insertions(+), 3 deletions(-)
10 --- a/drivers/mtd/ubi/attach.c
11 +++ b/drivers/mtd/ubi/attach.c
12 @@ -939,6 +939,13 @@ static bool vol_ignored(int vol_id)
16 +static bool ec_hdr_has_eof(struct ubi_ec_hdr *ech)
18 + return ech->padding1[0] == 'E' &&
19 + ech->padding1[1] == 'O' &&
20 + ech->padding1[2] == 'F';
24 * scan_peb - scan and process UBI headers of a PEB.
25 * @ubi: UBI device description object
26 @@ -971,9 +978,21 @@ static int scan_peb(struct ubi_device *u
30 - err = ubi_io_read_ec_hdr(ubi, pnum, ech, 0);
33 + if (!ai->eof_found) {
34 + err = ubi_io_read_ec_hdr(ubi, pnum, ech, 0);
38 + if (ec_hdr_has_eof(ech)) {
39 + pr_notice("UBI: EOF marker found, PEBs from %d will be erased\n",
41 + ai->eof_found = true;
46 + err = UBI_IO_FF_BITFLIPS;
51 --- a/drivers/mtd/ubi/ubi.h
52 +++ b/drivers/mtd/ubi/ubi.h
53 @@ -779,6 +779,7 @@ struct ubi_attach_info {
58 struct kmem_cache *aeb_slab_cache;
59 struct ubi_ec_hdr *ech;
60 struct ubi_vid_io_buf *vidb;