提交 cb42425a 编写于 作者: B Bin Meng 提交者: Jagan Teki

spi: spi-mem-nodm: Fix read data size issue

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.

This commit mirrors the same changes in the dm version done in
commit 535b1fdb ("spi: spi-mem: Fix read data size issue").
Signed-off-by: NBin Meng <bmeng.cn@gmail.com>
Reviewed-by: NJagan Teki <jagan@amarulasolutions.com>
上级 9102cce7
......@@ -93,12 +93,14 @@ int spi_mem_adjust_op_size(struct spi_slave *slave,
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,
slave->max_read_size);
else if (slave->max_write_size)
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) {
op->data.nbytes = min(op->data.nbytes,
slave->max_write_size - len);
}
if (!op->data.nbytes)
return -EINVAL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册