drivers/mtd: fix mtdraw write support
When unaligned writes are used, typically doing a cp file /dev/mtdraw0.foo, the alignement correction code was incorrectly handling such cases, and didn't return the expected number of written bytes. This was tested on a 528 block size. Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
8d6bfdaec7
commit
93125fda04
|
@ -191,8 +191,9 @@ static ssize_t mtdraw_write(struct cdev *cdev, const void *buf, size_t count,
|
|||
}
|
||||
|
||||
if (mtdraw->write_fill == bsz) {
|
||||
ret = mtdraw_blkwrite(mtd, mtdraw->writebuf, mtdraw->write_ofs);
|
||||
retlen += ret;
|
||||
numpage = mtdraw->write_ofs / (mtd->writesize + mtd->oobsize);
|
||||
ret = mtdraw_blkwrite(mtd, mtdraw->writebuf,
|
||||
mtd->writesize * numpage);
|
||||
mtdraw->write_fill = 0;
|
||||
}
|
||||
|
||||
|
@ -208,6 +209,7 @@ static ssize_t mtdraw_write(struct cdev *cdev, const void *buf, size_t count,
|
|||
if (ret >= 0 && count) {
|
||||
mtdraw->write_ofs = offset - mtdraw->write_fill;
|
||||
mtdraw_fillbuf(mtdraw, buf + retlen, count);
|
||||
retlen += count;
|
||||
}
|
||||
|
||||
if (ret < 0) {
|
||||
|
|
Loading…
Reference in New Issue