Commit 5f8f8035 authored by Andrey Smirnov's avatar Andrey Smirnov Committed by Mark Brown

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

Upper layer users of SPI device drivers may rely on 'actual_length',
so it is important that information is correctly reported. One such
example is spi_mem_exec_op() function that will fail if
'actual_length' of the data transferred is not what was requested. Add
necessary code to populate 'actual_length.

Cc: Mark Brown <broonie@kernel.org>
Cc: Sanchayan Maity <maitysanchayan@gmail.com>
Cc: Stefan Agner <stefan@agner.ch>
Cc: cphealy@gmail.com
Cc: linux-spi@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: default avatarAndrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 504f2565
...@@ -358,6 +358,7 @@ static int dspi_dma_xfer(struct fsl_dspi *dspi) ...@@ -358,6 +358,7 @@ static int dspi_dma_xfer(struct fsl_dspi *dspi)
{ {
struct fsl_dspi_dma *dma = dspi->dma; struct fsl_dspi_dma *dma = dspi->dma;
struct device *dev = &dspi->pdev->dev; struct device *dev = &dspi->pdev->dev;
struct spi_message *message = dspi->cur_msg;
int curr_remaining_bytes; int curr_remaining_bytes;
int bytes_per_buffer; int bytes_per_buffer;
int ret = 0; int ret = 0;
...@@ -377,8 +378,10 @@ static int dspi_dma_xfer(struct fsl_dspi *dspi) ...@@ -377,8 +378,10 @@ static int dspi_dma_xfer(struct fsl_dspi *dspi)
goto exit; goto exit;
} else { } else {
curr_remaining_bytes -= dma->curr_xfer_len const int len =
* dspi->bytes_per_word; dma->curr_xfer_len * dspi->bytes_per_word;
curr_remaining_bytes -= len;
message->actual_length += len;
if (curr_remaining_bytes < 0) if (curr_remaining_bytes < 0)
curr_remaining_bytes = 0; curr_remaining_bytes = 0;
} }
......
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