[mtd-utils] nanddump: print ecc.stat info after reading

Gupta, Pekon pekon at ti.com
Fri May 10 04:32:50 EDT 2013


Hi Mike, 

One more request.. 
Shouldn't the following ecc.stat info moved after actual mtd_read() ?

fprintf(stderr, "ECC failed: %d\n", stat1.failed);
fprintf(stderr, "ECC corrected: %d\n", stat1.corrected);
fprintf(stderr, "Number of bad blocks: %d\n", stat1.badblocks);
fprintf(stderr, "Number of bbt blocks: %d\n", stat1.bbtblocks);

Currently this info is printed, before the actual reads happen on
MTD device. I'm not sure if this was intended for some other purpose?

-----------------------------------------------------------------

diff --git a/nanddump.c b/nanddump.c
index be458c6..ac0f299 100644
--- a/nanddump.c
+++ b/nanddump.c
        /* Open output file for writing. If file name is "-", write to standard
@@ -476,6 +464,18 @@ int main(int argc, char * const argv[])
                        write(ofd, oobbuf, mtd.oob_size);
        }

+       /* check if we can read ecc stats */
+       if (!noecc && !ioctl(fd, ECCGETSTATS, &stat1)) {
+               eccstats = true;
+               if (!quiet) {
+                       fprintf(stderr, "ECC failed: %d\n", stat1.failed);
+                       fprintf(stderr, "ECC corrected: %d\n", stat1.corrected);
+                       fprintf(stderr, "Number of bad blocks: %d\n", stat1.badblocks);
+                       fprintf(stderr, "Number of bbt blocks: %d\n", stat1.bbtblocks);
+               }
+       } else {
+                       perror("No ECC status information available");
+       }
        /* Close the output file and MTD device, free memory */
        close(fd);
        close(ofd);


with regards, pekon



More information about the linux-mtd mailing list