diff options
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/mtdpart.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index 9cf73d360e78..5aac59c21ead 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c | |||
@@ -424,18 +424,24 @@ static struct mtd_part *add_one_partition(struct mtd_info *master, | |||
424 | } | 424 | } |
425 | if (master->numeraseregions > 1) { | 425 | if (master->numeraseregions > 1) { |
426 | /* Deal with variable erase size stuff */ | 426 | /* Deal with variable erase size stuff */ |
427 | int i; | 427 | int i, max = master->numeraseregions; |
428 | u32 end = slave->offset + slave->mtd.size; | ||
428 | struct mtd_erase_region_info *regions = master->eraseregions; | 429 | struct mtd_erase_region_info *regions = master->eraseregions; |
429 | 430 | ||
430 | /* Find the first erase regions which is part of this partition. */ | 431 | /* Find the first erase regions which is part of this |
431 | for (i = 0; i < master->numeraseregions && regions[i].offset <= slave->offset; i++) | 432 | * partition. */ |
433 | for (i = 0; i < max && regions[i].offset <= slave->offset; i++) | ||
432 | ; | 434 | ; |
435 | /* The loop searched for the region _behind_ the first one */ | ||
436 | i--; | ||
433 | 437 | ||
434 | for (i--; i < master->numeraseregions && regions[i].offset < slave->offset + slave->mtd.size; i++) { | 438 | /* Pick biggest erasesize */ |
439 | for (; i < max && regions[i].offset < end; i++) { | ||
435 | if (slave->mtd.erasesize < regions[i].erasesize) { | 440 | if (slave->mtd.erasesize < regions[i].erasesize) { |
436 | slave->mtd.erasesize = regions[i].erasesize; | 441 | slave->mtd.erasesize = regions[i].erasesize; |
437 | } | 442 | } |
438 | } | 443 | } |
444 | BUG_ON(slave->mtd.erasesize == 0); | ||
439 | } else { | 445 | } else { |
440 | /* Single erase size */ | 446 | /* Single erase size */ |
441 | slave->mtd.erasesize = master->erasesize; | 447 | slave->mtd.erasesize = master->erasesize; |