Skip to contentSkip to conversation

mtd: spi-nor: allow NOR driver to write fewer bytes than requested

PATCH New Felix Fietkau 1 participant 1 message Feb 22, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: spi-nor: allow NOR driver to write fewer bytes than requested

The write size can be constrained by the maximum message/transfer size of the SPI controller. Only check for ret = 0 to avoid an infinite loop.

---
 drivers/mtd/spi-nor/spi-nor.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/mtd/spi-nor/spi-nor.c +1 -8
index 61de4cc3bd7f..c60802eb6aa3 100644
@@ -1392,7 +1392,7 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
 
 		write_enable(nor);
 		ret = nor->write(nor, addr, page_remain, buf + i);
-		if (ret < 0)
+		if (ret <= 0)
 			goto write_err;
 		written = ret;
 
@@ -1401,13 +1401,6 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
 			goto write_err;
 		*retlen += written;
 		i += written;
-		if (written != page_remain) {
-			dev_err(nor->dev,
-				"While writing %zu bytes written %zd bytes\n",
-				page_remain, written);
-			ret = -EIO;
-			goto write_err;
-		}
 	}
 
 write_err:
Signature · 1 line
2.14.2