Skip to content

Commit

Permalink
[MTD][MTDPART] Cleanup and document the erase region handling
Browse files Browse the repository at this point in the history
Mostly simplifying the loops.  Now everything fits into 80 columns,
is easier to read and the finer details have extra comments.

Signed-off-by: Jörn Engel <joern@logfs.org>
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
Atsushi Nemoto authored and David Woodhouse committed Jul 25, 2008
1 parent b33a288 commit 6910c13
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions drivers/mtd/mtdpart.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,18 +424,24 @@ static struct mtd_part *add_one_partition(struct mtd_info *master,
}
if (master->numeraseregions > 1) {
/* 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;

/* Find the first erase regions which is part of this partition. */
for (i = 0; i < master->numeraseregions && regions[i].offset <= slave->offset; i++)
/* Find the first erase regions which is part of this
* 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) {
slave->mtd.erasesize = regions[i].erasesize;
}
}
BUG_ON(slave->mtd.erasesize == 0);
} else {
/* Single erase size */
slave->mtd.erasesize = master->erasesize;
Expand Down

0 comments on commit 6910c13

Please sign in to comment.