[MTD] [NAND] Wrong calculation of page number in nand_block_bad()

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Fri Apr 27 10:59:02 EDT 2007


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=78ab67da1002d954ea4c3e2b441e2483c41f94e8
Commit:     78ab67da1002d954ea4c3e2b441e2483c41f94e8
Parent:     ef2e58ea6b9931c3a4816c66593da49bb20e3b24
Author:     Knobloch, Thomas <knobloch at siemens.com>
AuthorDate: Fri Apr 27 13:19:36 2007 +0200
Committer:  David Woodhouse <dwmw2 at infradead.org>
CommitDate: Fri Apr 27 15:13:53 2007 +0100

    [MTD] [NAND] Wrong calculation of page number in nand_block_bad()
    
    In case that there is no memory based bad block table available the
    function nand_block_checkbad() in drivers/mtd/nand/nand_base.c will call
    nand_block_bad() directly. When parameter 'getchip' is set to zero,
    nand_block_bad() will not right shift the offset to calculate the
    correct page number.
    
    Signed-off-by: Thomas Knobloch <knobloch at siemens.com>
    Signed-off-by: David Woodhouse <dwmw2 at infradead.org>
---
 drivers/mtd/nand/nand_base.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index ab3b2d1..04de315 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -312,7 +312,7 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
 		/* Select the NAND device */
 		chip->select_chip(mtd, chipnr);
 	} else
-		page = (int)ofs;
+		page = (int)(ofs >> chip->page_shift);
 
 	if (chip->options & NAND_BUSWIDTH_16) {
 		chip->cmdfunc(mtd, NAND_CMD_READOOB, chip->badblockpos & 0xFE,



More information about the linux-mtd-cvs mailing list