15 #include <linux/slab.h>
18 #include <linux/export.h>
39 for (i = 0; i < td->
len; i++) {
61 int i,
j, numblocks, len, scanlen;
64 size_t readlen, ooblen;
89 for (i = startblock; i < numblocks; ) {
92 for (j = 0; j <
len; j++) {
96 from + j * this->writesize + bd->
offs, &ops);
102 if (ret || check_short_pattern(&buf[j * scanlen],
103 scanlen, this->writesize, bd)) {
104 bbm->
bbt[i >> 3] |= 0x03 << (i & 0x6);
106 "initial bad block\n", i >> 1);
137 return create_bbt(mtd, this->
page_buf, bd, -1);
146 static int onenand_isbad_bbt(
struct mtd_info *mtd, loff_t
offs,
int allowbbt)
155 res = (bbm->
bbt[block >> 3] >> (block & 0x06)) & 0x03;
157 pr_debug(
"onenand_isbad_bbt: bbt info for offs 0x%08x: (block %d) 0x%02x\n",
158 (
unsigned int) offs, block >> 1, res);
163 case 0x02:
return allowbbt ? 0 : 1;
189 len = this->chipsize >> (this->erase_shift + 2);
205 if ((ret = onenand_memory_bbt(mtd, bd))) {
206 printk(
KERN_ERR "onenand_scan_bbt: Can't scan flash and build the RAM-based BBT\n");
218 static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
224 .pattern = scan_ff_pattern,