Commit 6910c136 authored by Atsushi Nemoto's avatar Atsushi Nemoto Committed by David Woodhouse

[MTD][MTDPART] Cleanup and document the erase region handling

Mostly simplifying the loops.  Now everything fits into 80 columns,
is easier to read and the finer details have extra comments.
Signed-off-by: default avatarJörn Engel <joern@logfs.org>
Signed-off-by: default avatarAtsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent b33a2887
...@@ -424,18 +424,24 @@ static struct mtd_part *add_one_partition(struct mtd_info *master, ...@@ -424,18 +424,24 @@ static struct mtd_part *add_one_partition(struct mtd_info *master,
} }
if (master->numeraseregions > 1) { if (master->numeraseregions > 1) {
/* Deal with variable erase size stuff */ /* Deal with variable erase size stuff */
int i; int i, max = master->numeraseregions;
u32 end = slave->offset + slave->mtd.size;
struct mtd_erase_region_info *regions = master->eraseregions; struct mtd_erase_region_info *regions = master->eraseregions;
/* Find the first erase regions which is part of this partition. */ /* Find the first erase regions which is part of this
for (i = 0; i < master->numeraseregions && regions[i].offset <= slave->offset; i++) * partition. */
for (i = 0; i < max && regions[i].offset <= slave->offset; i++)
; ;
/* The loop searched for the region _behind_ the first one */
i--;
for (i--; i < master->numeraseregions && regions[i].offset < slave->offset + slave->mtd.size; i++) { /* Pick biggest erasesize */
for (; i < max && regions[i].offset < end; i++) {
if (slave->mtd.erasesize < regions[i].erasesize) { if (slave->mtd.erasesize < regions[i].erasesize) {
slave->mtd.erasesize = regions[i].erasesize; slave->mtd.erasesize = regions[i].erasesize;
} }
} }
BUG_ON(slave->mtd.erasesize == 0);
} else { } else {
/* Single erase size */ /* Single erase size */
slave->mtd.erasesize = master->erasesize; slave->mtd.erasesize = master->erasesize;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment