diff mbox

[2/2] nanddump: always check the first erase block

Message ID c0bf28b432c6f1e6e5ed634ff64afcf46762503a.1286871735.git.baruch@tkos.co.il
State Accepted
Commit 5ee3a1905e4ea852c936f92bc9b15b98032285ca
Headers show

Commit Message

Baruch Siach Oct. 12, 2010, 8:23 a.m. UTC
Check the first block even when start_addr is not eraseblock aligned.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
 nanddump.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

Comments

Artem Bityutskiy Oct. 16, 2010, 7:11 p.m. UTC | #1
On Tue, 2010-10-12 at 10:23 +0200, Baruch Siach wrote:
> Check the first block even when start_addr is not eraseblock aligned.
> 
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> ---
>  nanddump.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)

Pushed to mtd-utils, thanks!
diff mbox

Patch

diff --git a/nanddump.c b/nanddump.c
index d6d1352..9267a1c 100644
--- a/nanddump.c
+++ b/nanddump.c
@@ -283,7 +283,7 @@  int main(int argc, char * const argv[])
 	struct mtd_oob_buf oob = {0, 16, oobbuf};
 	mtd_info_t meminfo;
 	char pretty_buf[PRETTY_BUF_LEN];
-	int oobinfochanged = 0 ;
+	int oobinfochanged = 0, firstblock = 1;
 	struct nand_oobinfo old_oobinfo;
 	struct mtd_ecc_stats stat1, stat2;
 	bool eccstats = false;
@@ -405,8 +405,10 @@  int main(int argc, char * const argv[])
 		// new eraseblock , check for bad block
 		if (noskipbad) {
 			badblock = 0;
-		} else if (blockstart != (ofs & (~meminfo.erasesize + 1))) {
+		} else if (blockstart != (ofs & (~meminfo.erasesize + 1)) ||
+				firstblock) {
 			blockstart = ofs & (~meminfo.erasesize + 1);
+			firstblock = 0;
 			if ((badblock = ioctl(fd, MEMGETBADBLOCK, &blockstart)) < 0) {
 				perror("ioctl(MEMGETBADBLOCK)");
 				goto closeall;