Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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: default avatarFrieder Schrempf <frieder.schrempf@kontron.de>
Reviewed-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
parent 39e01956
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line 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)
static int amd_nand_init(struct nand_chip *chip)
{
{
	if (nand_is_slc(chip))
	if (nand_is_slc(chip))
		chip->bbt_options |= NAND_BBT_SCAN2NDPAGE;
		chip->options |= NAND_BBM_SECONDPAGE;


	return 0;
	return 0;
}
}
+6 −6
Original line number Original line Diff line number Diff line
@@ -295,11 +295,11 @@ static int nand_block_bad(struct nand_chip *chip, loff_t ofs)
	int page, page_end, res;
	int page, page_end, res;
	u8 bad;
	u8 bad;


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


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


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


	/* Write to first/last page(s) if necessary */
	/* Write to first/last page(s) if necessary */
	if (chip->bbt_options & NAND_BBT_SCANLASTPAGE)
	if (chip->options & NAND_BBM_LASTPAGE)
		ofs += mtd->erasesize - mtd->writesize;
		ofs += mtd->erasesize - mtd->writesize;
	do {
	do {
		res = nand_do_write_oob(chip, ofs, &ops);
		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)


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


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


	/* Set the bad block position */
	/* Set the bad block position */
	if (mtd->writesize > 512 || (chip->options & NAND_BUSWIDTH_16))
	if (mtd->writesize > 512 || (chip->options & NAND_BUSWIDTH_16))
		chip->badblockpos = NAND_LARGE_BADBLOCK_POS;
		chip->badblockpos = NAND_BBM_POS_LARGE;
	else
	else
		chip->badblockpos = NAND_SMALL_BADBLOCK_POS;
		chip->badblockpos = NAND_BBM_POS_SMALL;
}
}


static inline bool is_full_id_nand(struct nand_flash_dev *type)
static inline bool is_full_id_nand(struct nand_flash_dev *type)
+2 −2
Original line number Original line Diff line number Diff line
@@ -468,7 +468,7 @@ static int create_bbt(struct nand_chip *this, uint8_t *buf,


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


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


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


	for (i = startblock; i < numblocks; i++) {
	for (i = startblock; i < numblocks; i++) {
+1 −1
Original line number Original line 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)
static int esmt_nand_init(struct nand_chip *chip)
{
{
	if (nand_is_slc(chip))
	if (nand_is_slc(chip))
		chip->bbt_options |= NAND_BBT_SCAN2NDPAGE;
		chip->options |= NAND_BBM_SECONDPAGE;


	return 0;
	return 0;
}
}
+2 −2
Original line number Original line Diff line number Diff line
@@ -688,9 +688,9 @@ static int hynix_nand_init(struct nand_chip *chip)
	int ret;
	int ret;


	if (!nand_is_slc(chip))
	if (!nand_is_slc(chip))
		chip->bbt_options |= NAND_BBT_SCANLASTPAGE;
		chip->options |= NAND_BBM_LASTPAGE;
	else
	else
		chip->bbt_options |= NAND_BBT_SCAN2NDPAGE;
		chip->options |= NAND_BBM_SECONDPAGE;


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