From patchwork Mon Oct 25 08:38:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu CASTET X-Patchwork-Id: 69078 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from canuck.infradead.org (canuck.infradead.org [134.117.69.58]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 152BAB70AA for ; Mon, 25 Oct 2010 19:41:55 +1100 (EST) Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1PAIaF-000677-4a; Mon, 25 Oct 2010 08:39:11 +0000 Received: from co202.xi-lite.net ([149.6.83.202]) by canuck.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1PAIaB-00066P-Sg for linux-mtd@lists.infradead.org; Mon, 25 Oct 2010 08:39:08 +0000 Received: from ONYX.xi-lite.lan (unknown [193.34.35.244]) by co202.xi-lite.net (Postfix) with ESMTPS id DF7782602BA for ; Mon, 25 Oct 2010 11:05:58 +0200 (CEST) Received: from [172.20.223.18] (84.14.91.202) by mail.xi-lite.com (193.34.32.105) with Microsoft SMTP Server (TLS) id 8.1.336.0; Mon, 25 Oct 2010 09:43:48 +0100 Message-ID: <4CC54223.2050401@parrot.com> Date: Mon, 25 Oct 2010 10:38:59 +0200 From: Matthieu CASTET User-Agent: Thunderbird 2.0.0.24 (X11/20100228) MIME-Version: 1.0 To: linux-mtd Subject: [PATCH] write bad block marker even with BBT X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20101025_043908_069476_DE87EC2F X-CRM114-Status: GOOD ( 11.01 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Add a new flag to force writing bad block marker if we use bad block table. This allow to solve problem where bootloader don't support reading BBT. Signed-off-by: Matthieu CASTET diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index ddffe76..4d79a8d 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -396,7 +396,7 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs) { struct nand_chip *chip = mtd->priv; uint8_t buf[2] = { 0, 0 }; - int block, ret, i = 0; + int block, ret = 0, i = 0; if (chip->options & NAND_BBT_SCANLASTPAGE) ofs += mtd->erasesize - mtd->writesize; @@ -409,7 +409,12 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs) /* Do we have a flash based bad block table ? */ if (chip->options & NAND_USE_FLASH_BBT) ret = nand_update_bbt(mtd, ofs); - else { + + /* Write the bad block marker if we don't have BBT, or driver + * request it (in case the bootloader doesn't support reading it + * or we loose BBT). + */ + if (!(chip->options & NAND_USE_FLASH_BBT) || chip->options & NAND_WRITE_BB) { nand_get_device(chip, mtd, FL_WRITING); /* Write to first two pages and to byte 1 and 6 if necessary. diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index 102e12c..2efd2f9 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h @@ -215,6 +215,8 @@ typedef enum { #define NAND_OWN_BUFFERS 0x00040000 /* Chip may not exist, so silence any errors in scan */ #define NAND_SCAN_SILENT_NODEV 0x00080000 +/* in case of NAND_USE_FLASH_BBT, write also bad block marker */ +#define NAND_WRITE_BB 0x00100000 /* Options set by nand scan */ /* Nand scan has allocated controller struct */