Skip to contentSkip to conversation

spi: spi-fsl-dspi: Fill actual_length when doing DMA transfer

PATCH Superseded Andrey Smirnov 2 participants 3 messages Jul 16, 2018 – Jul 17, 2018

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spi: spi-fsl-dspi: Fill actual_length when doing DMA transfer

Users of SPI device drivers may rely on 'actual_length', so it is important that information is correctly reported. One example would be spi_mem_exec_op() which will fail if 'actual_length' doesn't match requested transfer length. To fix the problem, add necessary code to populate 'actual_length'.

---
 drivers/spi/spi-fsl-dspi.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/spi/spi-fsl-dspi.c +5 -1
index 0630962ce442..8877dd1e18dc 100644
@@ -327,6 +327,7 @@ static int dspi_dma_xfer(struct fsl_dspi *dspi)
 {
 	struct fsl_dspi_dma *dma = dspi->dma;
 	struct device *dev = &dspi->pdev->dev;
+	struct spi_message *message = dspi->cur_msg;
 	int curr_remaining_bytes;
 	int bytes_per_buffer;
 	int word = 1;
@@ -348,7 +349,10 @@ static int dspi_dma_xfer(struct fsl_dspi *dspi)
 			goto exit;
 
 		} else {
-			curr_remaining_bytes -= dma->curr_xfer_len * word;
+			const int len = dma->curr_xfer_len * word;
+
+			curr_remaining_bytes -= len;
+			message->actual_length += len;
 			if (curr_remaining_bytes < 0)
 				curr_remaining_bytes = 0;
 		}
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 5 lines · Andrey Smirnov

Users of SPI device drivers may rely on 'actual_length', so it is important that information is correctly reported. One example would be spi_mem_exec_op() which will fail if 'actual_length' doesn't match requested transfer length. To fix the problem, add necessary code to populate 'actual_length'.

This doesn't apply against current code, please check and resend.

#2 lore raw
Quoted 9 lines · Mark Brown
Quoted 5 lines · Andrey Smirnov

Users of SPI device drivers may rely on 'actual_length', so it is important that information is correctly reported. One example would be spi_mem_exec_op() which will fail if 'actual_length' doesn't match requested transfer length. To fix the problem, add necessary code to populate 'actual_length'.

This doesn't apply against current code, please check and resend.

Sorry about that. Will do in v2.

Thanks,
Andrey Smirnov