drivers: spi: fix the update of spi_context tx & rx length

The unit of spi_context's tx_len and rx_len is byte instead of frame.
Thus, in spi_context_update_tx(), the value of ctx->tx_len should be
reduced by (len * dfs).
Also to fix the update of ctx->tx_len in spi_context_update_rx().

Signed-off-by: cyliang tw <cyliang@nuvoton.com>
This commit is contained in:
cyliang tw 2025-05-29 18:04:50 +08:00 committed by Dan Kalowsky
commit 4a486ce51b

View file

@ -496,7 +496,7 @@ void spi_context_update_tx(struct spi_context *ctx, uint8_t dfs, uint32_t len)
return; return;
} }
ctx->tx_len -= len; ctx->tx_len -= len * dfs;
if (!ctx->tx_len) { if (!ctx->tx_len) {
/* Current buffer is done. Get the next one to be processed. */ /* Current buffer is done. Get the next one to be processed. */
++ctx->current_tx; ++ctx->current_tx;
@ -555,7 +555,7 @@ void spi_context_update_rx(struct spi_context *ctx, uint8_t dfs, uint32_t len)
return; return;
} }
ctx->rx_len -= len; ctx->rx_len -= len * dfs;
if (!ctx->rx_len) { if (!ctx->rx_len) {
/* Current buffer is done. Get the next one to be processed. */ /* Current buffer is done. Get the next one to be processed. */
++ctx->current_rx; ++ctx->current_rx;