aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
authorRobin Gong <b38343@freescale.com>2015-04-15 22:54:18 -0400
committerMark Brown <broonie@kernel.org>2015-04-16 13:58:05 -0400
commitf8bb820da4ae863c676156627973a950129559fb (patch)
treee1b6856ee95c4930dfb9c51ffee382d6c05d916c /drivers/spi
parent56afdb70ca9140cdcbdcf01870f3e4e2e8be17f5 (diff)
spi: check tx_buf and rx_buf in spi_unmap_msg
Some spi device drivers use the same tx_buf and rx_buf repeatly for better performance such as driver/input/touchsreen/ads7846.c, but spi core grab tx_buf /rx_buf of transfer and set them as dummy_tx/dummy_rx once they are NULL. Thus, in the second time the tx_buf/rx_buf will be replaced by dummy_tx/dummy_rx and the data which produced by the last tx or rx may be wrongly sent to the device or handled by the upper level protocol. This patch just keep the orignal value of tx_buf/rx_buf if they are NULL after this transfer processed. Signed-off-by: Robin Gong <b38343@freescale.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/spi.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index d5d7d2235163..50910d85df5a 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -583,6 +583,15 @@ static int spi_unmap_msg(struct spi_master *master, struct spi_message *msg)
583 rx_dev = master->dma_rx->device->dev; 583 rx_dev = master->dma_rx->device->dev;
584 584
585 list_for_each_entry(xfer, &msg->transfers, transfer_list) { 585 list_for_each_entry(xfer, &msg->transfers, transfer_list) {
586 /*
587 * Restore the original value of tx_buf or rx_buf if they are
588 * NULL.
589 */
590 if (xfer->tx_buf == master->dummy_tx)
591 xfer->tx_buf = NULL;
592 if (xfer->rx_buf == master->dummy_rx)
593 xfer->rx_buf = NULL;
594
586 if (!master->can_dma(master, msg->spi, xfer)) 595 if (!master->can_dma(master, msg->spi, xfer))
587 continue; 596 continue;
588 597