diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2012-12-20 18:49:14 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-12-20 18:49:14 -0500 |
commit | 21e89c0c48bb799beb09181740796fc80c9676e2 (patch) | |
tree | bd5aef34a980f189ad41c75e881d225bc854bf44 /drivers/mtd/ubi/gluebi.c | |
parent | b911a6bdeef5848c468597d040e3407e0aee04ce (diff) | |
parent | 91c7fbbf63f33c77d8d28de624834a21888842bb (diff) |
Merge branch 'fscache' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs into for-linus
Diffstat (limited to 'drivers/mtd/ubi/gluebi.c')
-rw-r--r-- | drivers/mtd/ubi/gluebi.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/drivers/mtd/ubi/gluebi.c b/drivers/mtd/ubi/gluebi.c index 4bd4db8c84c9..b93807b4c459 100644 --- a/drivers/mtd/ubi/gluebi.c +++ b/drivers/mtd/ubi/gluebi.c | |||
@@ -171,17 +171,17 @@ static void gluebi_put_device(struct mtd_info *mtd) | |||
171 | static int gluebi_read(struct mtd_info *mtd, loff_t from, size_t len, | 171 | static int gluebi_read(struct mtd_info *mtd, loff_t from, size_t len, |
172 | size_t *retlen, unsigned char *buf) | 172 | size_t *retlen, unsigned char *buf) |
173 | { | 173 | { |
174 | int err = 0, lnum, offs, total_read; | 174 | int err = 0, lnum, offs, bytes_left; |
175 | struct gluebi_device *gluebi; | 175 | struct gluebi_device *gluebi; |
176 | 176 | ||
177 | gluebi = container_of(mtd, struct gluebi_device, mtd); | 177 | gluebi = container_of(mtd, struct gluebi_device, mtd); |
178 | lnum = div_u64_rem(from, mtd->erasesize, &offs); | 178 | lnum = div_u64_rem(from, mtd->erasesize, &offs); |
179 | total_read = len; | 179 | bytes_left = len; |
180 | while (total_read) { | 180 | while (bytes_left) { |
181 | size_t to_read = mtd->erasesize - offs; | 181 | size_t to_read = mtd->erasesize - offs; |
182 | 182 | ||
183 | if (to_read > total_read) | 183 | if (to_read > bytes_left) |
184 | to_read = total_read; | 184 | to_read = bytes_left; |
185 | 185 | ||
186 | err = ubi_read(gluebi->desc, lnum, buf, offs, to_read); | 186 | err = ubi_read(gluebi->desc, lnum, buf, offs, to_read); |
187 | if (err) | 187 | if (err) |
@@ -189,11 +189,11 @@ static int gluebi_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
189 | 189 | ||
190 | lnum += 1; | 190 | lnum += 1; |
191 | offs = 0; | 191 | offs = 0; |
192 | total_read -= to_read; | 192 | bytes_left -= to_read; |
193 | buf += to_read; | 193 | buf += to_read; |
194 | } | 194 | } |
195 | 195 | ||
196 | *retlen = len - total_read; | 196 | *retlen = len - bytes_left; |
197 | return err; | 197 | return err; |
198 | } | 198 | } |
199 | 199 | ||
@@ -211,7 +211,7 @@ static int gluebi_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
211 | static int gluebi_write(struct mtd_info *mtd, loff_t to, size_t len, | 211 | static int gluebi_write(struct mtd_info *mtd, loff_t to, size_t len, |
212 | size_t *retlen, const u_char *buf) | 212 | size_t *retlen, const u_char *buf) |
213 | { | 213 | { |
214 | int err = 0, lnum, offs, total_written; | 214 | int err = 0, lnum, offs, bytes_left; |
215 | struct gluebi_device *gluebi; | 215 | struct gluebi_device *gluebi; |
216 | 216 | ||
217 | gluebi = container_of(mtd, struct gluebi_device, mtd); | 217 | gluebi = container_of(mtd, struct gluebi_device, mtd); |
@@ -220,12 +220,12 @@ static int gluebi_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
220 | if (len % mtd->writesize || offs % mtd->writesize) | 220 | if (len % mtd->writesize || offs % mtd->writesize) |
221 | return -EINVAL; | 221 | return -EINVAL; |
222 | 222 | ||
223 | total_written = len; | 223 | bytes_left = len; |
224 | while (total_written) { | 224 | while (bytes_left) { |
225 | size_t to_write = mtd->erasesize - offs; | 225 | size_t to_write = mtd->erasesize - offs; |
226 | 226 | ||
227 | if (to_write > total_written) | 227 | if (to_write > bytes_left) |
228 | to_write = total_written; | 228 | to_write = bytes_left; |
229 | 229 | ||
230 | err = ubi_leb_write(gluebi->desc, lnum, buf, offs, to_write); | 230 | err = ubi_leb_write(gluebi->desc, lnum, buf, offs, to_write); |
231 | if (err) | 231 | if (err) |
@@ -233,11 +233,11 @@ static int gluebi_write(struct mtd_info *mtd, loff_t to, size_t len, | |||
233 | 233 | ||
234 | lnum += 1; | 234 | lnum += 1; |
235 | offs = 0; | 235 | offs = 0; |
236 | total_written -= to_write; | 236 | bytes_left -= to_write; |
237 | buf += to_write; | 237 | buf += to_write; |
238 | } | 238 | } |
239 | 239 | ||
240 | *retlen = len - total_written; | 240 | *retlen = len - bytes_left; |
241 | return err; | 241 | return err; |
242 | } | 242 | } |
243 | 243 | ||