[U-Boot-Users] [PATCH] Fix NAND erase progress error

Hugo Villeneuve hugo.villeneuve at lyrtech.com
Fri May 16 03:58:53 CEST 2008


diff --git a/drivers/mtd/nand/nand_util.c b/drivers/mtd/nand/nand_util.c
index 6c5624a..bd21e04 100644
--- a/drivers/mtd/nand/nand_util.c
+++ b/drivers/mtd/nand/nand_util.c
@@ -209,10 +209,15 @@ int nand_erase_opts(nand_info_t *meminfo, const nand_erase_options_t *opts)
 		}
 
 		if (!opts->quiet) {
-			unsigned long long n =(unsigned long long)
-				(erase.addr + meminfo->erasesize - opts->offset)
-				* 100;
+			unsigned long long n;
 			int percent;
+			size_t erased_size = erase.addr - opts->offset + meminfo->erasesize;
+
+			if (erased_size > erase_length) {
+				erased_size = erase_length;
+			}
+
+			n = (unsigned long long) erased_size * 100;
 
 			do_div(n, erase_length);
 			percent = (int)n;




More information about the U-Boot mailing list