Author: nbd
Date: 2015-10-05 13:34:16 +0200 (Mon, 05 Oct 2015)
New Revision: 47137

Modified:
   
trunk/target/linux/ramips/patches-3.18/0044-mtd-add-chunked-read-io-to-m25p80.patch
Log:
ramips: improve read performance of the m25p80 chunked io patch

Signed-off-by: Felix Fietkau <[email protected]>

Modified: 
trunk/target/linux/ramips/patches-3.18/0044-mtd-add-chunked-read-io-to-m25p80.patch
===================================================================
--- 
trunk/target/linux/ramips/patches-3.18/0044-mtd-add-chunked-read-io-to-m25p80.patch
 2015-10-05 10:29:01 UTC (rev 47136)
+++ 
trunk/target/linux/ramips/patches-3.18/0044-mtd-add-chunked-read-io-to-m25p80.patch
 2015-10-05 11:34:16 UTC (rev 47137)
@@ -16,10 +16,56 @@
        u8                      command[MAX_CMD_SIZE];
  };
  
-@@ -157,6 +159,61 @@ static int m25p80_read(struct spi_nor *n
+@@ -117,25 +119,14 @@ 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,
+-                      size_t *retlen, u_char *buf)
++static int __m25p80_read(struct spi_nor *nor, loff_t from, size_t len,
++                       size_t *retlen, u_char *buf)
+ {
+       struct m25p *flash = nor->priv;
+       struct spi_device *spi = flash->spi;
+       struct spi_transfer t[2];
+       struct spi_message m;
+       int dummy = nor->read_dummy;
+-      int ret;
+-
+-      /* Wait till previous write/erase is done. */
+-      ret = nor->wait_till_ready(nor);
+-      if (ret)
+-              return ret;
+-
+       spi_message_init(&m);
+       memset(t, 0, (sizeof t));
+ 
+@@ -156,6 +147,84 @@ static int m25p80_read(struct spi_nor *n
+       *retlen = m.actual_length - m25p_cmdsz(nor) - dummy;
        return 0;
  }
- 
++/*
++ * 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,
++                      size_t *retlen, u_char *buf)
++{
++      int ret;
++
++      /* Wait till previous write/erase is done. */
++      ret = nor->wait_till_ready(nor);
++      if (ret)
++              return ret;
++
++      return __m25p80_read(nor, from, len, retlen, buf);
++}
++
++
 +static void m25p80_chunked_write(struct spi_nor *nor, loff_t _from, size_t 
_len,
 +                      size_t *_retlen, const u_char *_buf)
 +{
@@ -52,7 +98,13 @@
 +{
 +      struct m25p *flash = nor->priv;
 +      int chunk_size;
++      int ret;
 +
++      /* Wait till previous write/erase is done. */
++      ret = nor->wait_till_ready(nor);
++      if (ret)
++              return ret;
++
 +      chunk_size = flash->chunk_size;
 +      if (!chunk_size)
 +              chunk_size = _len;
@@ -64,7 +116,7 @@
 +              u_char *buf = _buf + *_retlen;
 +              loff_t from = _from + *_retlen;
 +              int retlen = 0;
-+              int ret = m25p80_read(nor, from, len, &retlen, buf);
++              int ret = __m25p80_read(nor, from, len, &retlen, buf);
 +
 +              if (ret)
 +                      return ret;
@@ -74,11 +126,10 @@
 +
 +      return 0;
 +}
-+
+ 
  static int m25p80_erase(struct spi_nor *nor, loff_t offset)
  {
-       struct m25p *flash = nor->priv;
-@@ -197,6 +254,7 @@ static int m25p_probe(struct spi_device
+@@ -197,6 +266,7 @@ static int m25p_probe(struct spi_device
        struct spi_nor *nor;
        enum read_mode mode = SPI_NOR_NORMAL;
        char *flash_name = NULL;
@@ -86,7 +137,7 @@
        int ret;
  
        data = dev_get_platdata(&spi->dev);
-@@ -244,6 +302,14 @@ static int m25p_probe(struct spi_device
+@@ -244,6 +314,14 @@ static int m25p_probe(struct spi_device
        if (ret)
                return ret;
  
_______________________________________________
openwrt-commits mailing list
[email protected]
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-commits

Reply via email to