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:
parent
526a745f68
commit
992c291e95
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue