]> err.no Git - linux-2.6/commitdiff
[MTD] Skip bad blocks when checking for RedBoot partition table
authorDavid Woodhouse <dwmw2@infradead.org>
Mon, 29 Oct 2007 01:57:02 +0000 (21:57 -0400)
committerDavid Woodhouse <dwmw2@infradead.org>
Mon, 29 Oct 2007 01:57:02 +0000 (21:57 -0400)
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
drivers/mtd/redboot.c

index a61351f88ec046d894bf07bc042907e2a22bb364..47474903263c377555b0a5c0fefad3af737c1c78 100644 (file)
@@ -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);