Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 347422
b: refs/heads/master
c: 41c0438
h: refs/heads/master
v: v3
  • Loading branch information
Ezequiel Garcia authored and Artem Bityutskiy committed Nov 30, 2012
1 parent 38f12b0 commit 7f0603b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d125a753425b9de3c251df519e521024c79c663d
refs/heads/master: 41c043842f047af682daf4940a1fc6dfc807bdbb
28 changes: 14 additions & 14 deletions trunk/drivers/mtd/ubi/gluebi.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,29 +171,29 @@ static void gluebi_put_device(struct mtd_info *mtd)
static int gluebi_read(struct mtd_info *mtd, loff_t from, size_t len,
size_t *retlen, unsigned char *buf)
{
int err = 0, lnum, offs, total_read;
int err = 0, lnum, offs, bytes_left;
struct gluebi_device *gluebi;

gluebi = container_of(mtd, struct gluebi_device, mtd);
lnum = div_u64_rem(from, mtd->erasesize, &offs);
total_read = len;
while (total_read) {
bytes_left = len;
while (bytes_left) {
size_t to_read = mtd->erasesize - offs;

if (to_read > total_read)
to_read = total_read;
if (to_read > bytes_left)
to_read = bytes_left;

err = ubi_read(gluebi->desc, lnum, buf, offs, to_read);
if (err)
break;

lnum += 1;
offs = 0;
total_read -= to_read;
bytes_left -= to_read;
buf += to_read;
}

*retlen = len - total_read;
*retlen = len - bytes_left;
return err;
}

Expand All @@ -211,7 +211,7 @@ static int gluebi_read(struct mtd_info *mtd, loff_t from, size_t len,
static int gluebi_write(struct mtd_info *mtd, loff_t to, size_t len,
size_t *retlen, const u_char *buf)
{
int err = 0, lnum, offs, total_written;
int err = 0, lnum, offs, bytes_left;
struct gluebi_device *gluebi;

gluebi = container_of(mtd, struct gluebi_device, mtd);
Expand All @@ -220,24 +220,24 @@ static int gluebi_write(struct mtd_info *mtd, loff_t to, size_t len,
if (len % mtd->writesize || offs % mtd->writesize)
return -EINVAL;

total_written = len;
while (total_written) {
bytes_left = len;
while (bytes_left) {
size_t to_write = mtd->erasesize - offs;

if (to_write > total_written)
to_write = total_written;
if (to_write > bytes_left)
to_write = bytes_left;

err = ubi_leb_write(gluebi->desc, lnum, buf, offs, to_write);
if (err)
break;

lnum += 1;
offs = 0;
total_written -= to_write;
bytes_left -= to_write;
buf += to_write;
}

*retlen = len - total_written;
*retlen = len - bytes_left;
return err;
}

Expand Down

0 comments on commit 7f0603b

Please sign in to comment.