mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Robert Jarzmik <robert.jarzmik@free.fr>
To: barebox@lists.infradead.org
Subject: [PATCH] drivers/mtd: fix mtdraw write support
Date: Thu, 26 Jan 2012 20:55:24 +0100	[thread overview]
Message-ID: <1327607728-2788-1-git-send-email-robert.jarzmik@free.fr> (raw)

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

             reply	other threads:[~2012-01-26 19:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-26 19:55 Robert Jarzmik [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1327607728-2788-1-git-send-email-robert.jarzmik@free.fr \
    --to=robert.jarzmik@free.fr \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox