summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAtsushi Nemoto <anemo@mba.ocn.ne.jp>2008-07-19 01:00:57 +0900
committerDavid Woodhouse <David.Woodhouse@intel.com>2008-07-25 09:59:52 -0400
commit6910c1368104d50e6b6afc6c8b7e9d1670a374e7 (patch)
treeaf6d9e591f4c985cb8977552ce3b805750ade2c7
parentb33a2887396a1a5207e56459f62c4b132294ca58 (diff)
downloadop-kernel-dev-6910c1368104d50e6b6afc6c8b7e9d1670a374e7.zip
op-kernel-dev-6910c1368104d50e6b6afc6c8b7e9d1670a374e7.tar.gz
[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: 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>
-rw-r--r--drivers/mtd/mtdpart.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index 9cf73d3..5aac59c 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,
}
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;
OpenPOWER on IntegriCloud