mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] mtd: core: initialize *retlen in mtd_write()
@ 2015-11-23  9:39 Sascha Hauer
  0 siblings, 0 replies; only message in thread
From: Sascha Hauer @ 2015-11-23  9:39 UTC (permalink / raw)
  To: Barebox List

Some mtd drivers like the spi-nor driver do not assign a value
to the retlen pointer but instead only add the bytes written
to *retlen. Users of mtd_write expect the variable to be initialized
by the mtd core though, so we have to do it in mtd_write(). The
same is done in mtd_read already.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mtd/core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c
index d873369..62307db 100644
--- a/drivers/mtd/core.c
+++ b/drivers/mtd/core.c
@@ -340,6 +340,8 @@ int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
 int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
 		const u_char *buf)
 {
+	*retlen = 0;
+
 	return mtd->write(mtd, to, len, retlen, buf);
 }
 
-- 
2.6.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

only message in thread, other threads:[~2015-11-23  9:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-23  9:39 [PATCH] mtd: core: initialize *retlen in mtd_write() Sascha Hauer

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