aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/pending-4.14/450-mtd-m25p80-allow-fallback-from-spi_flash_read-to-reg.patch
blob: accd63df58c6eab10776800d9fcfc0627887f6e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
From: Felix Fietkau <nbd@nbd.name>
Date: Fri, 23 Feb 2018 17:12:16 +0100
Subject: [PATCH] mtd: m25p80: allow fallback from spi_flash_read to regular
 SPI transfer

Some flash controllers, e.g. on the ath79 platform can support a fast
flash read via memory mapping, but only if the flash chip is in
3-byte address mode.

Since spi_flash_read_supported does not have access to the same data as
spi_flash_read, the driver can't detect an unsupported call until m25p80
has decided to use spi_flash_read.

Allow the driver to indicate a fallback to a regular SPI transfer by
returning -EOPNOTSUPP

Signed-off-by: Felix Fietkau <nbd@nbd.name>
---

--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -170,9 +170,11 @@ static ssize_t m25p80_read(struct spi_no
 		msg.data_nbits = data_nbits;
 
 		ret = spi_flash_read(spi, &msg);
-		if (ret < 0)
-			return ret;
-		return msg.retlen;
+		if (ret != -EOPNOTSUPP) {
+			if (ret < 0)
+				return ret;
+			return msg.retlen;
+		}
 	}
 
 	spi_message_init(&m);