aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2007-10-28 21:57:02 -0400
committerDavid Woodhouse <dwmw2@infradead.org>2007-10-28 21:57:02 -0400
commit3c441baa0365ea7c3be9ee79f03e944289dd37e1 (patch)
treeac030573837c8df6086acec92e9d72814c19a4cd /drivers
parent9c37f3329ae098d4c17e8bec589a589bcbf0acff (diff)
[MTD] Skip bad blocks when checking for RedBoot partition table
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mtd/redboot.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/drivers/mtd/redboot.c b/drivers/mtd/redboot.c
index a61351f88ec0..47474903263c 100644
--- a/drivers/mtd/redboot.c
+++ b/drivers/mtd/redboot.c
@@ -59,16 +59,31 @@ static int parse_redboot_partitions(struct mtd_info *master,
59 static char nullstring[] = "unallocated"; 59 static char nullstring[] = "unallocated";
60#endif 60#endif
61 61
62 if ( directory < 0 ) {
63 offset = master->size + directory * master->erasesize;
64 while (master->block_isbad &&
65 master->block_isbad(master, offset)) {
66 if (!offset) {
67 nogood:
68 printk(KERN_NOTICE "Failed to find a non-bad block to check for RedBoot partition table\n");
69 return -EIO;
70 }
71 offset -= master->erasesize;
72 }
73 } else {
74 offset = directory * master->erasesize;
75 while (master->block_isbad &&
76 master->block_isbad(master, offset)) {
77 offset += master->erasesize;
78 if (offset == master->size)
79 goto nogood;
80 }
81 }
62 buf = vmalloc(master->erasesize); 82 buf = vmalloc(master->erasesize);
63 83
64 if (!buf) 84 if (!buf)
65 return -ENOMEM; 85 return -ENOMEM;
66 86
67 if ( directory < 0 )
68 offset = master->size + directory*master->erasesize;
69 else
70 offset = directory*master->erasesize;
71
72 printk(KERN_NOTICE "Searching for RedBoot partition table in %s at offset 0x%lx\n", 87 printk(KERN_NOTICE "Searching for RedBoot partition table in %s at offset 0x%lx\n",
73 master->name, offset); 88 master->name, offset);
74 89