All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] fix: nand: Fix nand RW access wrappers
@ 2017-02-22 13:29 kostap at marvell.com
  0 siblings, 0 replies; only message in thread
From: kostap at marvell.com @ 2017-02-22 13:29 UTC (permalink / raw)
  To: u-boot

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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-02-22 13:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-22 13:29 [U-Boot] [PATCH] fix: nand: Fix nand RW access wrappers kostap at marvell.com

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.