All of lore.kernel.org
 help / color / mirror / Atom feed
From: kostap at marvell.com <kostap@marvell.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] fix: nand: Fix nand RW access wrappers
Date: Wed, 22 Feb 2017 15:29:19 +0200	[thread overview]
Message-ID: <1487770159-13056-1-git-send-email-kostap@marvell.com> (raw)

From: Konstantin Porotchkin <kostap@marvell.com>

The inline functions nand_read and nand_write wrap calls
to mtd_read and mtd_write APIs.
The MTD APIs are using an additional parameter for returning
the amount of bytes actually handled by the RW operation.
The wrapper uses a pointer to the same input "len" parameter
for both input and output bytes count when calls to MTD API.
However the MTD finctions are zeroing the returning bytes
count at the beginning effectively zeroing the input/output
buffer length as well.

Signed-off-by: Konstantin Porotchkin <kostap@marvell.com>
Cc: Scott Wood <oss@buserror.net>
Cc: Stefan Roese <sr@denx.de>
---
 include/nand.h | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/include/nand.h b/include/nand.h
index b6eb223..8414c6c 100644
--- a/include/nand.h
+++ b/include/nand.h
@@ -48,13 +48,21 @@ extern struct mtd_info *nand_info[];
 static inline int nand_read(struct mtd_info *info, loff_t ofs, size_t *len,
 			    u_char *buf)
 {
-	return mtd_read(info, ofs, *len, (size_t *)len, buf);
+	size_t retlen;
+	int ret = mtd_read(info, ofs, *len, &retlen, buf);
+
+	*len = retlen;
+	return ret;
 }
 
 static inline int nand_write(struct mtd_info *info, loff_t ofs, size_t *len,
 			     u_char *buf)
 {
-	return mtd_write(info, ofs, *len, (size_t *)len, buf);
+	size_t retlen;
+	int ret = mtd_write(info, ofs, *len, &retlen, buf);
+
+	*len = retlen;
+	return ret;
 }
 
 static inline int nand_block_isbad(struct mtd_info *info, loff_t ofs)
-- 
2.7.4

                 reply	other threads:[~2017-02-22 13:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1487770159-13056-1-git-send-email-kostap@marvell.com \
    --to=kostap@marvell.com \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.