[openwrt/openwrt] kernel: m25p80: allow fallback from spi_flash_read to regular SPI transfer

LEDE Commits lede-commits at lists.infradead.org
Mon Feb 26 10:20:19 PST 2018


nbd pushed a commit to openwrt/openwrt.git, branch master:
https://git.lede-project.org/a49f6565b34c7defbe66cd03c2cb04752ec4dbe6

commit a49f6565b34c7defbe66cd03c2cb04752ec4dbe6
Author: Felix Fietkau <nbd at nbd.name>
AuthorDate: Fri Feb 23 17:33:21 2018 +0100

    kernel: m25p80: allow fallback from spi_flash_read to regular SPI transfer
    
    Signed-off-by: Felix Fietkau <nbd at nbd.name>
---
 ...low-to-pass-probe-types-via-platform-data.patch |  4 +--
 ...-consider-max-message-size-in-m25p80_read.patch |  2 +-
 ...allow-fallback-from-spi_flash_read-to-reg.patch | 36 ++++++++++++++++++++++
 ...allow-fallback-from-spi_flash_read-to-reg.patch | 36 ++++++++++++++++++++++
 ...MTD-m25p80-allow-loading-mtd-name-from-OF.patch |  4 +--
 ...MTD-m25p80-allow-loading-mtd-name-from-OF.patch |  4 +--
 6 files changed, 79 insertions(+), 7 deletions(-)

diff --git a/target/linux/ar71xx/patches-4.9/407-mtd-m25p80-allow-to-pass-probe-types-via-platform-data.patch b/target/linux/ar71xx/patches-4.9/407-mtd-m25p80-allow-to-pass-probe-types-via-platform-data.patch
index 4fa957e..418db2a 100644
--- a/target/linux/ar71xx/patches-4.9/407-mtd-m25p80-allow-to-pass-probe-types-via-platform-data.patch
+++ b/target/linux/ar71xx/patches-4.9/407-mtd-m25p80-allow-to-pass-probe-types-via-platform-data.patch
@@ -1,6 +1,6 @@
 --- a/drivers/mtd/devices/m25p80.c
 +++ b/drivers/mtd/devices/m25p80.c
