mtd: nand: rename create_bbt()'s 'len' variable to 'numpages'
Rename 'len' variable of create_bbt/scan_block_fast/scan_block_full to 'numpages', since it really means number of pages to scan when searching for the BBM (and not the byte length of the scan). Signed-off-by: Shmulik Ladkani <shmulik.ladkani@gmail.com> Reviewed-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
This commit is contained in:
parent
19da4158d3
commit
eceb84b188
@ -401,7 +401,7 @@ static void read_abs_bbts(struct mtd_info *mtd, uint8_t *buf,
|
|||||||
/* Scan a given block full */
|
/* Scan a given block full */
|
||||||
static int scan_block_full(struct mtd_info *mtd, struct nand_bbt_descr *bd,
|
static int scan_block_full(struct mtd_info *mtd, struct nand_bbt_descr *bd,
|
||||||
loff_t offs, uint8_t *buf, size_t readlen,
|
loff_t offs, uint8_t *buf, size_t readlen,
|
||||||
int scanlen, int len)
|
int scanlen, int numpages)
|
||||||
{
|
{
|
||||||
int ret, j;
|
int ret, j;
|
||||||
|
|
||||||
@ -410,7 +410,7 @@ static int scan_block_full(struct mtd_info *mtd, struct nand_bbt_descr *bd,
|
|||||||
if (ret && !mtd_is_bitflip_or_eccerr(ret))
|
if (ret && !mtd_is_bitflip_or_eccerr(ret))
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
for (j = 0; j < len; j++, buf += scanlen) {
|
for (j = 0; j < numpages; j++, buf += scanlen) {
|
||||||
if (check_pattern(buf, scanlen, mtd->writesize, bd))
|
if (check_pattern(buf, scanlen, mtd->writesize, bd))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -419,7 +419,7 @@ static int scan_block_full(struct mtd_info *mtd, struct nand_bbt_descr *bd,
|
|||||||
|
|
||||||
/* Scan a given block partially */
|
/* Scan a given block partially */
|
||||||
static int scan_block_fast(struct mtd_info *mtd, struct nand_bbt_descr *bd,
|
static int scan_block_fast(struct mtd_info *mtd, struct nand_bbt_descr *bd,
|
||||||
loff_t offs, uint8_t *buf, int len)
|
loff_t offs, uint8_t *buf, int numpages)
|
||||||
{
|
{
|
||||||
struct mtd_oob_ops ops;
|
struct mtd_oob_ops ops;
|
||||||
int j, ret;
|
int j, ret;
|
||||||
@ -430,7 +430,7 @@ static int scan_block_fast(struct mtd_info *mtd, struct nand_bbt_descr *bd,
|
|||||||
ops.datbuf = NULL;
|
ops.datbuf = NULL;
|
||||||
ops.mode = MTD_OPS_PLACE_OOB;
|
ops.mode = MTD_OPS_PLACE_OOB;
|
||||||
|
|
||||||
for (j = 0; j < len; j++) {
|
for (j = 0; j < numpages; j++) {
|
||||||
/*
|
/*
|
||||||
* Read the full oob until read_oob is fixed to handle single
|
* Read the full oob until read_oob is fixed to handle single
|
||||||
* byte reads for 16 bit buswidth.
|
* byte reads for 16 bit buswidth.
|
||||||
@ -463,7 +463,7 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf,
|
|||||||
struct nand_bbt_descr *bd, int chip)
|
struct nand_bbt_descr *bd, int chip)
|
||||||
{
|
{
|
||||||
struct nand_chip *this = mtd->priv;
|
struct nand_chip *this = mtd->priv;
|
||||||
int i, numblocks, len, scanlen;
|
int i, numblocks, numpages, scanlen;
|
||||||
int startblock;
|
int startblock;
|
||||||
loff_t from;
|
loff_t from;
|
||||||
size_t readlen;
|
size_t readlen;
|
||||||
@ -471,11 +471,11 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf,
|
|||||||
pr_info("Scanning device for bad blocks\n");
|
pr_info("Scanning device for bad blocks\n");
|
||||||
|
|
||||||
if (bd->options & NAND_BBT_SCANALLPAGES)
|
if (bd->options & NAND_BBT_SCANALLPAGES)
|
||||||
len = 1 << (this->bbt_erase_shift - this->page_shift);
|
numpages = 1 << (this->bbt_erase_shift - this->page_shift);
|
||||||
else if (bd->options & NAND_BBT_SCAN2NDPAGE)
|
else if (bd->options & NAND_BBT_SCAN2NDPAGE)
|
||||||
len = 2;
|
numpages = 2;
|
||||||
else
|
else
|
||||||
len = 1;
|
numpages = 1;
|
||||||
|
|
||||||
if (!(bd->options & NAND_BBT_SCANEMPTY)) {
|
if (!(bd->options & NAND_BBT_SCANEMPTY)) {
|
||||||
/* We need only read few bytes from the OOB area */
|
/* We need only read few bytes from the OOB area */
|
||||||
@ -484,7 +484,7 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf,
|
|||||||
} else {
|
} else {
|
||||||
/* Full page content should be read */
|
/* Full page content should be read */
|
||||||
scanlen = mtd->writesize + mtd->oobsize;
|
scanlen = mtd->writesize + mtd->oobsize;
|
||||||
readlen = len * mtd->writesize;
|
readlen = numpages * mtd->writesize;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chip == -1) {
|
if (chip == -1) {
|
||||||
@ -508,7 +508,7 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this->bbt_options & NAND_BBT_SCANLASTPAGE)
|
if (this->bbt_options & NAND_BBT_SCANLASTPAGE)
|
||||||
from += mtd->erasesize - (mtd->writesize * len);
|
from += mtd->erasesize - (mtd->writesize * numpages);
|
||||||
|
|
||||||
for (i = startblock; i < numblocks;) {
|
for (i = startblock; i < numblocks;) {
|
||||||
int ret;
|
int ret;
|
||||||
@ -517,9 +517,9 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf,
|
|||||||
|
|
||||||
if (bd->options & NAND_BBT_SCANALLPAGES)
|
if (bd->options & NAND_BBT_SCANALLPAGES)
|
||||||
ret = scan_block_full(mtd, bd, from, buf, readlen,
|
ret = scan_block_full(mtd, bd, from, buf, readlen,
|
||||||
scanlen, len);
|
scanlen, numpages);
|
||||||
else
|
else
|
||||||
ret = scan_block_fast(mtd, bd, from, buf, len);
|
ret = scan_block_fast(mtd, bd, from, buf, numpages);
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user