diff options
author | Ye Li <ye.li@nxp.com> | 2019-07-10 09:23:51 +0000 |
---|---|---|
committer | Jagan Teki <jagan@amarulasolutions.com> | 2019-07-18 17:11:16 +0530 |
commit | 535b1fdb8e5e857b9d2747e5f1a1501ec85f327c (patch) | |
tree | be0fd3f742320707f12fafc611e58f8da21a02b0 /drivers/spi | |
parent | 0e80dda32c8d724c2a98dbbfb2f1e59762788f15 (diff) | |
download | u-boot-535b1fdb8e5e857b9d2747e5f1a1501ec85f327c.tar.gz u-boot-535b1fdb8e5e857b9d2747e5f1a1501ec85f327c.tar.xz u-boot-535b1fdb8e5e857b9d2747e5f1a1501ec85f327c.zip |
spi: spi-mem: Fix read data size issue
When slave drivers don't set the max_read_size, the spi-mem should directly
use data.nbytes and not limit to any size. But current logic will limit to
the max_write_size.
Signed-off-by: Ye Li <ye.li@nxp.com>
Acked-by: Vignesh Raghavendra <vigneshr@ti.com>
Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/spi-mem.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c index 7aabebeff5..7788ab9953 100644 --- a/drivers/spi/spi-mem.c +++ b/drivers/spi/spi-mem.c @@ -430,12 +430,14 @@ int spi_mem_adjust_op_size(struct spi_slave *slave, struct spi_mem_op *op) if (slave->max_write_size && len > slave->max_write_size) return -EINVAL; - if (op->data.dir == SPI_MEM_DATA_IN && slave->max_read_size) - op->data.nbytes = min(op->data.nbytes, + if (op->data.dir == SPI_MEM_DATA_IN) { + if (slave->max_read_size) + op->data.nbytes = min(op->data.nbytes, slave->max_read_size); - else if (slave->max_write_size) + } else if (slave->max_write_size) { op->data.nbytes = min(op->data.nbytes, slave->max_write_size - len); + } if (!op->data.nbytes) return -EINVAL; |