mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] drivers/mtd: fix mtdraw write support
@ 2012-01-26 19:55 Robert Jarzmik
  2012-01-26 19:55 ` [PATCH] drivers/mtd: fix docg3 " Robert Jarzmik
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Robert Jarzmik @ 2012-01-26 19:55 UTC (permalink / raw)
  To: barebox

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>

---
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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-01-31  9:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-26 19:55 [PATCH] drivers/mtd: fix mtdraw write support Robert Jarzmik
2012-01-26 19:55 ` [PATCH] drivers/mtd: fix docg3 " Robert Jarzmik
2012-01-26 19:55 ` [PATCH] arm/mach-pxa: add standard LCD panel GPIO settings Robert Jarzmik
2012-01-26 19:55 ` [PATCH] arm/mach-pxa: add CCCR bits definitions Robert Jarzmik
2012-01-26 19:55 ` [PATCH] arm/mach-pxa: add pulse width modulator controller Robert Jarzmik
2012-01-27 11:42   ` Sascha Hauer
2012-01-27 16:07     ` Robert Jarzmik
2012-01-31  9:37       ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox