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@xxxxxxx> --- This fix applies to branch master and next. --- drivers/mtd/mtdraw.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/mtdraw.c b/drivers/mtd/mtdraw.c index b1cce3d..7abe235 100644 --- a/drivers/mtd/mtdraw.c +++ b/drivers/mtd/mtdraw.c @@ -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) { -- 1.7.5.4 _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox