[PATCH 2/4] nandtest: Fix status print for NAND which size exceeds 4 GB

Stefan Riedmueller s.riedmueller at phytec.de
Tue Mar 30 07:50:38 BST 2021


Nandsize can be larger than 4 GB. So during status print the number of
blocks calculation needs to use 64 bit division.

Signed-off-by: Stefan Riedmueller <s.riedmueller at phytec.de>
---
 commands/nandtest.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/commands/nandtest.c b/commands/nandtest.c
index bfe4c4c0ed03..1bb59c7fdba5 100644
--- a/commands/nandtest.c
+++ b/commands/nandtest.c
@@ -178,12 +178,14 @@ static int erase_and_write(loff_t ofs, unsigned char *data,
 }
 
 /* Print stats of nandtest. */
-static void print_stats(int nr_passes, int length)
+static void print_stats(int nr_passes, loff_t length)
 {
 	unsigned int i;
+	uint64_t blocks = (uint64_t)length;
+
+	do_div(blocks, meminfo.erasesize);
 	printf("-------- Summary --------\n");
-	printf("Tested blocks		: %d\n", (length/meminfo.erasesize)
-			* nr_passes);
+	printf("Tested blocks		: %lld\n", blocks * nr_passes);
 
 	for (i = 0; i < MAX_ECC_BITS; i++)
 		printf("ECC %d bit error(s)	: %u\n", i + 1, ecc_stats[i]);
-- 
2.25.1




More information about the barebox mailing list