spi: fsl-espi: fix behaviour for full-duplex xfers
authorJonatas Rech <jonatas.rech@datacom.ind.br>
Wed, 15 Apr 2015 15:23:18 +0000 (12:23 -0300)
committerMark Brown <broonie@kernel.org>
Sat, 25 Apr 2015 13:00:09 +0000 (14:00 +0100)
commit2000058e892cd6773b3061a56c0bd6535ac15afe
tree037b3d1922e56e05c5082cc710725b9cce223a11
parentc517d838eb7d07bbe9507871fab3931deccff539
spi: fsl-espi: fix behaviour for full-duplex xfers

This patch makes possible for protocol drivers to do full-duplex SPI
transfers properly. Until now this driver could only be used for
half-duplex transfers, since it always expected an spi_transfer with
non-null tx_buf to be only used for TX, and those with non-null rx_buf
to be only used for RX.

The fix consists in correcting the fsl_espi_transfer length by taking
into consideration duplex spi_transfers, and not just by adding n_tx
and n_rx.

Furthermore, this correction has exposed an inconsistency in the
protocol driver <-> controller driver interaction. The spi-fsl-espi
driver artificially inserts TX bytes when message fragmentation is
necessary (due to SPCOM_TRANLEN_MAX) instead of informing the
protocol driver of the hardware limitation. This was tested with the
m25p80 NOR flash protocol driver. Since fixing this issue may cause
other client drivers to malfunction, it was left as is.

Signed-off-by: Jonatas Rech <jonatas.rech@datacom.ind.br>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-fsl-espi.c