Commit 0e58637e authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Mark Brown

spi: airoha: fix airoha_snand_{write,read}_data data_len estimation

Fix data length written and read in airoha_snand_write_data and
airoha_snand_read_data routines respectively if it is bigger than
SPI_MAX_TRANSFER_SIZE.

Fixes: a403997c ("spi: airoha: add SPI-NAND Flash controller driver")
Tested-by: default avatarChristian Marangi <ansuelsmth@gmail.com>
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Link: https://patch.msgid.link/20240913-airoha-spi-fixes-v1-2-de2e74ed4664@kernel.orgSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 2e6bbfe7
......@@ -405,7 +405,7 @@ static int airoha_snand_write_data(struct airoha_snand_ctrl *as_ctrl, u8 cmd,
for (i = 0; i < len; i += data_len) {
int err;
data_len = min(len, SPI_MAX_TRANSFER_SIZE);
data_len = min(len - i, SPI_MAX_TRANSFER_SIZE);
err = airoha_snand_set_fifo_op(as_ctrl, cmd, data_len);
if (err)
return err;
......@@ -427,7 +427,7 @@ static int airoha_snand_read_data(struct airoha_snand_ctrl *as_ctrl, u8 *data,
for (i = 0; i < len; i += data_len) {
int err;
data_len = min(len, SPI_MAX_TRANSFER_SIZE);
data_len = min(len - i, SPI_MAX_TRANSFER_SIZE);
err = airoha_snand_set_fifo_op(as_ctrl, 0xc, data_len);
if (err)
return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment