mtd: m25p80: consider max message size in m25p80_read

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Sun Feb 12 18:59:09 PST 2017


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=9e276de6a367cde07c1a63522152985d4e5cca8b
Commit:     9e276de6a367cde07c1a63522152985d4e5cca8b
Parent:     9e84609e8cdb4ce841cc2f9a217996a0b1198d29
Author:     Heiner Kallweit <hkallweit1 at gmail.com>
AuthorDate: Fri Oct 28 07:58:46 2016 +0200
Committer:  Cyrille Pitchen <cyrille.pitchen at atmel.com>
CommitDate: Fri Feb 10 13:54:55 2017 +0100

    mtd: m25p80: consider max message size in m25p80_read
    
    Consider a message size limit when calculating the maximum amount
    of data that can be read.
    
    The message size limit has been introduced with 4.9, so cc it
    to stable.
    
    Signed-off-by: Heiner Kallweit <hkallweit1 at gmail.com>
    Signed-off-by: Cyrille Pitchen <cyrille.pitchen at atmel.com>
---
 drivers/mtd/devices/m25p80.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 9cf7fcd..16a7df2 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -172,7 +172,8 @@ static ssize_t m25p80_read(struct spi_nor *nor, loff_t from, size_t len,
 
 	t[1].rx_buf = buf;
 	t[1].rx_nbits = m25p80_rx_nbits(nor);
-	t[1].len = min(len, spi_max_transfer_size(spi));
+	t[1].len = min3(len, spi_max_transfer_size(spi),
+			spi_max_message_size(spi) - t[0].len);
 	spi_message_add_tail(&t[1], &m);
 
 	ret = spi_sync(spi, &m);



More information about the linux-mtd-cvs mailing list