[PATCH] mtd-utils: tests: Fix nandbiterrs Failure Check

Harpreet Eli Sangha harpreet at nestlabs.com
Tue Jun 27 13:52:26 PDT 2017


From: "Harpreet \"Eli\" Sangha" <harpreet at nestlabs.com>

After a page read, the old failure statistics are compared against the
new failure statistics before the new values are actually read.

Signed-off-by: Harpreet "Eli" Sangha <harpreet at nestlabs.com>
---
 tests/mtd-tests/nandbiterrs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/mtd-tests/nandbiterrs.c b/tests/mtd-tests/nandbiterrs.c
index 6acbfee..de9d0dd 100644
--- a/tests/mtd-tests/nandbiterrs.c
+++ b/tests/mtd-tests/nandbiterrs.c
@@ -268,15 +268,15 @@ static int read_page(void)
 		return -1;
 	}
 
+	if (ioctl(fd, ECCGETSTATS, &new) != 0)
+		goto failstats;
+
 	if (new.failed > old.failed) {
 		fprintf(stderr, "Failed to recover %d bitflips\n",
 				new.failed - old.failed);
 		return -1;
 	}
 
-	if (ioctl(fd, ECCGETSTATS, &new) != 0)
-		goto failstats;
-
 	return new.corrected - old.corrected;
 failstats:
 	perror("ECCGETSTATS");
-- 
2.13.2.725.g09c95d1e9-goog




More information about the linux-mtd mailing list