diff -aur b/drivers/mtd/nand/nand_base.c c/drivers/mtd/nand/nand_base.c --- b/drivers/mtd/nand/nand_base.c 2006-02-09 20:05:28.447558688 +0300 +++ c/drivers/mtd/nand/nand_base.c 2006-02-09 20:14:58.182945744 +0300 @@ -409,7 +409,7 @@ */ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip) { - int page, chipnr, res = 0; + int page, badblockpos, chipnr, res = 0; struct nand_chip *this = mtd->priv; u16 bad; @@ -425,15 +425,22 @@ } else page = (int) ofs; + /* If pattern is given use offset from badblock_pattern structure + else use badblockpos which take default values */ + if (this->badblock_pattern) + badblockpos=this->badblock_pattern->offs; + else + badblockpos=this->badblockpos; + if (this->options & NAND_BUSWIDTH_16) { - this->cmdfunc (mtd, NAND_CMD_READOOB, this->badblockpos & 0xFE, page & this->pagemask); + this->cmdfunc (mtd, NAND_CMD_READOOB, badblockpos & 0xFE, page & this->pagemask); bad = cpu_to_le16(this->read_word(mtd)); if (this->badblockpos & 0x1) bad >>= 8; if ((bad & 0xFF) != 0xff) res = 1; } else { - this->cmdfunc (mtd, NAND_CMD_READOOB, this->badblockpos, page & this->pagemask); + this->cmdfunc (mtd, NAND_CMD_READOOB, badblockpos, page & this->pagemask); if (this->read_byte(mtd) != 0xff) res = 1; } @@ -470,8 +477,11 @@ if (this->options & NAND_USE_FLASH_BBT) return nand_update_bbt (mtd, ofs); - /* We write two bytes, so we dont have to mess with 16 bit access */ - ofs += mtd->oobsize + (this->badblockpos & ~0x01); + if (this->badblock_pattern) + ofs += (this->badblock_pattern->offs & ~0x01); + else + ofs += (this->badblockpos & ~0x01); + return nand_write_oob (mtd, ofs , 2, &retlen, buf); } @@ -1700,7 +1710,7 @@ len += num; fsbuf += num; } - ofs += mtd->oobavail; + ofs += mtd->oobsize; } return this->oob_buf; }