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>
This commit is contained in:
Simon Glass 2019-12-06 21:42:44 -07:00 committed by Bin Meng
parent c59f2ac175
commit 43c145b8b3

View 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);