]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
spi: spi-mem: Fix read data size issue
authorYe Li <ye.li@nxp.com>
Wed, 10 Jul 2019 09:23:51 +0000 (09:23 +0000)
committerJagan Teki <jagan@amarulasolutions.com>
Thu, 18 Jul 2019 11:41:16 +0000 (17:11 +0530)
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>
drivers/spi/spi-mem.c

index 7aabebeff5fa35a6aef80bb1a412403138fd778e..7788ab995344332a1280b196c52de652dd55de5a 100644 (file)
@@ -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;