mtd/drivers/mtd/nand nand_bbt.c,1.30,1.31
Artem Bityuckiy
dedekind at infradead.org
Wed Feb 16 12:09:39 EST 2005
- Previous message: mtd/include/linux/mtd map.h,1.47,1.48
- Next message: mtd/util compr.c, 1.6, 1.7 flash_eraseall.c, 1.21, 1.22 flashcp.c,
1.4, 1.5 mkfs.jffs.c, 1.13, 1.14 mkfs.jffs2.c, 1.43,
1.44 nanddump.c, 1.26, 1.27 sumtool.c, 1.2, 1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/mtd/drivers/mtd/nand
In directory phoenix.infradead.org:/tmp/cvs-serv851
Modified Files:
nand_bbt.c
Log Message:
Scan 1st and 2nd pages of SP devices dor BB marker by default.
Fix more then one page scanning in create_bbt.c.
Index: nand_bbt.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/nand/nand_bbt.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- nand_bbt.c 11 Feb 2005 10:14:12 -0000 1.30
+++ nand_bbt.c 16 Feb 2005 17:09:36 -0000 1.31
@@ -77,17 +77,17 @@
*/
static int check_pattern (uint8_t *buf, int len, int paglen, struct nand_bbt_descr *td)
{
- int i, end;
+ int i, end = 0;
uint8_t *p = buf;
- end = paglen + td->offs;
if (td->options & NAND_BBT_SCANEMPTY) {
+ end = paglen + td->offs;
for (i = 0; i < end; i++) {
if (p[i] != 0xff)
return -1;
}
+ p += end;
}
- p += end;
/* Compare the pattern */
for (i = 0; i < td->len; i++) {
@@ -95,9 +95,9 @@
return -1;
}
- p += td->len;
- end += td->len;
if (td->options & NAND_BBT_SCANEMPTY) {
+ p += td->len;
+ end += td->len;
for (i = end; i < len; i++) {
if (*p++ != 0xff)
return -1;
@@ -255,7 +255,7 @@
static int create_bbt (struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *bd, int chip)
{
struct nand_chip *this = mtd->priv;
- int i, j, numblocks, len, scanlen, pagelen;
+ int i, j, numblocks, len, scanlen;
int startblock;
loff_t from;
size_t readlen, ooblen;
@@ -270,17 +270,16 @@
else
len = 1;
}
-
- if (bd->options == 0) {
- /* Memory-based BBT. We may read only needed bytes from the OOB area to
- * test if block is bad, no need to read the whole page content. */
- scanlen = ooblen = pagelen = 0;
+
+ if (!(bd->options & NAND_BBT_SCANEMPTY)) {
+ /* We need only read few bytes from the OOB area */
+ scanlen = ooblen = 0;
readlen = bd->len;
} else {
+ /* Full page content should be read */
scanlen = mtd->oobblock + mtd->oobsize;
readlen = len * mtd->oobblock;
ooblen = len * mtd->oobsize;
- pagelen = mtd->oobblock;
}
if (chip == -1) {
@@ -293,7 +292,7 @@
if (chip >= this->numchips) {
printk (KERN_WARNING "create_bbt(): chipnr (%d) > available chips (%d)\n",
chip + 1, this->numchips);
- return -EINVAL;
+ return -EINVAL;
}
numblocks = this->chipsize >> (this->bbt_erase_shift - 1);
startblock = chip * numblocks;
@@ -304,16 +303,21 @@
for (i = startblock; i < numblocks;) {
int ret;
- if (bd->options == 0) {
- size_t retlen;
- if ((ret = mtd->read_oob(mtd, from + bd->offs, bd->len, &retlen, &buf[bd->offs])))
- return ret;
- } else {
+ if (bd->options & NAND_BBT_SCANEMPTY)
if ((ret = nand_read_raw (mtd, buf, from, readlen, ooblen)))
return ret;
- }
+
for (j = 0; j < len; j++) {
- if (check_pattern (&buf[j * scanlen], scanlen, pagelen, bd)) {
+ if (!(bd->options & NAND_BBT_SCANEMPTY)) {
+ size_t retlen;
+
+ /* No need to read pages fully, just read required OOB bytes */
+ ret = mtd->read_oob(mtd, from + j * mtd->oobblock + bd->offs,
+ readlen, &retlen, &buf[0]);
+ if (ret)
+ return ret;
+ }
+ if (check_pattern (&buf[j * scanlen], scanlen, mtd->oobblock, bd)) {
this->bbt[i >> 3] |= 0x03 << (i & 0x6);
printk (KERN_WARNING "Bad eraseblock %d at 0x%08x\n",
i >> 1, (unsigned int) from);
@@ -323,6 +327,7 @@
i += 2;
from += (1 << this->bbt_erase_shift);
}
+
return 0;
}
@@ -608,12 +613,11 @@
* The function creates a memory based bbt by scanning the device
* for manufacturer / software marked good / bad blocks
*/
-static int nand_memory_bbt (struct mtd_info *mtd, struct nand_bbt_descr *bd)
+static inline int nand_memory_bbt (struct mtd_info *mtd, struct nand_bbt_descr *bd)
{
struct nand_chip *this = mtd->priv;
- /* Ensure that we only scan for the pattern and nothing else */
- bd->options = 0;
+ bd->options &= ~NAND_BBT_SCANEMPTY;
return create_bbt (mtd, this->data_buf, bd, -1);
}
@@ -928,14 +932,11 @@
}
/* Define some generic bad / good block scan pattern which are used
- * while scanning a device for factory marked good / bad blocks
- *
- * The memory based patterns just
- */
+ * while scanning a device for factory marked good / bad blocks. */
static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
static struct nand_bbt_descr smallpage_memorybased = {
- .options = 0,
+ .options = NAND_BBT_SCAN2NDPAGE,
.offs = 5,
.len = 1,
.pattern = scan_ff_pattern
- Previous message: mtd/include/linux/mtd map.h,1.47,1.48
- Next message: mtd/util compr.c, 1.6, 1.7 flash_eraseall.c, 1.21, 1.22 flashcp.c,
1.4, 1.5 mkfs.jffs.c, 1.13, 1.14 mkfs.jffs2.c, 1.43,
1.44 nanddump.c, 1.26, 1.27 sumtool.c, 1.2, 1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the linux-mtd-cvs
mailing list