Hi all,
this patch fixes a bug for 'nand erase' command: when bad blocks are present into erasing area, they were skipped but the erased size was updated anyway.

Regards,
Michele Jr De Candia


Signed-off-by: Michele Jr De Candia <michele.decan...@valueteam.com>

diff -Naur u-boot-trunk-orig/drivers/mtd/nand/nand_util.c u-boot-trunk/drivers/mtd/nand/nand_util.c
--- u-boot-trunk-orig/drivers/mtd/nand/nand_util.c	2009-06-15 11:16:04.000000000 +0200
+++ u-boot-trunk/drivers/mtd/nand/nand_util.c	2009-06-16 14:42:21.000000000 +0200
@@ -73,7 +73,7 @@
 {
 	struct jffs2_unknown_node cleanmarker;
 	erase_info_t erase;
-	ulong erase_length;
+	ulong erase_length, erased_length;
 	int bbtest = 1;
 	int result;
 	int percent_complete = -1;
@@ -119,8 +119,9 @@
 		erase_length = meminfo->erasesize;
 	}
 
+	erased_length = 0;
 	for (;
-	     erase.addr < opts->offset + erase_length;
+	     erased_length < erase_length;
 	     erase.addr += meminfo->erasesize) {
 
 		WATCHDOG_RESET ();
@@ -149,6 +150,8 @@
 			       mtd_device, result);
 			continue;
 		}
+		else
+			erased_length += erase.len;
 
 		/* format for JFFS2 ? */
 		if (opts->jffs2 && chip->ecc.layout->oobavail >= 8) {
@@ -169,9 +172,7 @@
 		}
 
 		if (!opts->quiet) {
-			unsigned long long n =(unsigned long long)
-				(erase.addr + meminfo->erasesize - opts->offset)
-				* 100;
+			unsigned long long n = erased_length * 100;
 			int percent;
 
 			do_div(n, erase_length);
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to