diff options
author | Felix Fietkau <nbd@openwrt.org> | 2014-08-07 12:40:53 +0000 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2014-08-07 12:40:53 +0000 |
commit | e41a0cafff16f2443e587884782172c6d8478771 (patch) | |
tree | 2ab441d85607622857c5d7602918d24312daa7ab /target/linux/ar71xx/patches-3.14/406-mtd-m25p80-allow-to-specify-max-read-size.patch | |
parent | f75f9606ad6af9f4c62acd45741a7e3880ad7dbb (diff) | |
download | upstream-e41a0cafff16f2443e587884782172c6d8478771.tar.gz upstream-e41a0cafff16f2443e587884782172c6d8478771.tar.bz2 upstream-e41a0cafff16f2443e587884782172c6d8478771.zip |
ar71xx: add linux 3.14 support
Signed-off-by: Zhao, Gang <gang.zhao.42@gmail.com>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
SVN-Revision: 42038
Diffstat (limited to 'target/linux/ar71xx/patches-3.14/406-mtd-m25p80-allow-to-specify-max-read-size.patch')
-rw-r--r-- | target/linux/ar71xx/patches-3.14/406-mtd-m25p80-allow-to-specify-max-read-size.patch | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/target/linux/ar71xx/patches-3.14/406-mtd-m25p80-allow-to-specify-max-read-size.patch b/target/linux/ar71xx/patches-3.14/406-mtd-m25p80-allow-to-specify-max-read-size.patch new file mode 100644 index 0000000000..194b8becb4 --- /dev/null +++ b/target/linux/ar71xx/patches-3.14/406-mtd-m25p80-allow-to-specify-max-read-size.patch @@ -0,0 +1,106 @@ +--- a/drivers/mtd/devices/m25p80.c ++++ b/drivers/mtd/devices/m25p80.c +@@ -115,6 +115,7 @@ struct m25p { + u8 program_opcode; + u8 *command; + enum read_type flash_read; ++ size_t max_read_len; + }; + + static inline struct m25p *mtd_to_m25p(struct mtd_info *mtd) +@@ -517,6 +518,7 @@ static int m25p80_read(struct mtd_info * + struct spi_message m; + uint8_t opcode; + int dummy; ++ loff_t ofs; + + pr_debug("%s: %s from 0x%08x, len %zd\n", dev_name(&flash->spi->dev), + __func__, (u32)from, len); +@@ -534,29 +536,51 @@ static int m25p80_read(struct mtd_info * + t[0].len = m25p_cmdsz(flash) + dummy; + spi_message_add_tail(&t[0], &m); + +- t[1].rx_buf = buf; +- t[1].rx_nbits = m25p80_rx_nbits(flash); +- t[1].len = len; + spi_message_add_tail(&t[1], &m); + + mutex_lock(&flash->lock); + +- /* Wait till previous write/erase is done. */ +- if (wait_till_ready(flash)) { +- /* REVISIT status return?? */ +- mutex_unlock(&flash->lock); +- return 1; +- } +- + /* Set up the write data buffer. */ + opcode = flash->read_opcode; + flash->command[0] = opcode; +- m25p_addr2cmd(flash, from, flash->command); ++ ofs = 0; ++ while (len) { ++ size_t readlen; ++ size_t done; ++ int ret; + +- spi_sync(flash->spi, &m); ++ ret = wait_till_ready(flash); ++ if (ret) { ++ mutex_unlock(&flash->lock); ++ return 1; ++ } ++ ++ if (flash->max_read_len > 0 && ++ flash->max_read_len < len) ++ readlen = flash->max_read_len; ++ else ++ readlen = len; + +- *retlen = m.actual_length - m25p_cmdsz(flash) - dummy; ++ t[1].rx_buf = buf + ofs; ++ t[1].rx_nbits = m25p80_rx_nbits(flash); ++ t[1].len = readlen; + ++ m25p_addr2cmd(flash, from + ofs, flash->command); ++ ++ spi_sync(flash->spi, &m); ++ ++ done = m.actual_length - m25p_cmdsz(flash) - ++ dummy; ++ if (done != readlen) { ++ mutex_unlock(&flash->lock); ++ return 1; ++ } ++ ++ ofs += done; ++ len -= done; ++ } ++ ++ *retlen = ofs; + mutex_unlock(&flash->lock); + + return 0; +@@ -1193,6 +1217,12 @@ static int m25p_probe(struct spi_device + flash->mtd._unlock = m25p80_unlock; + } + ++ if (data && data->max_read_len) { ++ flash->max_read_len = data->max_read_len; ++ dev_warn(&spi->dev, "max_read_len set to %d bytes\n", ++ flash->max_read_len); ++ } ++ + /* sst flash chips use AAI word program */ + if (info->flags & SST_WRITE) + flash->mtd._write = sst_write; +--- a/include/linux/spi/flash.h ++++ b/include/linux/spi/flash.h +@@ -25,6 +25,7 @@ struct flash_platform_data { + + char *type; + ++ size_t max_read_len; + /* we'll likely add more ... use JEDEC IDs, etc */ + }; + |