aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/DocBook/mtdnand.tmpl2
-rw-r--r--drivers/mtd/nand/nand_bbt.c37
-rw-r--r--include/linux/mtd/bbm.h2
3 files changed, 3 insertions, 38 deletions
diff --git a/Documentation/DocBook/mtdnand.tmpl b/Documentation/DocBook/mtdnand.tmpl
index a248f42a121e..cd11926e07c7 100644
--- a/Documentation/DocBook/mtdnand.tmpl
+++ b/Documentation/DocBook/mtdnand.tmpl
@@ -1222,8 +1222,6 @@ in this page</entry>
1222#define NAND_BBT_VERSION 0x00000100 1222#define NAND_BBT_VERSION 0x00000100
1223/* Create a bbt if none axists */ 1223/* Create a bbt if none axists */
1224#define NAND_BBT_CREATE 0x00000200 1224#define NAND_BBT_CREATE 0x00000200
1225/* Search good / bad pattern through all pages of a block */
1226#define NAND_BBT_SCANALLPAGES 0x00000400
1227/* Write bbt if neccecary */ 1225/* Write bbt if neccecary */
1228#define NAND_BBT_WRITE 0x00001000 1226#define NAND_BBT_WRITE 0x00001000
1229/* Read and write back block contents when writing bbt */ 1227/* Read and write back block contents when writing bbt */
diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
index c75b6a7c6ea4..c0615d1526f9 100644
--- a/drivers/mtd/nand/nand_bbt.c
+++ b/drivers/mtd/nand/nand_bbt.c
@@ -412,25 +412,6 @@ static void read_abs_bbts(struct mtd_info *mtd, uint8_t *buf,
412 } 412 }
413} 413}
414 414
415/* Scan a given block full */
416static int scan_block_full(struct mtd_info *mtd, struct nand_bbt_descr *bd,
417 loff_t offs, uint8_t *buf, size_t readlen,
418 int scanlen, int numpages)
419{
420 int ret, j;
421
422 ret = scan_read_oob(mtd, buf, offs, readlen);
423 /* Ignore ECC errors when checking for BBM */
424 if (ret && !mtd_is_bitflip_or_eccerr(ret))
425 return ret;
426
427 for (j = 0; j < numpages; j++, buf += scanlen) {
428 if (check_pattern(buf, scanlen, mtd->writesize, bd))
429 return 1;
430 }
431 return 0;
432}
433
434/* Scan a given block partially */ 415/* Scan a given block partially */
435static int scan_block_fast(struct mtd_info *mtd, struct nand_bbt_descr *bd, 416static int scan_block_fast(struct mtd_info *mtd, struct nand_bbt_descr *bd,
436 loff_t offs, uint8_t *buf, int numpages) 417 loff_t offs, uint8_t *buf, int numpages)
@@ -477,24 +458,17 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf,
477 struct nand_bbt_descr *bd, int chip) 458 struct nand_bbt_descr *bd, int chip)
478{ 459{
479 struct nand_chip *this = mtd->priv; 460 struct nand_chip *this = mtd->priv;
480 int i, numblocks, numpages, scanlen; 461 int i, numblocks, numpages;
481 int startblock; 462 int startblock;
482 loff_t from; 463 loff_t from;
483 size_t readlen;
484 464
485 pr_info("Scanning device for bad blocks\n"); 465 pr_info("Scanning device for bad blocks\n");
486 466
487 if (bd->options & NAND_BBT_SCANALLPAGES) 467 if (bd->options & NAND_BBT_SCAN2NDPAGE)
488 numpages = 1 << (this->bbt_erase_shift - this->page_shift);
489 else if (bd->options & NAND_BBT_SCAN2NDPAGE)
490 numpages = 2; 468 numpages = 2;
491 else 469 else
492 numpages = 1; 470 numpages = 1;
493 471
494 /* We need only read few bytes from the OOB area */
495 scanlen = 0;
496 readlen = bd->len;
497
498 if (chip == -1) { 472 if (chip == -1) {
499 numblocks = mtd->size >> this->bbt_erase_shift; 473 numblocks = mtd->size >> this->bbt_erase_shift;
500 startblock = 0; 474 startblock = 0;
@@ -519,12 +493,7 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf,
519 493
520 BUG_ON(bd->options & NAND_BBT_NO_OOB); 494 BUG_ON(bd->options & NAND_BBT_NO_OOB);
521 495
522 if (bd->options & NAND_BBT_SCANALLPAGES) 496 ret = scan_block_fast(mtd, bd, from, buf, numpages);
523 ret = scan_block_full(mtd, bd, from, buf, readlen,
524 scanlen, numpages);
525 else
526 ret = scan_block_fast(mtd, bd, from, buf, numpages);
527
528 if (ret < 0) 497 if (ret < 0)
529 return ret; 498 return ret;
530 499
diff --git a/include/linux/mtd/bbm.h b/include/linux/mtd/bbm.h
index 95fc482cef36..36bb6a503f19 100644
--- a/include/linux/mtd/bbm.h
+++ b/include/linux/mtd/bbm.h
@@ -91,8 +91,6 @@ struct nand_bbt_descr {
91 * with NAND_BBT_CREATE. 91 * with NAND_BBT_CREATE.
92 */ 92 */
93#define NAND_BBT_CREATE_EMPTY 0x00000400 93#define NAND_BBT_CREATE_EMPTY 0x00000400
94/* Search good / bad pattern through all pages of a block */
95#define NAND_BBT_SCANALLPAGES 0x00000800
96/* Write bbt if neccecary */ 94/* Write bbt if neccecary */
97#define NAND_BBT_WRITE 0x00002000 95#define NAND_BBT_WRITE 0x00002000
98/* Read and write back block contents when writing bbt */ 96/* Read and write back block contents when writing bbt */