NAND bad block table creation

Naveen Mamindlapalli naveen.mamindlapalli at gmail.com
Thu Jun 10 05:13:16 EDT 2010


Hi All,

I am going through mtd subsystem code for bad block management
information. The linux kernel version I am using is linux-2.6.34. In
the create_bbt( )  function in drivers/mtd/nand/nand_bbt.c, the for
loop which checks for whether a block is bad or not is incrementing by
2 (line 436) . That means alternate NAND blocks are checked to find
out whether that block is bad or not.

Is this correct?

Code is pasted below ( drivers/mtd/nand/nand_bbt.c ):

    417         for (i = startblock; i < numblocks;) {
    418                 int ret;
    419
    420                 if (bd->options & NAND_BBT_SCANALLPAGES)
    421                         ret = scan_block_full(mtd, bd, from,
buf, readlen,
    422                                               scanlen, len);
    423                 else
    424                         ret = scan_block_fast(mtd, bd, from, buf, len);
    425
    426                 if (ret < 0)
    427                         return ret;
    428
    429                 if (ret) {
    430                         this->bbt[i >> 3] |= 0x03 << (i & 0x6);
    431                         printk(KERN_WARNING "Bad eraseblock %d
at 0x%012llx\n",
    432                                i >> 1, (unsigned long long)from);
    433                         mtd->ecc_stats.badblocks++;
    434                 }
    435
    436                 i += 2;
    437                 from += (1 << this->bbt_erase_shift);
    438         }

Thanks and Regards,
Naveen



More information about the linux-mtd mailing list