mtd: onenand_base: onenand_verify bugfix for writepage non-aligned address
Linux-MTD Mailing List
linux-mtd at lists.infradead.org
Fri Mar 11 10:59:04 EST 2011
Gitweb: http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=e6da85685b2dec1e69e58366c22d1f883d6da575
Commit: e6da85685b2dec1e69e58366c22d1f883d6da575
Parent: b085058fe556328443f982d892c9657b3aff9d4a
Author: Roman Tereshonkov <roman.tereshonkov at nokia.com>
AuthorDate: Tue Feb 8 12:02:42 2011 +0200
Committer: David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Fri Mar 11 14:22:45 2011 +0000
mtd: onenand_base: onenand_verify bugfix for writepage non-aligned address
In onenand_verify function the address can be writepage non-aligned.
When a page is read for comparing the right offset should be used
for "this->verify_buf" to get the right matching with compared
"buf" buffer.
Signed-off-by: Roman Tereshonkov <roman.tereshonkov at nokia.com>
Signed-off-by: Adrian Hunter <adrian.hunter at nokia.com>
Acked-by: Kyungmin Park <kyungmin.park at samsung.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy at nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
drivers/mtd/onenand/onenand_base.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c
index 38e6d76..4205b94 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -1648,11 +1648,10 @@ static int onenand_verify(struct mtd_info *mtd, const u_char *buf, loff_t addr,
int ret = 0;
int thislen, column;
+ column = addr & (this->writesize - 1);
+
while (len != 0) {
- thislen = min_t(int, this->writesize, len);
- column = addr & (this->writesize - 1);
- if (column + thislen > this->writesize)
- thislen = this->writesize - column;
+ thislen = min_t(int, this->writesize - column, len);
this->command(mtd, ONENAND_CMD_READ, addr, this->writesize);
@@ -1666,12 +1665,13 @@ static int onenand_verify(struct mtd_info *mtd, const u_char *buf, loff_t addr,
this->read_bufferram(mtd, ONENAND_DATARAM, this->verify_buf, 0, mtd->writesize);
- if (memcmp(buf, this->verify_buf, thislen))
+ if (memcmp(buf, this->verify_buf + column, thislen))
return -EBADMSG;
len -= thislen;
buf += thislen;
addr += thislen;
+ column = 0;
}
return 0;
More information about the linux-mtd-cvs
mailing list