-@@ -192,6 +192,7 @@ static ssize_t m25p80_read(struct spi_no
+@@ -194,6 +194,7 @@ static ssize_t m25p80_read(struct spi_no
   */
  static int m25p_probe(struct spi_device *spi)
  {
@@ -8,7 +8,7 @@
  	struct flash_platform_data	*data;
  	struct m25p *flash;
  	struct spi_nor *nor;
-@@ -244,8 +245,11 @@ static int m25p_probe(struct spi_device
+@@ -246,8 +247,11 @@ static int m25p_probe(struct spi_device
  	if (ret)
  		return ret;
  
diff --git a/target/linux/brcm63xx/patches-4.9/001-4.11-01-mtd-m25p80-consider-max-message-size-in-m25p80_read.patch b/target/linux/brcm63xx/patches-4.9/001-4.11-01-mtd-m25p80-consider-max-message-size-in-m25p80_read.patch
index e902701..9d41b3c 100644
--- a/target/linux/brcm63xx/patches-4.9/001-4.11-01-mtd-m25p80-consider-max-message-size-in-m25p80_read.patch
+++ b/target/linux/brcm63xx/patches-4.9/001-4.11-01-mtd-m25p80-consider-max-message-size-in-m25p80_read.patch
@@ -18,7 +18,7 @@ Signed-off-by: Cyrille Pitchen <cyrille.pitchen at atmel.com>
 
 --- a/drivers/mtd/devices/m25p80.c
 +++ b/drivers/mtd/devices/m25p80.c
-@@ -172,7 +172,8 @@ static ssize_t m25p80_read(struct spi_no
+@@ -174,7 +174,8 @@ static ssize_t m25p80_read(struct spi_no
  
  	t[1].rx_buf = buf;
  	t[1].rx_nbits = m25p80_rx_nbits(nor);
diff --git a/target/linux/generic/pending-4.14/450-mtd-m25p80-allow-fallback-from-spi_flash_read-to-reg.patch b/target/linux/generic/pending-4.14/450-mtd-m25p80-allow-fallback-from-spi_flash_read-to-reg.patch
new file mode 100644
index 0000000..accd63d
--- /dev/null
+++ b/target/linux/generic/pending-4.14/450-mtd-m25p80-allow-fallback-from-spi_flash_read-to-reg.patch
@@ -0,0 +1,36 @@
+From: Felix Fietkau <nbd at 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 at 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);
diff --git a/target/linux/generic/pending-4.9/450-mtd-m25p80-allow-fallback-from-spi_flash_read-to-reg.patch b/target/linux/generic/pending-4.9/450-mtd-m25p80-allow-fallback-from-spi_flash_read-to-reg.patch
new file mode 100644
index 0000000..feaf8cb
--- /dev/null
+++ b/target/linux/generic/pending-4.9/450-mtd-m25p80-allow-fallback-from-spi_flash_read-to-reg.patch
@@ -0,0 +1,36 @@
+From: Felix Fietkau <nbd at 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 at nbd.name>
+---
+
+--- a/drivers/mtd/devices/m25p80.c
++++ b/drivers/mtd/devices/m25p80.c
+@@ -155,9 +155,11 @@ static ssize_t m25p80_read(struct spi_no
+ 		msg.data_nbits = m25p80_rx_nbits(nor);
+ 
+ 		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);
diff --git a/target/linux/lantiq/patches-4.14/0022-MTD-m25p80-allow-loading-mtd-name-from-OF.patch b/target/linux/lantiq/patches-4.14/0022-MTD-m25p80-allow-loading-mtd-name-from-OF.patch
index 6cd456a..415c857 100644
--- a/target/linux/lantiq/patches-4.14/0022-MTD-m25p80-allow-loading-mtd-name-from-OF.patch
+++ b/target/linux/lantiq/patches-4.14/0022-MTD-m25p80-allow-loading-mtd-name-from-OF.patch
@@ -22,7 +22,7 @@ Signed-off-by: John Crispin <blogic at openwrt.org>
  
  #include <linux/mtd/mtd.h>
  #include <linux/mtd/partitions.h>
-@@ -243,6 +244,10 @@ static int m25p_probe(struct spi_device
+@@ -245,6 +246,10 @@ static int m25p_probe(struct spi_device
  	};
  	char *flash_name;
  	int ret;
@@ -33,7 +33,7 @@ Signed-off-by: John Crispin <blogic at openwrt.org>
  
  	data = dev_get_platdata(&spi->dev);
  
-@@ -281,6 +286,8 @@ static int m25p_probe(struct spi_device
+@@ -283,6 +288,8 @@ static int m25p_probe(struct spi_device
  
  	if (data && data->name)
  		nor->mtd.name = data->name;
diff --git a/target/linux/lantiq/patches-4.9/0022-MTD-m25p80-allow-loading-mtd-name-from-OF.patch b/target/linux/lantiq/patches-4.9/0022-MTD-m25p80-allow-loading-mtd-name-from-OF.patch
index f08db65..7617c14 100644
--- a/target/linux/lantiq/patches-4.9/0022-MTD-m25p80-allow-loading-mtd-name-from-OF.patch
+++ b/target/linux/lantiq/patches-4.9/0022-MTD-m25p80-allow-loading-mtd-name-from-OF.patch
@@ -22,7 +22,7 @@ Signed-off-by: John Crispin <blogic at openwrt.org>
  
  #include <linux/mtd/mtd.h>
  #include <linux/mtd/partitions.h>
-@@ -198,6 +199,10 @@ static int m25p_probe(struct spi_device
+@@ -200,6 +201,10 @@ static int m25p_probe(struct spi_device
  	enum read_mode mode = SPI_NOR_NORMAL;
  	char *flash_name;
  	int ret;
@@ -33,7 +33,7 @@ Signed-off-by: John Crispin <blogic at openwrt.org>
  
  	data = dev_get_platdata(&spi->dev);
  
-@@ -227,6 +232,8 @@ static int m25p_probe(struct spi_device
+@@ -229,6 +234,8 @@ static int m25p_probe(struct spi_device
  
  	if (data && data->name)
  		nor->mtd.name = data->name;



More information about the lede-commits mailing list