spi: bugfix: spi_message.transfer_length does not get reset
authorMartin Sperl <kernel@martin.sperl.org>
Fri, 27 Nov 2015 12:31:09 +0000 (12:31 +0000)
committerMark Brown <broonie@kernel.org>
Fri, 27 Nov 2015 12:55:22 +0000 (12:55 +0000)
When submitting an identical spi_message multiple times via spi_sync
the spi_message.frame_length does not get reset to 0 in __spi_validate
before adding up all spi_transfer.len resulting in
frame_length > actual_length on all but the first spi_sync call.

Signed-off-by: Martin Sperl <kernel@martin.sperl.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi.c

index e2415be209d5a77e9224add30db37d65244fabda..a0e346f3b71e42f214b9080fb47ae558554e7f44 100644 (file)
@@ -2130,6 +2130,7 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message)
         * Set transfer tx_nbits and rx_nbits as single transfer default
         * (SPI_NBITS_SINGLE) if it is not set for this transfer.
         */
+       message->frame_length = 0;
        list_for_each_entry(xfer, &message->transfers, transfer_list) {
                message->frame_length += xfer->len;
                if (!xfer->bits_per_word)