[MTD] Skip bad blocks when checking for RedBoot partition table
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
This commit is contained in:
parent
9c37f3329a
commit
3c441baa03
@ -59,16 +59,31 @@ static int parse_redboot_partitions(struct mtd_info *master,
|
|||||||
static char nullstring[] = "unallocated";
|
static char nullstring[] = "unallocated";
|
||||||
#endif
|
#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);
|
buf = vmalloc(master->erasesize);
|
||||||
|
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return -ENOMEM;
|
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",
|
printk(KERN_NOTICE "Searching for RedBoot partition table in %s at offset 0x%lx\n",
|
||||||
master->name, offset);
|
master->name, offset);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user