Commit 9b80aa8ec90d8606346573b92d098470fc320601

Authored by Scott Wood
1 parent eab2276458

nand: Don't call adjust_size_for_badblocks for erase

adjust_size_for_badblocks reduces the operation size to account
for the block skipping done by the read/write functions when an
interval (partition name or whole chip) is specified rather than a data
amount.

Erase does not do block skipping, except for erase.spread which takes
a data amount rather than an interval (and thus already does not call
adjust_size_for_badblocks).  Calling adjust_size_for_badblocks when
block skipping is not done means that if bad blocks are present,
the "nand erase.part" and "nand erase.chip" commands will fail to erase
blocks at the end of the interval.

Signed-off-by: Scott Wood <scottwood@freescale.com>
Cc: Harvey Chapman <hchapman@3gfp.com>
Acked-by: Heiko Schocher <hs@denx.de>

Showing 1 changed file with 1 additions and 8 deletions Side-by-side Diff

... ... @@ -426,7 +426,7 @@
426 426 }
427 427  
428 428 /* Adjust a chip/partition size down for bad blocks so we don't
429   - * read/write/erase past the end of a chip/partition by accident.
  429 + * read/write past the end of a chip/partition by accident.
430 430 */
431 431 static void adjust_size_for_badblocks(loff_t *size, loff_t offset, int dev)
432 432 {
... ... @@ -546,7 +546,6 @@
546 546 int scrub = !strncmp(cmd, "scrub", 5);
547 547 int spread = 0;
548 548 int args = 2;
549   - int adjust_size = 0;
550 549 const char *scrub_warn =
551 550 "Warning: "
552 551 "scrub option will erase all factory set bad blocks!\n"
553 552  
... ... @@ -563,10 +562,8 @@
563 562 spread = 1;
564 563 } else if (!strcmp(&cmd[5], ".part")) {
565 564 args = 1;
566   - adjust_size = 1;
567 565 } else if (!strcmp(&cmd[5], ".chip")) {
568 566 args = 0;
569   - adjust_size = 1;
570 567 } else {
571 568 goto usage;
572 569 }
... ... @@ -585,10 +582,6 @@
585 582 if (arg_off_size(argc - o, argv + o, &dev, &off, &size,
586 583 &maxsize) != 0)
587 584 return 1;
588   -
589   - /* size is unspecified */
590   - if (adjust_size && !scrub)
591   - adjust_size_for_badblocks(&size, off, dev);
592 585  
593 586 nand = &nand_info[dev];
594 587