2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-17 09:43:59 +08:00

UBI: gluebi: rename misleading variables

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>
This commit is contained in:
Ezequiel Garcia 2012-11-19 20:35:20 -03:00 committed by Artem Bityutskiy
parent d125a75342
commit 41c043842f

View File

@ -171,17 +171,17 @@ 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)
@ -189,11 +189,11 @@ static int gluebi_read(struct mtd_info *mtd, loff_t from, size_t len,
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;
}
@ -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);
@ -220,12 +220,12 @@ 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)
@ -233,11 +233,11 @@ static int gluebi_write(struct mtd_info *mtd, loff_t to, size_t len,
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;
}