From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wi0-f172.google.com ([209.85.212.172]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WSMcF-0002Cd-3s for linux-mtd@lists.infradead.org; Tue, 25 Mar 2014 08:21:47 +0000 Received: by mail-wi0-f172.google.com with SMTP id hi5so3184422wib.17 for ; Tue, 25 Mar 2014 01:21:24 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC 35/47] mtd: nand: stm_nand_bch: dump bad blocks Date: Tue, 25 Mar 2014 08:19:52 +0000 Message-Id: <1395735604-26706-36-git-send-email-lee.jones@linaro.org> In-Reply-To: <1395735604-26706-1-git-send-email-lee.jones@linaro.org> References: <1395735604-26706-1-git-send-email-lee.jones@linaro.org> Cc: angus.clark@st.com, kernel@stlinux.com, lee.jones@linaro.org, linux-mtd@lists.infradead.org, pekon@ti.com, computersforpeace@gmail.com, dwmw2@infradead.org List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Inform the user of any known bad blocks during initialisation. Conversely, if there aren't any known bad blocks, let the user know the good news. Signed-off-by: Lee Jones --- drivers/mtd/nand/stm_nand_bch.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/mtd/nand/stm_nand_bch.c b/drivers/mtd/nand/stm_nand_bch.c index 6698b1f..abbb4d9 100644 --- a/drivers/mtd/nand/stm_nand_bch.c +++ b/drivers/mtd/nand/stm_nand_bch.c @@ -1060,6 +1060,28 @@ static int bch_load_bbt(struct nandi_controller *nandi, return 0; } +static void nandi_dump_bad_blocks(struct nandi_controller *nandi) +{ + int bad_count = 0; + uint32_t block; + uint8_t *bbt = nandi->info.bbt_info.bbt; + uint8_t mark; + + pr_info("BBT:\n"); + for (block = 0; block < nandi->blocks_per_device; block++) { + mark = bbt_get_block_mark(bbt, block); + if (mark != BBT_MARK_GOOD) { + pr_info("\t\tBlock 0x%08x [%05u] marked bad [%s]\n", + block << nandi->block_shift, block, + (mark == BBT_MARK_BAD_FACTORY) ? + "Factory" : "Wear"); + bad_count++; + } + } + if (bad_count == 0) + pr_info("\t\tNo bad blocks listed in BBT\n"); +} + /* * Initialisation */ @@ -1849,6 +1871,8 @@ static int stm_nand_bch_probe(struct platform_device *pdev) return err; } + nandi_dump_bad_blocks(nandi); + return 0; } -- 1.8.3.2