spi: ich: Correct max-size bug in ich_spi_adjust_size()
authorSimon Glass <sjg@chromium.org>
Sat, 7 Dec 2019 04:42:44 +0000 (21:42 -0700)
committerBin Meng <bmeng.cn@gmail.com>
Sun, 15 Dec 2019 03:44:23 +0000 (11:44 +0800)
This incorrectly shortens read operations if there is a maximum write size
but no maximum read size. Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
drivers/spi/ich.c

index 08c37ca4ab4eff980fc785835667552a2ca60091..17b7a0ba0b929f91b10cc83613b8bdea0651ac4c 100644 (file)
@@ -425,9 +425,11 @@ static int ich_spi_adjust_size(struct spi_slave *slave, struct spi_mem_op *op)
                page_offset = do_div(aux, ICH_BOUNDARY);
        }
 
-       if (op->data.dir == SPI_MEM_DATA_IN && slave->max_read_size) {
-               op->data.nbytes = min(ICH_BOUNDARY - page_offset,
-                                     slave->max_read_size);
+       if (op->data.dir == SPI_MEM_DATA_IN) {
+               if (slave->max_read_size) {
+                       op->data.nbytes = min(ICH_BOUNDARY - page_offset,
+                                             slave->max_read_size);
+               }
        } else if (slave->max_write_size) {
                op->data.nbytes = min(ICH_BOUNDARY - page_offset,
                                      slave->max_write_size);