Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e6da8568 authored by Roman Tereshonkov's avatar Roman Tereshonkov Committed by David Woodhouse
Browse files

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: default avatarRoman Tereshonkov <roman.tereshonkov@nokia.com>
Signed-off-by: default avatarAdrian Hunter <adrian.hunter@nokia.com>
Acked-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent b085058f
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -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;

	while (len != 0) {
		thislen = min_t(int, this->writesize, len);
	column = addr & (this->writesize - 1);
		if (column + thislen > this->writesize)
			thislen = this->writesize - column;

	while (len != 0) {
		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;