]> git.sur5r.net Git - u-boot/commitdiff
drivers: spi: consider command bytes when sending transfers
authorÁlvaro Fernández Rojas <noltari@gmail.com>
Tue, 23 Jan 2018 16:14:57 +0000 (17:14 +0100)
committerJagan Teki <jagan@amarulasolutions.com>
Wed, 24 Jan 2018 06:33:43 +0000 (12:03 +0530)
Command bytes are part of the written bytes and they should be taken into
account when sending a spi transfer.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Reviewed-by: Jagan Teki <jagan@openedev.com>
drivers/mtd/spi/spi_flash.c
include/spi.h

index e40e1c01deb369727ac5b820b00c7c643ae9b25e..294d9f9d79c6eb123dec396bd56fac801d8da860 100644 (file)
@@ -405,7 +405,7 @@ int spi_flash_cmd_write_ops(struct spi_flash *flash, u32 offset,
 
                if (spi->max_write_size)
                        chunk_len = min(chunk_len,
-                                       (size_t)spi->max_write_size);
+                                       spi->max_write_size - sizeof(cmd));
 
                spi_flash_addr(write_addr, cmd);
 
index 4787454e59e67ec0612d4100c4e7fef23a6bd550..5a7df1c7063610a71f2d08e4c1a75ce2b8777aed 100644 (file)
@@ -89,7 +89,7 @@ struct dm_spi_slave_platdata {
  * @max_read_size:     If non-zero, the maximum number of bytes which can
  *                     be read at once.
  * @max_write_size:    If non-zero, the maximum number of bytes which can
- *                     be written at once, excluding command bytes.
+ *                     be written at once.
  * @memory_map:                Address of read-only SPI flash access.
  * @flags:             Indication of SPI flags.
  */