9
0
Fork 0

mtd mtdraw: Fix partial page read

When reading parts of a page we have to limit the maximum bytes copied
to the remaining bytes of a page.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>
This commit is contained in:
Sascha Hauer 2012-09-15 16:54:47 +02:00
parent 526a745f68
commit 992c291e95
1 changed files with 2 additions and 1 deletions

View File

@ -128,7 +128,8 @@ static ssize_t mtdraw_read(struct cdev *cdev, void *buf, size_t count,
skip = offset % (mtd->writesize + mtd->oobsize);
while (ret > 0 && count > 0) {
toread = min_t(int, count, mtd->writesize + mtd->oobsize);
toread = min_t(int, toread,
mtd->writesize + mtd->oobsize - skip);
ret = mtdraw_read_unaligned(mtd, buf, toread,
skip, numpage++ * mtd->writesize);
buf += ret;