diff options
author | Brian Norris <computersforpeace@gmail.com> | 2012-01-20 23:38:03 -0500 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2012-03-26 19:16:04 -0400 |
commit | df698621a5b39ced5ce527444cafd50c6fdc186d (patch) | |
tree | ae3316d7790e13ac7412309b9ca2ba8dde95c118 /drivers/mtd | |
parent | f0e0c09b88b23ec418c065739096e198e8d6be22 (diff) |
mtd: nand: move SCANLASTPAGE handling to the correct code block
As nand_default_block_markbad() is becoming more complex, it helps to
have code appear only in its relevant codepath(s). Here, the calculation
of `ofs' based on NAND_BBT_SCANLASTPAGE is only useful on paths where we
write bad block markers to OOB. We move the condition/calculation closer
to the `write' operation and update the comment to more correctly
describe the operation.
The variable `wr_ofs' is also used to help isolate our calculation of
the "write" offset from the usage of `ofs' to represent the eraseblock
offset. This will become useful when we reorder operations in the next
patch.
This patch should make no functional change.
Signed-off-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>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/nand/nand_base.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index c6603d4b25c8..b90206613108 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c | |||
@@ -411,9 +411,6 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs) | |||
411 | nand_erase_nand(mtd, &einfo, 0); | 411 | nand_erase_nand(mtd, &einfo, 0); |
412 | } | 412 | } |
413 | 413 | ||
414 | if (chip->bbt_options & NAND_BBT_SCANLASTPAGE) | ||
415 | ofs += mtd->erasesize - mtd->writesize; | ||
416 | |||
417 | /* Get block number */ | 414 | /* Get block number */ |
418 | block = (int)(ofs >> chip->bbt_erase_shift); | 415 | block = (int)(ofs >> chip->bbt_erase_shift); |
419 | if (chip->bbt) | 416 | if (chip->bbt) |
@@ -424,11 +421,12 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs) | |||
424 | ret = nand_update_bbt(mtd, ofs); | 421 | ret = nand_update_bbt(mtd, ofs); |
425 | else { | 422 | else { |
426 | struct mtd_oob_ops ops; | 423 | struct mtd_oob_ops ops; |
424 | loff_t wr_ofs = ofs; | ||
427 | 425 | ||
428 | nand_get_device(chip, mtd, FL_WRITING); | 426 | nand_get_device(chip, mtd, FL_WRITING); |
429 | 427 | ||
430 | /* | 428 | /* |
431 | * Write to first two pages if necessary. If we write to more | 429 | * Write to first/last page(s) if necessary. If we write to more |
432 | * than one location, the first error encountered quits the | 430 | * than one location, the first error encountered quits the |
433 | * procedure. | 431 | * procedure. |
434 | */ | 432 | */ |
@@ -442,11 +440,14 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs) | |||
442 | ops.len = ops.ooblen = 1; | 440 | ops.len = ops.ooblen = 1; |
443 | } | 441 | } |
444 | ops.mode = MTD_OPS_PLACE_OOB; | 442 | ops.mode = MTD_OPS_PLACE_OOB; |
443 | |||
444 | if (chip->bbt_options & NAND_BBT_SCANLASTPAGE) | ||
445 | wr_ofs += mtd->erasesize - mtd->writesize; | ||
445 | do { | 446 | do { |
446 | ret = nand_do_write_oob(mtd, ofs, &ops); | 447 | ret = nand_do_write_oob(mtd, wr_ofs, &ops); |
447 | 448 | ||
448 | i++; | 449 | i++; |
449 | ofs += mtd->writesize; | 450 | wr_ofs += mtd->writesize; |
450 | } while (!ret && (chip->bbt_options & NAND_BBT_SCAN2NDPAGE) && | 451 | } while (!ret && (chip->bbt_options & NAND_BBT_SCAN2NDPAGE) && |
451 | i < 2); | 452 | i < 2); |
452 | 453 | ||