linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Richard Weinberger <richard@nod.at>
To: linux-mtd@lists.infradead.org
Cc: linux-kernel@vger.kernel.org, Richard Weinberger <richard@nod.at>
Subject: [PATCH 4/8] ubi: fastmap: Handle bad block count for preseeded fastmap case
Date: Mon, 14 May 2018 13:24:18 +0200	[thread overview]
Message-ID: <20180514112422.23988-5-richard@nod.at> (raw)
In-Reply-To: <20180514112422.23988-1-richard@nod.at>

If the fastmap is preseeded the bad block count is created while
scanning for bad blocks in the PEB fixup code.

Signed-off-by: Richard Weinberger <richard@nod.at>
---
 drivers/mtd/ubi/fastmap.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
index a351860f420a..f40cd2b18d4c 100644
--- a/drivers/mtd/ubi/fastmap.c
+++ b/drivers/mtd/ubi/fastmap.c
@@ -692,7 +692,16 @@ static int ubi_attach_fastmap(struct ubi_device *ubi,
 	}
 
 	ai->mean_ec = div_u64(ai->ec_sum, ai->ec_count);
-	ai->bad_peb_count = be32_to_cpu(fmhdr->bad_peb_count);
+
+	if (fm->flags & UBI_FM_SB_PRESEEDED_FLG) {
+		/* When we have a preseeded Fastmap cannot use the provided bad block number */
+		if (be32_to_cpu(fmhdr->bad_peb_count) != 0) {
+			ubi_err(ubi, "Bad block count in preseeded Fastmap is non-zero");
+			goto fail_bad;
+		}
+	} else {
+		ai->bad_peb_count = be32_to_cpu(fmhdr->bad_peb_count);
+	}
 
 	/* Iterate over all volumes and read their EBA table */
 	for (i = 0; i < be32_to_cpu(fmhdr->vol_count); i++) {
-- 
2.13.6

  parent reply	other threads:[~2018-05-14 11:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-14 11:24 [PATCH 0/8] ubi: fastmap: Support for preseeded fastmap Richard Weinberger
2018-05-14 11:24 ` [PATCH 1/8] ubi: fastmap: Add support for flags Richard Weinberger
2018-05-14 11:24 ` [PATCH 2/8] ubi: fastmap: Add UBI_FM_SB_PRESEEDED_FLG flag Richard Weinberger
2018-05-14 11:24 ` [PATCH 3/8] ubi: fastmap: Implement PEB fixup Richard Weinberger
2018-05-14 11:24 ` Richard Weinberger [this message]
2018-05-14 11:24 ` [PATCH 5/8] ubi: fastmap: Fixup pool sizes for preseeded fastmaps Richard Weinberger
2018-05-14 11:24 ` [PATCH 6/8] ubi: fastmap: Scan empty space if fastmap is preseeded Richard Weinberger
2018-05-14 11:24 ` [PATCH 7/8] ubi: fastmap: Relax size check Richard Weinberger
2018-05-14 11:24 ` [PATCH 8/8] ubi: Fix assert in ubi_wl_init Richard Weinberger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180514112422.23988-5-richard@nod.at \
    --to=richard@nod.at \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).