spi: spi-mem: Fix read data size issue
PATCH 1/1 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.
--- drivers/spi/spi-mem.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/spi/spi-mem.c +5 -3
@@ -423,12 +423,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 ;
Signature · 1 line
2.7.4
PATCH 1/1 spi: spi-mem: Fix read data size issue
Quoted 4 lines · Ye Li
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 themax_write_size.
Indeed. Thanks for catching this!
Quoted 28 lines
Signed-off-by Ye Li <[email protected]>--- drivers/spi/spi-mem.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/spi/spi-mem.c +5
-3@@ -423,12 +423,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 ;
Signature · 2 lines
Regards Vignesh
PATCH 1/1 spi: spi-mem: Fix read data size issue
In reply to Ye LiQuoted 19 lines · Ye Li
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 themax_write_size.Signed-off-by Ye Li <[email protected]>--- drivers/spi/spi-mem.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/spi/spi-mem.c +0
-1@@ -423,12 +423,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)
drivers/spi/spi-mem.c int spi_mem_adjust_op_size(struct spi_slave *slave, struct spi_mem_op *op) · line 433
Quoted 10 lines
drivers/spi/spi-mem.c +5
-2- 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); + }
PATCH 1/1 spi: spi-mem: Fix read data size issue
In reply to Ye LiQuoted 9 lines · Ye Li
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 themax_write_size.Signed-off-by Ye Li <[email protected]>--- drivers/spi/spi-mem.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
Applied to u-boot-spi/master