summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Knobloch <knobloch@siemens.com>2007-05-05 07:04:42 +0200
committerStefan Roese <sr@denx.de>2007-05-05 07:04:42 +0200
commita79886590593ba1d667c840caa4940c61639f18f (patch)
tree705931458699b81600559d222dad5738cb0ce265
parent8d1c439e2d9b0bdfe35df207e2c6b2f3a2312a3b (diff)
downloadu-boot-imx-a79886590593ba1d667c840caa4940c61639f18f.zip
u-boot-imx-a79886590593ba1d667c840caa4940c61639f18f.tar.gz
u-boot-imx-a79886590593ba1d667c840caa4940c61639f18f.tar.bz2
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@siemens.com> Signed-off-by: Stefan Roese <sr@denx.de>
-rw-r--r--drivers/nand/nand_base.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/nand/nand_base.c b/drivers/nand/nand_base.c
index 8495829..c6fee18 100644
--- a/drivers/nand/nand_base.c
+++ b/drivers/nand/nand_base.c
@@ -427,8 +427,9 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
struct nand_chip *this = mtd->priv;
u16 bad;
+ page = (int)(ofs >> this->page_shift) & this->pagemask;
+
if (getchip) {
- page = (int)(ofs >> this->page_shift);
chipnr = (int)(ofs >> this->chip_shift);
/* Grab the lock and see if the device is available */
@@ -436,18 +437,17 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
/* Select the NAND device */
this->select_chip(mtd, chipnr);
- } else
- page = (int) ofs;
+ }
if (this->options & NAND_BUSWIDTH_16) {
- this->cmdfunc (mtd, NAND_CMD_READOOB, this->badblockpos & 0xFE, page & this->pagemask);
+ this->cmdfunc (mtd, NAND_CMD_READOOB, this->badblockpos & 0xFE, page);
bad = cpu_to_le16(this->read_word(mtd));
if (this->badblockpos & 0x1)
bad >>= 1;
if ((bad & 0xFF) != 0xff)
res = 1;
} else {
- this->cmdfunc (mtd, NAND_CMD_READOOB, this->badblockpos, page & this->pagemask);
+ this->cmdfunc (mtd, NAND_CMD_READOOB, this->badblockpos, page);
if (this->read_byte(mtd) != 0xff)
res = 1;
}