spi: spi-fsl-dspi: Change the way of increasing spi_message->actual_length
authorHaikun Wang <haikun.wang@freescale.com>
Tue, 9 Jun 2015 11:45:37 +0000 (19:45 +0800)
committerMark Brown <broonie@kernel.org>
Tue, 9 Jun 2015 17:35:54 +0000 (18:35 +0100)
commitc042af95a26207704ffa71098223c7fcb9e95a9d
tree79ef4b7aeda6b16b77c4c1c3bc6f908fc2cc68af
parentd1f4a38c8139cf87316b16f28b206fd1fd2b31db
spi: spi-fsl-dspi: Change the way of increasing spi_message->actual_length

In current driver, we increase actual_length in the following way:
message->actual_length += dspi_xxx_transfer()
It has two defects.
First, transmitting maybe in process when the function call finished and
we don't know the transmitting result in this moment.
Secondly, the last sentence in function before returning is accessing the
SPI register and trigger the data transmitting. If we enable interrupt,
interrupt may be generated before function return and we also have the same
sentence "message->actual_length += dspi_xxx_transfer()"
in the IRQ handler.
And usually dspi_xxx_transfer will trigger a new IRQ.
The original dspi_xxx_transfer call may return when no new IRQ generate.
This may mess the variable spi_message->actual_length.
Now we increase the variable in the IRQ handler and only when we get the
TCF or EOQ interrupt
And we get the transmitted data length from the SPI transfer counter
instead of the function return value.

Signed-off-by: Haikun Wang <haikun.wang@freescale.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-fsl-dspi.c