Revert "generic: 5.4: Add 4B_OPCODES flag to w25q256"
[openwrt/openwrt.git] / target / linux / generic / pending-5.4 / 450-mtd-spi-nor-allow-NOR-driver-to-write-fewer-bytes-th.patch
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 @@ -2704,7 +2704,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