Skip to content

Commit 04649ec

Browse files
fschrempfmiquelraynal
authored andcommitted
mtd: rawnand: Always store info about bad block markers in chip struct
The information about where the manufacturer puts the bad block markers inside the bad block and in the OOB data is stored in different places. Let's move this information to nand_chip.options and nand_chip.badblockpos. As this chip-specific information is not directly related to the bad block table (BBT), we also rename the flags to NAND_BBM_*. Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
1 parent 39e0195 commit 04649ec

11 files changed

Lines changed: 34 additions & 20 deletions

File tree

‎drivers/mtd/nand/raw/nand_amd.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static void amd_nand_decode_id(struct nand_chip *chip)
4545
static int amd_nand_init(struct nand_chip *chip)
4646
{
4747
if (nand_is_slc(chip))
48-
chip->bbt_options |= NAND_BBT_SCAN2NDPAGE;
48+
chip->options |= NAND_BBM_SECONDPAGE;
4949

5050
return 0;
5151
}

‎drivers/mtd/nand/raw/nand_base.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -295,11 +295,11 @@ static int nand_block_bad(struct nand_chip *chip, loff_t ofs)
295295
int page, page_end, res;
296296
u8 bad;
297297

298-
if (chip->bbt_options & NAND_BBT_SCANLASTPAGE)
298+
if (chip->options & NAND_BBM_LASTPAGE)
299299
ofs += mtd->erasesize - mtd->writesize;
300300

301301
page = (int)(ofs >> chip->page_shift) & chip->pagemask;
302-
page_end = page + (chip->bbt_options & NAND_BBT_SCAN2NDPAGE ? 2 : 1);
302+
page_end = page + ((chip->options & NAND_BBM_SECONDPAGE) ? 2 : 1);
303303

304304
for (; page < page_end; page++) {
305305
res = chip->ecc.read_oob(chip, page);
@@ -507,7 +507,7 @@ static int nand_default_block_markbad(struct nand_chip *chip, loff_t ofs)
507507
ops.mode = MTD_OPS_PLACE_OOB;
508508

509509
/* Write to first/last page(s) if necessary */
510-
if (chip->bbt_options & NAND_BBT_SCANLASTPAGE)
510+
if (chip->options & NAND_BBM_LASTPAGE)
511511
ofs += mtd->erasesize - mtd->writesize;
512512
do {
513513
res = nand_do_write_oob(chip, ofs, &ops);
@@ -516,7 +516,7 @@ static int nand_default_block_markbad(struct nand_chip *chip, loff_t ofs)
516516

517517
i++;
518518
ofs += mtd->writesize;
519-
} while ((chip->bbt_options & NAND_BBT_SCAN2NDPAGE) && i < 2);
519+
} while ((chip->options & NAND_BBM_SECONDPAGE) && i < 2);
520520

521521
return ret;
522522
}
@@ -4513,9 +4513,9 @@ static void nand_decode_bbm_options(struct nand_chip *chip)
45134513

45144514
/* Set the bad block position */
45154515
if (mtd->writesize > 512 || (chip->options & NAND_BUSWIDTH_16))
4516-
chip->badblockpos = NAND_LARGE_BADBLOCK_POS;
4516+
chip->badblockpos = NAND_BBM_POS_LARGE;
45174517
else
4518-
chip->badblockpos = NAND_SMALL_BADBLOCK_POS;
4518+
chip->badblockpos = NAND_BBM_POS_SMALL;
45194519
}
45204520

45214521
static inline bool is_full_id_nand(struct nand_flash_dev *type)

