[MTD] Skip bad blocks when checking for RedBoot partition table

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Sun Oct 28 21:59:01 EDT 2007


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=3c441baa0365ea7c3be9ee79f03e944289dd37e1
Commit:     3c441baa0365ea7c3be9ee79f03e944289dd37e1
Parent:     9c37f3329ae098d4c17e8bec589a589bcbf0acff
Author:     David Woodhouse <dwmw2 at infradead.org>
AuthorDate: Sun Oct 28 21:57:02 2007 -0400
Committer:  David Woodhouse <dwmw2 at infradead.org>
CommitDate: Sun Oct 28 21:57:02 2007 -0400

    [MTD] Skip bad blocks when checking for RedBoot partition table
    
    Signed-off-by: David Woodhouse <dwmw2 at infradead.org>
---
 drivers/mtd/redboot.c |   25 ++++++++++++++++++++-----
 1 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/redboot.c b/drivers/mtd/redboot.c
index a61351f..4747490 100644
--- a/drivers/mtd/redboot.c
+++ b/drivers/mtd/redboot.c
@@ -59,16 +59,31 @@ static int parse_redboot_partitions(struct mtd_info *master,
 	static char nullstring[] = "unallocated";
 #endif
 
+	if ( directory < 0 ) {
+		offset = master->size + directory * master->erasesize;
+		while (master->block_isbad && 
+		       master->block_isbad(master, offset)) {
+			if (!offset) {
+			nogood:
+				printk(KERN_NOTICE "Failed to find a non-bad block to check for RedBoot partition table\n");
+				return -EIO;
+			}
+			offset -= master->erasesize;
+		}
+	} else {
+		offset = directory * master->erasesize;
+		while (master->block_isbad && 
+		       master->block_isbad(master, offset)) {
+			offset += master->erasesize;
+			if (offset == master->size)
+				goto nogood;
+		}
+	}
 	buf = vmalloc(master->erasesize);
 
 	if (!buf)
 		return -ENOMEM;
 
-	if ( directory < 0 )
-		offset = master->size + directory*master->erasesize;
-	else
-		offset = directory*master->erasesize;
-
 	printk(KERN_NOTICE "Searching for RedBoot partition table in %s at offset 0x%lx\n",
 	       master->name, offset);
 



More information about the linux-mtd-cvs mailing list