diff options
author | Leilk Liu <leilk.liu@mediatek.com> | 2015-07-23 17:10:40 +0800 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2015-07-24 18:35:00 +0100 |
commit | c37f45b5f1cdfcdc351d88950b32658c970582ca (patch) | |
tree | 221c0166afca2716ef6dd52eb1a2c98396aa23a9 /drivers/spi/spi.c | |
parent | bc0195aad0daa2ad5b0d76cce22b167bc3435590 (diff) | |
download | lwn-c37f45b5f1cdfcdc351d88950b32658c970582ca.tar.gz lwn-c37f45b5f1cdfcdc351d88950b32658c970582ca.zip |
spi: support spi without dma channel to use can_dma()
For spi without dma channel and use can_dma(), it can
use master->dev for struct device.
Signed-off-by: Leilk Liu <leilk.liu@mediatek.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi/spi.c')
-rw-r--r-- | drivers/spi/spi.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index cf8b91b23a76..f725085a5f07 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -539,8 +539,15 @@ static int __spi_map_msg(struct spi_master *master, struct spi_message *msg) if (!master->can_dma) return 0; - tx_dev = master->dma_tx->device->dev; - rx_dev = master->dma_rx->device->dev; + if (master->dma_tx) + tx_dev = master->dma_tx->device->dev; + else + tx_dev = &master->dev; + + if (master->dma_rx) + rx_dev = master->dma_rx->device->dev; + else + rx_dev = &master->dev; list_for_each_entry(xfer, &msg->transfers, transfer_list) { if (!master->can_dma(master, msg->spi, xfer)) @@ -579,8 +586,15 @@ static int __spi_unmap_msg(struct spi_master *master, struct spi_message *msg) if (!master->cur_msg_mapped || !master->can_dma) return 0; - tx_dev = master->dma_tx->device->dev; - rx_dev = master->dma_rx->device->dev; + if (master->dma_tx) + tx_dev = master->dma_tx->device->dev; + else + tx_dev = &master->dev; + + if (master->dma_rx) + rx_dev = master->dma_rx->device->dev; + else + rx_dev = &master->dev; list_for_each_entry(xfer, &msg->transfers, transfer_list) { if (!master->can_dma(master, msg->spi, xfer)) |