Commit c6012bbce6ce9ac3162aeb841b2502ba71e52af6

Authored by Andreas Fenkart
Committed by Tom Rini
1 parent e2c9351d5a

tools/env: pass bad block offset by value

the offset is not modified by linux ioctl call
see mtd_ioctl{drivers/mtd/mtdchar.c}
Makes the interface less ambiguous, since the caller can
now exclude a modification of blockstart

Signed-off-by: Andreas Fenkart <andreas.fenkart@digitalstrom.com>

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

... ... @@ -661,10 +661,10 @@
661 661 * > 0 - block is bad
662 662 * < 0 - failed to test
663 663 */
664   -static int flash_bad_block (int fd, uint8_t mtd_type, loff_t *blockstart)
  664 +static int flash_bad_block(int fd, uint8_t mtd_type, loff_t blockstart)
665 665 {
666 666 if (mtd_type == MTD_NANDFLASH) {
667   - int badblock = ioctl (fd, MEMGETBADBLOCK, blockstart);
  667 + int badblock = ioctl(fd, MEMGETBADBLOCK, &blockstart);
668 668  
669 669 if (badblock < 0) {
670 670 perror ("Cannot read bad block mark");
... ... @@ -674,7 +674,7 @@
674 674 if (badblock) {
675 675 #ifdef DEBUG
676 676 fprintf (stderr, "Bad block at 0x%llx, skipping\n",
677   - (unsigned long long) *blockstart);
  677 + (unsigned long long)blockstart);
678 678 #endif
679 679 return badblock;
680 680 }
... ... @@ -722,7 +722,7 @@
722 722  
723 723 /* This only runs once on NOR flash */
724 724 while (processed < count) {
725   - rc = flash_bad_block (fd, mtd_type, &blockstart);
  725 + rc = flash_bad_block(fd, mtd_type, blockstart);
726 726 if (rc < 0) /* block test failed */
727 727 return -1;
728 728  
... ... @@ -876,7 +876,7 @@
876 876  
877 877 /* This only runs once on NOR flash and SPI-dataflash */
878 878 while (processed < write_total) {
879   - rc = flash_bad_block (fd, mtd_type, &blockstart);
  879 + rc = flash_bad_block(fd, mtd_type, blockstart);
880 880 if (rc < 0) /* block test failed */
881 881 return rc;
882 882