‎drivers/mtd/nand/raw/nand_bbt.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ static int create_bbt(struct nand_chip *this, uint8_t *buf,
468468

469469
pr_info("Scanning device for bad blocks\n");
470470

471-
if (bd->options & NAND_BBT_SCAN2NDPAGE)
471+
if (this->options & NAND_BBM_SECONDPAGE)
472472
numpages = 2;
473473
else
474474
numpages = 1;
@@ -489,7 +489,7 @@ static int create_bbt(struct nand_chip *this, uint8_t *buf,
489489
from = (loff_t)startblock << this->bbt_erase_shift;
490490
}
491491

492-
if (this->bbt_options & NAND_BBT_SCANLASTPAGE)
492+
if (this->options & NAND_BBM_LASTPAGE)
493493
from += mtd->erasesize - (mtd->writesize * numpages);
494494

495495
for (i = startblock; i < numblocks; i++) {

‎drivers/mtd/nand/raw/nand_esmt.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static void esmt_nand_decode_id(struct nand_chip *chip)
3636
static int esmt_nand_init(struct nand_chip *chip)
3737
{
3838
if (nand_is_slc(chip))
39-
chip->bbt_options |= NAND_BBT_SCAN2NDPAGE;
39+
chip->options |= NAND_BBM_SECONDPAGE;
4040

4141
return 0;
4242
}

‎drivers/mtd/nand/raw/nand_hynix.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -688,9 +688,9 @@ static int hynix_nand_init(struct nand_chip *chip)
688688
int ret;
689689

690690
if (!nand_is_slc(chip))
691-
chip->bbt_options |= NAND_BBT_SCANLASTPAGE;
691+
chip->options |= NAND_BBM_LASTPAGE;
692692
else
693-
chip->bbt_options |= NAND_BBT_SCAN2NDPAGE;
693+
chip->options |= NAND_BBM_SECONDPAGE;
694694

695695
hynix = kzalloc(sizeof(*hynix), GFP_KERNEL);
696696
if (!hynix)

‎drivers/mtd/nand/raw/nand_macronix.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static void macronix_nand_fix_broken_get_timings(struct nand_chip *chip)
6262
static int macronix_nand_init(struct nand_chip *chip)
6363
{
6464
if (nand_is_slc(chip))
65-
chip->bbt_options |= NAND_BBT_SCAN2NDPAGE;
65+
chip->options |= NAND_BBM_SECONDPAGE;
6666

6767
macronix_nand_fix_broken_get_timings(chip);
6868

‎drivers/mtd/nand/raw/nand_micron.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ static int micron_nand_init(struct nand_chip *chip)
448448
goto err_free_manuf_data;
449449

450450
if (mtd->writesize == 2048)
451-
chip->bbt_options |= NAND_BBT_SCAN2NDPAGE;
451+
chip->options |= NAND_BBM_SECONDPAGE;
452452

453453
ondie = micron_supports_on_die_ecc(chip);
454454

‎drivers/mtd/nand/raw/nand_samsung.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ static int samsung_nand_init(struct nand_chip *chip)
131131
chip->options |= NAND_SAMSUNG_LP_OPTIONS;
132132

133133
if (!nand_is_slc(chip))
134-
chip->bbt_options |= NAND_BBT_SCANLASTPAGE;
134+
chip->options |= NAND_BBM_LASTPAGE;
135135
else
136-
chip->bbt_options |= NAND_BBT_SCAN2NDPAGE;
136+
chip->options |= NAND_BBM_SECONDPAGE;
137137

138138
return 0;
139139
}

‎drivers/mtd/nand/raw/nand_toshiba.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ static void toshiba_nand_decode_id(struct nand_chip *chip)
152152
static int toshiba_nand_init(struct nand_chip *chip)
153153
{
154154
if (nand_is_slc(chip))
155-
chip->bbt_options |= NAND_BBT_SCAN2NDPAGE;
155+
chip->options |= NAND_BBM_SECONDPAGE;
156156

157157
/* Check that chip is BENAND and ECC mode is on-die */
158158
if (nand_is_slc(chip) && chip->ecc.mode == NAND_ECC_ON_DIE &&

‎drivers/mtd/nand/raw/sh_flctl.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,12 @@ static const struct mtd_ooblayout_ops flctl_4secc_oob_largepage_ops = {
101101
static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
102102

103103
static struct nand_bbt_descr flctl_4secc_smallpage = {
104-
.options = NAND_BBT_SCAN2NDPAGE,
105104
.offs = 11,
106105
.len = 1,
107106
.pattern = scan_ff_pattern,
108107
};
109108

110109
static struct nand_bbt_descr flctl_4secc_largepage = {
111-
.options = NAND_BBT_SCAN2NDPAGE,
112110
.offs = 0,
113111
.len = 2,
114112
.pattern = scan_ff_pattern,
@@ -1179,6 +1177,8 @@ static int flctl_probe(struct platform_device *pdev)
11791177
if (pdata->flcmncr_val & SEL_16BIT)
11801178
nand->options |= NAND_BUSWIDTH_16;
11811179

1180+
nand->options |= NAND_BBM_SECONDPAGE;
1181+
11821182
pm_runtime_enable(&pdev->dev);
11831183
pm_runtime_resume(&pdev->dev);
11841184

0 commit comments

Comments
 (0)