Commit 065a1ed8de85583888b3d4f22c64b534a1fbdaaa

Authored by Brian Norris
Committed by David Woodhouse
1 parent 93b352fce6

mtd: nand: Fix regression in BBM detection

Commit c7b28e25cb9beb943aead770ff14551b55fa8c79 ("mtd: nand: refactor BB
marker detection") caused a regression in detection of factory-set bad
block markers, especially for certain small-page NAND. This fix removes
some unneeded constraints on using NAND_SMALL_BADBLOCK_POS, making the
detection code more correct.

This regression can be seen, for example, in Hynix HY27US081G1M and
similar.

Signed-off-by: Brian Norris <norris@broadcom.com>
Tested-by: Michael Guntsche <mike@it-loops.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>

Showing 1 changed file with 3 additions and 7 deletions Side-by-side Diff

drivers/mtd/nand/nand_base.c
... ... @@ -2934,14 +2934,10 @@
2934 2934 chip->chip_shift = ffs((unsigned)(chip->chipsize >> 32)) + 32 - 1;
2935 2935  
2936 2936 /* Set the bad block position */
2937   - if (!(busw & NAND_BUSWIDTH_16) && (*maf_id == NAND_MFR_STMICRO ||
2938   - (*maf_id == NAND_MFR_SAMSUNG &&
2939   - mtd->writesize == 512) ||
2940   - *maf_id == NAND_MFR_AMD))
2941   - chip->badblockpos = NAND_SMALL_BADBLOCK_POS;
2942   - else
  2937 + if (mtd->writesize > 512 || (busw & NAND_BUSWIDTH_16))
2943 2938 chip->badblockpos = NAND_LARGE_BADBLOCK_POS;
2944   -
  2939 + else
  2940 + chip->badblockpos = NAND_SMALL_BADBLOCK_POS;
2945 2941  
2946 2942 /* Get chip options, preserve non chip based options */
2947 2943 chip->options &= ~NAND_CHIPOPTIONS_MSK;