[PATCH 3/8] mtd: mtdraw: do not write empty buffers

Sascha Hauer s.hauer at pengutronix.de
Fri Sep 21 04:18:15 PDT 2018


When a page is completely 0xff then do not write it since users
expect pages to be writable when they are empty.

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

diff --git a/drivers/mtd/mtdraw.c b/drivers/mtd/mtdraw.c
index 3ad9de80a2..bfae795bd7 100644
--- a/drivers/mtd/mtdraw.c
+++ b/drivers/mtd/mtdraw.c
@@ -165,6 +165,9 @@ static ssize_t mtdraw_blkwrite(struct mtd_info *mtd, const void *buf,
 	struct mtd_oob_ops ops;
 	int ret;
 
+	if (mtd_buf_all_ff(buf, mtd->writesize + mtd->oobsize))
+		return 0;
+
 	ops.mode = MTD_OPS_RAW;
 	ops.ooboffs = 0;
 	ops.datbuf = (void *)buf;
-- 
2.19.0




More information about the barebox mailing list