aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/bcm47xxpart.c
diff options
context:
space:
mode:
authorRafał Miłecki <zajec5@gmail.com>2013-01-06 10:08:35 -0500
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2013-02-04 02:26:30 -0500
commit648bdbee5d2cc3ff27370d05e7577ade8496bfd0 (patch)
tree4302c048de379367a8de5d5d563151fa7d456acf /drivers/mtd/bcm47xxpart.c
parent55bf75b7dd8ec875d048824f3cdecf8254e292e5 (diff)
mtd: bcm47xxpart: simplify size calculation to one loop
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Diffstat (limited to 'drivers/mtd/bcm47xxpart.c')
-rw-r--r--drivers/mtd/bcm47xxpart.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/mtd/bcm47xxpart.c b/drivers/mtd/bcm47xxpart.c
index e06d782489a6..06125eb59f14 100644
--- a/drivers/mtd/bcm47xxpart.c
+++ b/drivers/mtd/bcm47xxpart.c
@@ -169,11 +169,12 @@ static int bcm47xxpart_parse(struct mtd_info *master,
169 * Assume that partitions end at the beginning of the one they are 169 * Assume that partitions end at the beginning of the one they are
170 * followed by. 170 * followed by.
171 */ 171 */
172 for (i = 0; i < curr_part - 1; i++) 172 for (i = 0; i < curr_part; i++) {
173 parts[i].size = parts[i + 1].offset - parts[i].offset; 173 u64 next_part_offset = (i < curr_part - 1) ?
174 if (curr_part > 0) 174 parts[i + 1].offset : master->size;
175 parts[curr_part - 1].size = 175
176 master->size - parts[curr_part - 1].offset; 176 parts[i].size = next_part_offset - parts[i].offset;
177 }
177 178
178 *pparts = parts; 179 *pparts = parts;
179 return curr_part; 180 return curr_part;