diff options
author | Bin Meng <bmeng.cn@gmail.com> | 2021-07-28 20:50:14 +0800 |
---|---|---|
committer | Jagan Teki <jagan@amarulasolutions.com> | 2021-08-03 11:50:37 +0530 |
commit | cb42425aa1086f2a732dd2e0614acc0c993c869d (patch) | |
tree | 94352a2b9308b717eb9901b10183a9bac6cfda23 | |
parent | 9102cce7f439b1939e37d28bfa587d316d1c7a73 (diff) | |
download | u-boot-cb42425aa1086f2a732dd2e0614acc0c993c869d.zip u-boot-cb42425aa1086f2a732dd2e0614acc0c993c869d.tar.gz u-boot-cb42425aa1086f2a732dd2e0614acc0c993c869d.tar.bz2 |
spi: spi-mem-nodm: 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.
This commit mirrors the same changes in the dm version done in
commit 535b1fdb8e5e ("spi: spi-mem: Fix read data size issue").
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
-rw-r--r-- | drivers/spi/spi-mem-nodm.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/spi/spi-mem-nodm.c b/drivers/spi/spi-mem-nodm.c index a228c80..77ddb19 100644 --- a/drivers/spi/spi-mem-nodm.c +++ b/drivers/spi/spi-mem-nodm.c @@ -93,12 +93,14 @@ int spi_mem_adjust_op_size(struct spi_slave *slave, 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, - slave->max_read_size); - else if (slave->max_write_size) + 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) { op->data.nbytes = min(op->data.nbytes, slave->max_write_size - len); + } if (!op->data.nbytes) return -EINVAL; |