diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-12-18 07:06:51 -0500 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-12-23 05:23:40 -0500 |
commit | 4d61db4f87b527734ac0cc830dda8fcc4e2add2f (patch) | |
tree | 881cb7614a928ba004f588a82c064592f461fee3 /fs/ubifs/lpt.c | |
parent | af14a1ad792621942a03e4bd0e5f17b6e177e2e0 (diff) |
UBIFS: use nicer 64-bit math
Instead of using do_div(), use better primitives from
linux/math64.h.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'fs/ubifs/lpt.c')
-rw-r--r-- | fs/ubifs/lpt.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/fs/ubifs/lpt.c b/fs/ubifs/lpt.c index 6d914160ec55..b2792e84d245 100644 --- a/fs/ubifs/lpt.c +++ b/fs/ubifs/lpt.c | |||
@@ -43,8 +43,9 @@ | |||
43 | * mounted. | 43 | * mounted. |
44 | */ | 44 | */ |
45 | 45 | ||
46 | #include <linux/crc16.h> | ||
47 | #include "ubifs.h" | 46 | #include "ubifs.h" |
47 | #include <linux/crc16.h> | ||
48 | #include <linux/math64.h> | ||
48 | 49 | ||
49 | /** | 50 | /** |
50 | * do_calc_lpt_geom - calculate sizes for the LPT area. | 51 | * do_calc_lpt_geom - calculate sizes for the LPT area. |
@@ -135,15 +136,13 @@ static void do_calc_lpt_geom(struct ubifs_info *c) | |||
135 | int ubifs_calc_lpt_geom(struct ubifs_info *c) | 136 | int ubifs_calc_lpt_geom(struct ubifs_info *c) |
136 | { | 137 | { |
137 | int lebs_needed; | 138 | int lebs_needed; |
138 | uint64_t sz; | 139 | long long sz; |
139 | 140 | ||
140 | do_calc_lpt_geom(c); | 141 | do_calc_lpt_geom(c); |
141 | 142 | ||
142 | /* Verify that lpt_lebs is big enough */ | 143 | /* Verify that lpt_lebs is big enough */ |
143 | sz = c->lpt_sz * 2; /* Must have at least 2 times the size */ | 144 | sz = c->lpt_sz * 2; /* Must have at least 2 times the size */ |
144 | sz += c->leb_size - 1; | 145 | lebs_needed = div_u64(sz + c->leb_size - 1, c->leb_size); |
145 | do_div(sz, c->leb_size); | ||
146 | lebs_needed = sz; | ||
147 | if (lebs_needed > c->lpt_lebs) { | 146 | if (lebs_needed > c->lpt_lebs) { |
148 | ubifs_err("too few LPT LEBs"); | 147 | ubifs_err("too few LPT LEBs"); |
149 | return -EINVAL; | 148 | return -EINVAL; |
@@ -175,7 +174,7 @@ static int calc_dflt_lpt_geom(struct ubifs_info *c, int *main_lebs, | |||
175 | int *big_lpt) | 174 | int *big_lpt) |
176 | { | 175 | { |
177 | int i, lebs_needed; | 176 | int i, lebs_needed; |
178 | uint64_t sz; | 177 | long long sz; |
179 | 178 | ||
180 | /* Start by assuming the minimum number of LPT LEBs */ | 179 | /* Start by assuming the minimum number of LPT LEBs */ |
181 | c->lpt_lebs = UBIFS_MIN_LPT_LEBS; | 180 | c->lpt_lebs = UBIFS_MIN_LPT_LEBS; |
@@ -202,9 +201,7 @@ static int calc_dflt_lpt_geom(struct ubifs_info *c, int *main_lebs, | |||
202 | /* Now check there are enough LPT LEBs */ | 201 | /* Now check there are enough LPT LEBs */ |
203 | for (i = 0; i < 64 ; i++) { | 202 | for (i = 0; i < 64 ; i++) { |
204 | sz = c->lpt_sz * 4; /* Allow 4 times the size */ | 203 | sz = c->lpt_sz * 4; /* Allow 4 times the size */ |
205 | sz += c->leb_size - 1; | 204 | lebs_needed = div_u64(sz + c->leb_size - 1, c->leb_size); |
206 | do_div(sz, c->leb_size); | ||
207 | lebs_needed = sz; | ||
208 | if (lebs_needed > c->lpt_lebs) { | 205 | if (lebs_needed > c->lpt_lebs) { |
209 | /* Not enough LPT LEBs so try again with more */ | 206 | /* Not enough LPT LEBs so try again with more */ |
210 | c->lpt_lebs = lebs_needed; | 207 | c->lpt_lebs = lebs_needed; |