aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorSimon Glass2019-12-06 21:42:44 -0700
committerBin Meng2019-12-15 11:44:23 +0800
commit43c145b8b3eeb77a31d3dd4810929b14c29003de (patch)
tree667a0ca076691f6b13d7a65013a02e40f4c3a5d8 /drivers
parentc59f2ac175ec895dd7ddb7921c859c641565fef9 (diff)
spi: ich: Correct max-size bug in ich_spi_adjust_size()
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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/spi/ich.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/spi/ich.c b/drivers/spi/ich.c
index 08c37ca4ab4..17b7a0ba0b9 100644
--- a/drivers/spi/ich.c
+++ b/drivers/spi/ich.c
@@ -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);