Skip to content

Commit

Permalink
UBI: gluebi: rename misleading variables
Browse files Browse the repository at this point in the history
Both names 'total_read' and 'total_written' are actually used
as the number of bytes left to read and write.
Fix this confusion by renaming both to 'bytes_left'.

Signed-off-by: Ezequiel Garcia <elezegarcia@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
  • Loading branch information
Ezequiel Garcia authored and Artem Bityutskiy committed Nov 30, 2012
1 parent d125a75 commit 41c0438
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions 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 41c0438

Please sign in to comment.