kernel: update myloader for linux 4.9
[openwrt/openwrt.git] / target / linux / generic / patches-4.4 / 045-mtd-devices-m25p80-add-support-for-mmap-read-request.patch
1 From 08922f644878c9163ada8df3ef9def89be1d5e90 Mon Sep 17 00:00:00 2001
2 From: Vignesh R <vigneshr@ti.com>
3 Date: Tue, 29 Mar 2016 11:16:17 +0530
4 Subject: [PATCH] mtd: devices: m25p80: add support for mmap read request
5
6 Certain SPI controllers may provide accelerated hardware interface to
7 read from m25p80 type flash devices in order to provide better read
8 performance. SPI core supports such devices with spi_flash_read() API.
9 Call spi_flash_read(), if supported, to make use of such interface.
10
11 Signed-off-by: Vignesh R <vigneshr@ti.com>
12 [Brian: add memset()]
13 Signed-off-by: Brian Norris <computersforpeace@gmail.com>
14 ---
15
16 --- a/drivers/mtd/devices/m25p80.c
17 +++ b/drivers/mtd/devices/m25p80.c
18 @@ -131,6 +131,28 @@ static int m25p80_read(struct spi_nor *n
19 /* convert the dummy cycles to the number of bytes */
20 dummy /= 8;
21
22 + if (spi_flash_read_supported(spi)) {
23 + struct spi_flash_read_message msg;
24 + int ret;
25 +
26 + memset(&msg, 0, sizeof(msg));
27 +
28 + msg.buf = buf;
29 + msg.from = from;
30 + msg.len = len;
31 + msg.read_opcode = nor->read_opcode;
32 + msg.addr_width = nor->addr_width;
33 + msg.dummy_bytes = dummy;
34 + /* TODO: Support other combinations */
35 + msg.opcode_nbits = SPI_NBITS_SINGLE;
36 + msg.addr_nbits = SPI_NBITS_SINGLE;
37 + msg.data_nbits = m25p80_rx_nbits(nor);
38 +
39 + ret = spi_flash_read(spi, &msg);
40 + *retlen = msg.retlen;
41 + return ret;
42 + }
43 +
44 spi_message_init(&m);
45 memset(t, 0, (sizeof t));
46