Skip to content

Commit 4a486ce

Browse files
cyliangtwdkalowsk
authored andcommitted
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 <[email protected]>
1 parent 2bda9ad commit 4a486ce

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/spi/spi_context.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ void spi_context_update_tx(struct spi_context *ctx, uint8_t dfs, uint32_t len)
496496
return;
497497
}
498498

499-
ctx->tx_len -= len;
499+
ctx->tx_len -= len * dfs;
500500
if (!ctx->tx_len) {
501501
/* Current buffer is done. Get the next one to be processed. */
502502
++ctx->current_tx;
@@ -555,7 +555,7 @@ void spi_context_update_rx(struct spi_context *ctx, uint8_t dfs, uint32_t len)
555555
return;
556556
}
557557

558-
ctx->rx_len -= len;
558+
ctx->rx_len -= len * dfs;
559559
if (!ctx->rx_len) {
560560
/* Current buffer is done. Get the next one to be processed. */
561561
++ctx->current_rx;

0 commit comments

Comments
 (0)