* [U-Boot] [PATCH] [ONENAND] Add markbad function
@ 2008-11-13 6:14 Kyungmin Park
2008-11-17 19:57 ` Scott Wood
0 siblings, 1 reply; 2+ messages in thread
From: Kyungmin Park @ 2008-11-13 6:14 UTC (permalink / raw)
To: u-boot
Add missing markbad function
If not, it's hang when it entered the mtd->mard_bad().
It's not against the u-boot-nand.
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c
index a54098c..0dc99be 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -1589,6 +1589,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
@@ -2051,6 +2082,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;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [U-Boot] [PATCH] [ONENAND] Add markbad function
2008-11-13 6:14 [U-Boot] [PATCH] [ONENAND] Add markbad function Kyungmin Park
@ 2008-11-17 19:57 ` Scott Wood
0 siblings, 0 replies; 2+ messages in thread
From: Scott Wood @ 2008-11-17 19:57 UTC (permalink / raw)
To: u-boot
On Thu, Nov 13, 2008 at 03:14:33PM +0900, Kyungmin Park wrote:
> Add missing markbad function
> If not, it's hang when it entered the mtd->mard_bad().
Applied to u-boot-nand-flash/next.
> It's not against the u-boot-nand.
Hmm? It appears to apply to the NAND next branch, and not mainline...
-Scott
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-11-17 19:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-13 6:14 [U-Boot] [PATCH] [ONENAND] Add markbad function Kyungmin Park
2008-11-17 19:57 ` Scott Wood
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox