diff options
author | Kyungmin Park <kmpark@infradead.org> | 2008-11-13 15:14:33 +0900 |
---|---|---|
committer | Scott Wood <scottwood@freescale.com> | 2009-01-23 10:32:47 -0600 |
commit | 1714f51a2009baaecf3d4f6e3bd8c4e93a8d3f23 (patch) | |
tree | d92f8ab97f2e8e87f70c8bb2f5bdfdfe9142f2e5 /drivers/mtd | |
parent | c438ea175d8d002c1063b7a94b0c0e26668d1ac9 (diff) | |
download | u-boot-imx-1714f51a2009baaecf3d4f6e3bd8c4e93a8d3f23.zip u-boot-imx-1714f51a2009baaecf3d4f6e3bd8c4e93a8d3f23.tar.gz u-boot-imx-1714f51a2009baaecf3d4f6e3bd8c4e93a8d3f23.tar.bz2 |
Add markbad function
Add missing markbad function
If not, it's hang when it entered the mtd->mark_bad().
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/onenand/onenand_base.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c index f62b1aa..dcc969f 100644 --- a/drivers/mtd/onenand/onenand_base.c +++ b/drivers/mtd/onenand/onenand_base.c @@ -1584,6 +1584,37 @@ int onenand_block_isbad(struct mtd_info *mtd, loff_t ofs) } /** + * onenand_default_block_markbad - [DEFAULT] mark a block bad + * @param mtd MTD device structure + * @param ofs offset from device start + * + * This is the default implementation, which can be overridden by + * a hardware specific driver. + */ +static int onenand_default_block_markbad(struct mtd_info *mtd, loff_t ofs) +{ + struct onenand_chip *this = mtd->priv; + struct bbm_info *bbm = this->bbm; + u_char buf[2] = {0, 0}; + struct mtd_oob_ops ops = { + .mode = MTD_OOB_PLACE, + .ooblen = 2, + .oobbuf = buf, + .ooboffs = 0, + }; + int block; + + /* Get block number */ + block = ((int) ofs) >> bbm->bbt_erase_shift; + if (bbm->bbt) + bbm->bbt[block >> 2] |= 0x01 << ((block & 0x03) << 1); + + /* We write two bytes, so we dont have to mess with 16 bit access */ + ofs += mtd->oobsize + (bbm->badblockpos & ~0x01); + return onenand_write_oob_nolock(mtd, ofs, &ops); +} + +/** * onenand_block_markbad - [MTD Interface] Mark the block at the given offset as bad * @param mtd MTD device structure * @param ofs offset relative to mtd start @@ -2048,6 +2079,8 @@ int onenand_scan(struct mtd_info *mtd, int maxchips) if (!this->write_bufferram) this->write_bufferram = onenand_write_bufferram; + if (!this->block_markbad) + this->block_markbad = onenand_default_block_markbad; if (!this->scan_bbt) this->scan_bbt = onenand_default_bbt; |