MLK-21879-2 spi-mem: Fix read data size issue
authorYe Li <ye.li@nxp.com>
Tue, 28 May 2019 07:47:17 +0000 (00:47 -0700)
committerYe Li <ye.li@nxp.com>
Tue, 28 May 2019 13:56:02 +0000 (06:56 -0700)
When slave drivers not 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>
drivers/spi/spi-mem.c

index 1bb0987..195bc8d 100644 (file)
@@ -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;