Commit bb592548 authored by Frieder Schrempf's avatar Frieder Schrempf Committed by Miquel Raynal
Browse files

mtd: nand: Make flags for bad block marker position more granular



To be able to check and set bad block markers in the first and
second page of a block independently of each other, we create
separate flags for both cases.

Previously NAND_BBM_SECONDPAGE meant, that both, the first and the
second page were used. With this patch NAND_BBM_FIRSTPAGE stands for
using the first page and NAND_BBM_SECONDPAGE for using the second
page.

This patch is only for preparation of subsequent changes and does
not implement the logic to actually handle both flags separately.

Signed-off-by: default avatarFrieder Schrempf <frieder.schrempf@kontron.de>
Reviewed-by: default avatarBoris Brezillon <bbrezillon@kernel.org>
Reviewed-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
parent c902467c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ static void amd_nand_decode_id(struct nand_chip *chip)
static int amd_nand_init(struct nand_chip *chip)
{
	if (nand_is_slc(chip))
		chip->options |= NAND_BBM_SECONDPAGE;
		chip->options |= NAND_BBM_FIRSTPAGE | NAND_BBM_SECONDPAGE;

	return 0;
}
+4 −2
Original line number Diff line number Diff line
@@ -299,7 +299,8 @@ static int nand_block_bad(struct nand_chip *chip, loff_t ofs)
		ofs += mtd->erasesize - mtd->writesize;

	page = (int)(ofs >> chip->page_shift) & chip->pagemask;
	page_end = page + ((chip->options & NAND_BBM_SECONDPAGE) ? 2 : 1);
	page_end = page + (((chip->options & NAND_BBM_FIRSTPAGE) &&
			    (chip->options & NAND_BBM_SECONDPAGE)) ? 2 : 1);

	for (; page < page_end; page++) {
		res = chip->ecc.read_oob(chip, page);
@@ -516,7 +517,8 @@ static int nand_default_block_markbad(struct nand_chip *chip, loff_t ofs)

		i++;
		ofs += mtd->writesize;
	} while ((chip->options & NAND_BBM_SECONDPAGE) && i < 2);
	} while ((chip->options & NAND_BBM_FIRSTPAGE) &&
		 (chip->options & NAND_BBM_SECONDPAGE) && i < 2);

	return ret;
}
+2 −1
Original line number Diff line number Diff line
@@ -468,7 +468,8 @@ static int create_bbt(struct nand_chip *this, uint8_t *buf,

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

	if (this->options & NAND_BBM_SECONDPAGE)
	if ((this->options & NAND_BBM_FIRSTPAGE) &&
	    (this->options & NAND_BBM_SECONDPAGE))
		numpages = 2;
	else
		numpages = 1;
+1 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ static void esmt_nand_decode_id(struct nand_chip *chip)
static int esmt_nand_init(struct nand_chip *chip)
{
	if (nand_is_slc(chip))
		chip->options |= NAND_BBM_SECONDPAGE;
		chip->options |= NAND_BBM_FIRSTPAGE | NAND_BBM_SECONDPAGE;

	return 0;
}
+1 −1
Original line number Diff line number Diff line
@@ -690,7 +690,7 @@ static int hynix_nand_init(struct nand_chip *chip)
	if (!nand_is_slc(chip))
		chip->options |= NAND_BBM_LASTPAGE;
	else
		chip->options |= NAND_BBM_SECONDPAGE;
		chip->options |= NAND_BBM_FIRSTPAGE | NAND_BBM_SECONDPAGE;

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