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

Hugo Villeneuve hugo.villeneuve at lyrtech.com
Fri May 16 20:39:17 CEST 2008


This patch fixes an error when reporting the NAND erase
progress as in this example:
  U-Boot > nand erase 0000 800
  NAND erase: device 0 offset 0x0, size 0x800
  Erasing at 0x0 -- 6400% complete.

Signed-off-by: Hugo Villeneuve <hugo.villeneuve at lyrtech.com>
---

 drivers/mtd/nand/nand_util.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

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