mtd: devices: m25p80: add support for mmap read request

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Mon May 23 21:59:02 PDT 2016


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=08922f644878c9163ada8df3ef9def89be1d5e90
Commit:     08922f644878c9163ada8df3ef9def89be1d5e90
Parent:     5651d6aaf489d1db48c253cf884b40214e91c2c5
Author:     Vignesh R <vigneshr at ti.com>
AuthorDate: Tue Mar 29 11:16:17 2016 +0530
Committer:  Brian Norris <computersforpeace at gmail.com>
CommitDate: Tue Apr 5 11:06:57 2016 -0700

    mtd: devices: m25p80: add support for mmap read request
    
    Certain SPI controllers may provide accelerated hardware interface to
    read from m25p80 type flash devices in order to provide better read
    performance. SPI core supports such devices with spi_flash_read() API.
    Call spi_flash_read(), if supported, to make use of such interface.
    
    Signed-off-by: Vignesh R <vigneshr at ti.com>
    [Brian: add memset()]
    Signed-off-by: Brian Norris <computersforpeace at gmail.com>
---
 drivers/mtd/devices/m25p80.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index c9c3b7f..9d68544 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -131,6 +131,28 @@ static int m25p80_read(struct spi_nor *nor, loff_t from, size_t len,
 	/* convert the dummy cycles to the number of bytes */
 	dummy /= 8;
 
+	if (spi_flash_read_supported(spi)) {
+		struct spi_flash_read_message msg;
+		int ret;
+
+		memset(&msg, 0, sizeof(msg));
+
+		msg.buf = buf;
+		msg.from = from;
+		msg.len = len;
+		msg.read_opcode = nor->read_opcode;
+		msg.addr_width = nor->addr_width;
+		msg.dummy_bytes = dummy;
+		/* TODO: Support other combinations */
+		msg.opcode_nbits = SPI_NBITS_SINGLE;
+		msg.addr_nbits = SPI_NBITS_SINGLE;
+		msg.data_nbits = m25p80_rx_nbits(nor);
+
+		ret = spi_flash_read(spi, &msg);
+		*retlen = msg.retlen;
+		return ret;
+	}
+
 	spi_message_init(&m);
 	memset(t, 0, (sizeof t));
 



More information about the linux-mtd-cvs mailing list