From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Sat, 20 Jan 2018 02:11:37 +0100 Subject: [U-Boot] [PATCH v9 04/12] drivers: spi: consider command bytes when sending transfers In-Reply-To: <20180120011145.12603-1-noltari@gmail.com> References: <1495135788-9152-1-git-send-email-noltari@gmail.com> <20180120011145.12603-1-noltari@gmail.com> Message-ID: <20180120011145.12603-5-noltari@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit To: u-boot@lists.denx.de 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 Reviewed-by: Simon Glass Reviewed-by: Daniel Schwierzeck Reviewed-by: Jagan Teki --- v9: no changes v8: no changes v7: no changes v6: no changes v5: no changes v4: no changes v3: Fix bug introduced in v2: sizeof(cmd) vs len v2: Introduce changes requested by Simon Glass: - Always include command bytes when determining max write size. drivers/mtd/spi/spi_flash.c | 2 +- include/spi.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c index e40e1c01de..294d9f9d79 100644 --- a/drivers/mtd/spi/spi_flash.c +++ b/drivers/mtd/spi/spi_flash.c @@ -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); diff --git a/include/spi.h b/include/spi.h index 4787454e59..5a7df1c706 100644 --- a/include/spi.h +++ b/include/spi.h @@ -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. */ -- 2.11.0