aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/brcm63xx/patches-4.4/000-4.8-01-mtd-spi-nor-change-return-value-of-read-write.patch
diff options
context:
space:
mode:
authorJonas Gorski <jonas.gorski@gmail.com>2017-02-07 12:01:46 +0100
committerJonas Gorski <jonas.gorski@gmail.com>2017-06-04 10:40:00 +0200
commit2a2b16210bbc8c5881286d2ff742f3bdf1a7fd9c (patch)
tree0ff5bf45a97c1f307913cff42583bbd92c7233fd /target/linux/brcm63xx/patches-4.4/000-4.8-01-mtd-spi-nor-change-return-value-of-read-write.patch
parentf62e02cf20c23b55e998edf6874c1a5de3a88c6d (diff)
downloadupstream-2a2b16210bbc8c5881286d2ff742f3bdf1a7fd9c.tar.gz
upstream-2a2b16210bbc8c5881286d2ff742f3bdf1a7fd9c.tar.bz2
upstream-2a2b16210bbc8c5881286d2ff742f3bdf1a7fd9c.zip
brcm63xx: backport upstream solution for SPI message size limits
Backport upstream solution for working around SPI controller maximum message sizes. Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
Diffstat (limited to 'target/linux/brcm63xx/patches-4.4/000-4.8-01-mtd-spi-nor-change-return-value-of-read-write.patch')
-rw-r--r--target/linux/brcm63xx/patches-4.4/000-4.8-01-mtd-spi-nor-change-return-value-of-read-write.patch149
1 files changed, 149 insertions, 0 deletions
diff --git a/target/linux/brcm63xx/patches-4.4/000-4.8-01-mtd-spi-nor-change-return-value-of-read-write.patch b/target/linux/brcm63xx/patches-4.4/000-4.8-01-mtd-spi-nor-change-return-value-of-read-write.patch
new file mode 100644
index 0000000000..31c24e51a1
--- /dev/null
+++ b/target/linux/brcm63xx/patches-4.4/000-4.8-01-mtd-spi-nor-change-return-value-of-read-write.patch
@@ -0,0 +1,149 @@
+From 59451e1233bd315c5379a631838a03d80e689581 Mon Sep 17 00:00:00 2001
+From: Michal Suchanek <hramrach@gmail.com>
+Date: Thu, 5 May 2016 17:31:47 -0700
+Subject: [PATCH 01/10] mtd: spi-nor: change return value of read/write
+
+Change the return value of spi-nor device read and write methods to
+allow returning amount of data transferred and errors as
+read(2)/write(2) does.
+
+Also, start handling positive returns in spi_nor_read(), since we want
+to convert drivers to start returning the read-length both via *retlen
+and the return code. (We don't need to do the same transition process
+for spi_nor_write(), since ->write() didn't used to have a return code
+at all.)
+
+Signed-off-by: Michal Suchanek <hramrach@gmail.com>
+Signed-off-by: Brian Norris <computersforpeace@gmail.com>
+Tested-by Cyrille Pitchen <cyrille.pitchen@atmel.com>
+Acked-by: Michal Suchanek <hramrach@gmail.com>
+Tested-by: Michal Suchanek <hramrach@gmail.com>
+---
+ drivers/mtd/devices/m25p80.c | 5 +++--
+ drivers/mtd/spi-nor/fsl-quadspi.c | 5 +++--
+ drivers/mtd/spi-nor/nxp-spifi.c | 12 ++++++------
+ drivers/mtd/spi-nor/spi-nor.c | 5 ++++-
+ include/linux/mtd/spi-nor.h | 4 ++--
+ 6 files changed, 36 insertions(+), 21 deletions(-)
+
+--- a/drivers/mtd/devices/m25p80.c
++++ b/drivers/mtd/devices/m25p80.c
+@@ -73,7 +73,7 @@ static int m25p80_write_reg(struct spi_n
+ return spi_write(spi, flash->command, len + 1);
+ }
+
+-static void m25p80_write(struct spi_nor *nor, loff_t to, size_t len,
++static ssize_t m25p80_write(struct spi_nor *nor, loff_t to, size_t len,
+ size_t *retlen, const u_char *buf)
+ {
+ struct m25p *flash = nor->priv;
+@@ -101,6 +101,7 @@ static void m25p80_write(struct spi_nor
+ spi_sync(spi, &m);
+
+ *retlen += m.actual_length - cmd_sz;
++ return 0;
+ }
+
+ static inline unsigned int m25p80_rx_nbits(struct spi_nor *nor)
+@@ -119,7 +120,7 @@ static inline unsigned int m25p80_rx_nbi
+ * Read an address range from the nor chip. The address range
+ * may be any size provided it is within the physical boundaries.
+ */
+-static int m25p80_read(struct spi_nor *nor, loff_t from, size_t len,
++static ssize_t m25p80_read(struct spi_nor *nor, loff_t from, size_t len,
+ size_t *retlen, u_char *buf)
+ {
+ struct m25p *flash = nor->priv;
+--- a/drivers/mtd/spi-nor/fsl-quadspi.c
++++ b/drivers/mtd/spi-nor/fsl-quadspi.c
+@@ -822,7 +822,7 @@ static int fsl_qspi_write_reg(struct spi
+ return ret;
+ }
+
+-static void fsl_qspi_write(struct spi_nor *nor, loff_t to,
++static ssize_t fsl_qspi_write(struct spi_nor *nor, loff_t to,
+ size_t len, size_t *retlen, const u_char *buf)
+ {
+ struct fsl_qspi *q = nor->priv;
+@@ -832,9 +832,10 @@ static void fsl_qspi_write(struct spi_no
+
+ /* invalid the data in the AHB buffer. */
+ fsl_qspi_invalid(q);
++ return 0;
+ }
+
+-static int fsl_qspi_read(struct spi_nor *nor, loff_t from,
++static ssize_t fsl_qspi_read(struct spi_nor *nor, loff_t from,
+ size_t len, size_t *retlen, u_char *buf)
+ {
+ struct fsl_qspi *q = nor->priv;
+--- a/drivers/mtd/spi-nor/nxp-spifi.c
++++ b/drivers/mtd/spi-nor/nxp-spifi.c
+@@ -172,8 +172,8 @@ static int nxp_spifi_write_reg(struct sp
+ return nxp_spifi_wait_for_cmd(spifi);
+ }
+
+-static int nxp_spifi_read(struct spi_nor *nor, loff_t from, size_t len,
+- size_t *retlen, u_char *buf)
++static ssize_t nxp_spifi_read(struct spi_nor *nor, loff_t from, size_t len,
++ size_t *retlen, u_char *buf)
+ {
+ struct nxp_spifi *spifi = nor->priv;
+ int ret;
+@@ -188,8 +188,8 @@ static int nxp_spifi_read(struct spi_nor
+ return 0;
+ }
+
+-static void nxp_spifi_write(struct spi_nor *nor, loff_t to, size_t len,
+- size_t *retlen, const u_char *buf)
++static ssize_t nxp_spifi_write(struct spi_nor *nor, loff_t to, size_t len,
++ size_t *retlen, const u_char *buf)
+ {
+ struct nxp_spifi *spifi = nor->priv;
+ u32 cmd;
+@@ -197,7 +197,7 @@ static void nxp_spifi_write(struct spi_n
+
+ ret = nxp_spifi_set_memory_mode_off(spifi);
+ if (ret)
+- return;
++ return ret;
+
+ writel(to, spifi->io_base + SPIFI_ADDR);
+ *retlen += len;
+@@ -212,7 +212,7 @@ static void nxp_spifi_write(struct spi_n
+ while (len--)
+ writeb(*buf++, spifi->io_base + SPIFI_DATA);
+
+- nxp_spifi_wait_for_cmd(spifi);
++ return nxp_spifi_wait_for_cmd(spifi);
+ }
+
+ static int nxp_spifi_erase(struct spi_nor *nor, loff_t offs)
+--- a/drivers/mtd/spi-nor/spi-nor.c
++++ b/drivers/mtd/spi-nor/spi-nor.c
+@@ -893,7 +893,10 @@ static int spi_nor_read(struct mtd_info
+ ret = nor->read(nor, from, len, retlen, buf);
+
+ spi_nor_unlock_and_unprep(nor, SPI_NOR_OPS_READ);
+- return ret;
++ if (ret < 0)
++ return ret;
++
++ return 0;
+ }
+
+ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len,
+--- a/include/linux/mtd/spi-nor.h
++++ b/include/linux/mtd/spi-nor.h
+@@ -169,9 +169,9 @@ struct spi_nor {
+ int (*read_reg)(struct spi_nor *nor, u8 opcode, u8 *buf, int len);
+ int (*write_reg)(struct spi_nor *nor, u8 opcode, u8 *buf, int len);
+
+- int (*read)(struct spi_nor *nor, loff_t from,
++ ssize_t (*read)(struct spi_nor *nor, loff_t from,
+ size_t len, size_t *retlen, u_char *read_buf);
+- void (*write)(struct spi_nor *nor, loff_t to,
++ ssize_t (*write)(struct spi_nor *nor, loff_t to,
+ size_t len, size_t *retlen, const u_char *write_buf);
+ int (*erase)(struct spi_nor *nor, loff_t offs);
+