Skip to content

Commit bfd15c9

Browse files
fschrempfmiquelraynal
authored andcommitted
mtd: onenand: Store bad block marker position 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 the chip struct, as we did it for rawnand. 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 04649ec commit bfd15c9

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

‎drivers/mtd/nand/onenand/onenand_base.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2458,7 +2458,7 @@ static int onenand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)
24582458
bbm->bbt[block >> 2] |= 0x01 << ((block & 0x03) << 1);
24592459

24602460
/* We write two bytes, so we don't have to mess with 16-bit access */
2461-
ofs += mtd->oobsize + (bbm->badblockpos & ~0x01);
2461+
ofs += mtd->oobsize + (this->badblockpos & ~0x01);
24622462
/* FIXME : What to do when marking SLC block in partition
24632463
* with MLC erasesize? For now, it is not advisable to
24642464
* create partitions containing both SLC and MLC regions.
@@ -3967,6 +3967,9 @@ int onenand_scan(struct mtd_info *mtd, int maxchips)
39673967
if (!(this->options & ONENAND_SKIP_INITIAL_UNLOCKING))
39683968
this->unlock_all(mtd);
39693969

3970+
/* Set the bad block marker position */
3971+
this->badblockpos = ONENAND_BADBLOCK_POS;
3972+
39703973
ret = this->scan_bbt(mtd);
39713974
if ((!FLEXONENAND(this)) || ret)
39723975
return ret;

‎drivers/mtd/nand/onenand/onenand_bbt.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,6 @@ static int onenand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd)
190190
if (!bbm->bbt)
191191
return -ENOMEM;
192192

193-
/* Set the bad block position */
194-
bbm->badblockpos = ONENAND_BADBLOCK_POS;
195-
196193
/* Set erase shift */
197194
bbm->bbt_erase_shift = this->erase_shift;
198195

‎include/linux/mtd/onenand.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ struct onenand_chip {
9494
unsigned int technology;
9595
unsigned int density_mask;
9696
unsigned int options;
97+
unsigned int badblockpos;
9798

9899
unsigned int erase_shift;
99100
unsigned int page_shift;
@@ -188,6 +189,8 @@ struct onenand_chip {
188189
/* Check byte access in OneNAND */
189190
#define ONENAND_CHECK_BYTE_ACCESS(addr) (addr & 0x1)
190191

192+
#define ONENAND_BADBLOCK_POS 0
193+
191194
/*
192195
* Options bits
193196
*/

0 commit comments

Comments
 (0)