linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: leilk.liu@mediatek.com (Leilk Liu)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 1/4] spi: support spi without dma channel to use can_dma()
Date: Thu, 23 Jul 2015 17:10:40 +0800	[thread overview]
Message-ID: <1437642643-11966-2-git-send-email-leilk.liu@mediatek.com> (raw)
In-Reply-To: <1437642643-11966-1-git-send-email-leilk.liu@mediatek.com>

For spi without dma channel and use can_dma(), it can
use master->dev for struct device.

Change-Id: I5b320e1742767c2ea4368410fb49c6679e28af6b
Signed-off-by: Leilk Liu <leilk.liu@mediatek.com>
---
 drivers/spi/spi.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index cf8b91b..f725085 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))
-- 
1.8.1.1.dirty

  reply	other threads:[~2015-07-23  9:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-23  9:10 [PATCH v3 0/4] Add Mediatek SPI bus driver Leilk Liu
2015-07-23  9:10 ` Leilk Liu [this message]
2015-07-23  9:10 ` [PATCH v3 2/4] dt-bindings: ARM: Mediatek: Document devicetree bindings for spi bus Leilk Liu
2015-07-24 17:34   ` Mark Brown
2015-07-27  2:38     ` leilk liu
2015-07-23  9:10 ` [PATCH v3 3/4] spi: mediatek: Add spi bus for Mediatek MT8173 Leilk Liu
2015-07-24 17:49   ` Mark Brown
2015-07-27  2:48     ` leilk liu
2015-07-23  9:10 ` [PATCH v3 4/4] arm64: dts: Add spi bus dts Leilk Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1437642643-11966-2-git-send-email-leilk.liu@mediatek.com \
    --to=leilk.liu@mediatek.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).