diff mbox

[U-Boot] fix: nand: Fix nand RW access wrappers

Message ID 1487770159-13056-1-git-send-email-kostap@marvell.com
State Deferred
Delegated to: Scott Wood
Headers show

Commit Message

Kostya Porotchkin Feb. 22, 2017, 1:29 p.m. UTC
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 mbox

Patch

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)