diff options
author | Rafał Miłecki <zajec5@gmail.com> | 2013-01-06 10:08:35 -0500 |
---|---|---|
committer | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2013-02-04 02:26:30 -0500 |
commit | 648bdbee5d2cc3ff27370d05e7577ade8496bfd0 (patch) | |
tree | 4302c048de379367a8de5d5d563151fa7d456acf | |
parent | 55bf75b7dd8ec875d048824f3cdecf8254e292e5 (diff) |
mtd: bcm47xxpart: simplify size calculation to one loop
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
-rw-r--r-- | drivers/mtd/bcm47xxpart.c | 11 |
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; |