Skip to content

Commit

Permalink
fix comparison of ECC stats before and after mtd reads
Browse files Browse the repository at this point in the history
ECC errors are found by comparing the result of ioctl(ECCGETSTATS)
before and after the read.  But if an error was found causing us to go
to the next block, we'd compare the stats before the *first* read to
the stats after the second (third, fourth, etc.) reads, so we'd read
to the end of the partition without ever succeeding.  Fix logic so we
compare the values before and after each read independently.

Bug: 3162777
Change-Id: I5a13abd7243d2afd1d21bd98cbb233e5124b2e80
  • Loading branch information
Doug Zongker committed Nov 3, 2010
1 parent 51266d1 commit 5d6309e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mtdutils/mtdutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ static int read_block(const MtdPartition *partition, int fd, char *data)
fprintf(stderr, "mtd: ECC errors (%d soft, %d hard) at 0x%08llx\n",
after.corrected - before.corrected,
after.failed - before.failed, pos);
// copy the comparison baseline for the next read.
memcpy(&before, &after, sizeof(struct mtd_ecc_stats));
} else if ((mgbb = ioctl(fd, MEMGETBADBLOCK, &pos))) {
fprintf(stderr,
"mtd: MEMGETBADBLOCK returned %d at 0x%08llx (errno=%d)\n",
Expand Down

0 comments on commit 5d6309e

Please sign in to comment.