| b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | From: Felix Fietkau <nbd@nbd.name> |
| 2 | Date: Thu, 22 Feb 2018 11:11:57 +0100 |
| 3 | Subject: [PATCH] mtd: spi-nor: allow NOR driver to write fewer bytes than |
| 4 | requested |
| 5 | |
| 6 | The write size can be constrained by the maximum message/transfer size |
| 7 | of the SPI controller. Only check for ret = 0 to avoid an infinite loop. |
| 8 | |
| 9 | Signed-off-by: Felix Fietkau <nbd@nbd.name> |
| 10 | --- |
| 11 | |
| 12 | --- a/drivers/mtd/spi-nor/spi-nor.c |
| 13 | +++ b/drivers/mtd/spi-nor/spi-nor.c |
| 14 | @@ -2708,7 +2708,7 @@ static int spi_nor_write(struct mtd_info |
| 15 | |
| 16 | write_enable(nor); |
| 17 | ret = spi_nor_write_data(nor, addr, page_remain, buf + i); |
| 18 | - if (ret < 0) |
| 19 | + if (ret <= 0) |
| 20 | goto write_err; |
| 21 | written = ret; |
| 22 | |