public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] [PATCH] Fix NAND erase progress error
@ 2008-05-16 18:39 Hugo Villeneuve
  2008-05-16 19:40 ` Scott Wood
  0 siblings, 1 reply; 12+ messages in thread
From: Hugo Villeneuve @ 2008-05-16 18:39 UTC (permalink / raw)
  To: u-boot

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@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;

^ permalink raw reply related	[flat|nested] 12+ messages in thread
* [U-Boot-Users] [PATCH] Fix NAND erase progress error
@ 2008-05-16  1:58 Hugo Villeneuve
  2008-05-15 22:24 ` Wolfgang Denk
  0 siblings, 1 reply; 12+ messages in thread
From: Hugo Villeneuve @ 2008-05-16  1:58 UTC (permalink / raw)
  To: u-boot

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;

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2008-05-16 20:54 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-16 18:39 [U-Boot-Users] [PATCH] Fix NAND erase progress error Hugo Villeneuve
2008-05-16 19:40 ` Scott Wood
2008-05-16 20:15   ` Hugo Villeneuve
2008-05-16 20:18     ` Scott Wood
2008-05-16 20:29       ` Hugo Villeneuve
2008-05-16 20:34         ` Scott Wood
2008-05-16 20:39           ` Hugo Villeneuve
2008-05-16 20:43             ` Scott Wood
2008-05-16 20:51               ` Hugo Villeneuve
2008-05-16 20:54                 ` Scott Wood
  -- strict thread matches above, loose matches on Subject: below --
2008-05-16  1:58 Hugo Villeneuve
2008-05-15 22:24 ` Wolfgang Denk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox