mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Ujfalusi <peter.ujfalusi@ti.com>
To: <broonie@kernel.org>, <nsaenzjulienne@suse.de>,
	<f.fainelli@gmail.com>, <rjui@broadcom.com>,
	<sbranden@broadcom.com>, <shawnguo@kernel.org>,
	<s.hauer@pengutronix.de>, <baohua@kernel.org>,
	<mcoquelin.stm32@gmail.com>, <alexandre.torgue@st.com>
Cc: <vkoul@kernel.org>, <linux-spi@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-rpi-kernel@lists.infradead.org>,
	<linux-stm32@st-md-mailman.stormreply.com>
Subject: [PATCH 8/9] spi: stm32-qspi: Use dma_request_chan() instead dma_request_slave_channel()
Date: Thu, 12 Dec 2019 15:55:49 +0200	[thread overview]
Message-ID: <20191212135550.4634-9-peter.ujfalusi@ti.com> (raw)
In-Reply-To: <20191212135550.4634-1-peter.ujfalusi@ti.com>

dma_request_slave_channel() is a wrapper on top of dma_request_chan()
eating up the error code.

By using dma_request_chan() directly the driver can support deferred
probing against DMA.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 drivers/spi/spi-stm32-qspi.c | 30 ++++++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/drivers/spi/spi-stm32-qspi.c b/drivers/spi/spi-stm32-qspi.c
index 4e726929bb4f..4ef569b47aa6 100644
--- a/drivers/spi/spi-stm32-qspi.c
+++ b/drivers/spi/spi-stm32-qspi.c
@@ -470,10 +470,11 @@ static int stm32_qspi_setup(struct spi_device *spi)
 	return 0;
 }
 
-static void stm32_qspi_dma_setup(struct stm32_qspi *qspi)
+static int stm32_qspi_dma_setup(struct stm32_qspi *qspi)
 {
 	struct dma_slave_config dma_cfg;
 	struct device *dev = qspi->dev;
+	int ret = 0;
 
 	memset(&dma_cfg, 0, sizeof(dma_cfg));
 
@@ -484,8 +485,13 @@ static void stm32_qspi_dma_setup(struct stm32_qspi *qspi)
 	dma_cfg.src_maxburst = 4;
 	dma_cfg.dst_maxburst = 4;
 
-	qspi->dma_chrx = dma_request_slave_channel(dev, "rx");
-	if (qspi->dma_chrx) {
+	qspi->dma_chrx = dma_request_chan(dev, "rx");
+	if (IS_ERR(qspi->dma_chrx)) {
+		ret = PTR_ERR(qspi->dma_chrx);
+		qspi->dma_chrx = NULL;
+		if (ret == -EPROBE_DEFER)
+			goto out;
+	} else {
 		if (dmaengine_slave_config(qspi->dma_chrx, &dma_cfg)) {
 			dev_err(dev, "dma rx config failed\n");
 			dma_release_channel(qspi->dma_chrx);
@@ -493,8 +499,11 @@ static void stm32_qspi_dma_setup(struct stm32_qspi *qspi)
 		}
 	}
 
-	qspi->dma_chtx = dma_request_slave_channel(dev, "tx");
-	if (qspi->dma_chtx) {
+	qspi->dma_chtx = dma_request_chan(dev, "tx");
+	if (IS_ERR(qspi->dma_chtx)) {
+		ret = PTR_ERR(qspi->dma_chtx);
+		qspi->dma_chtx = NULL;
+	} else {
 		if (dmaengine_slave_config(qspi->dma_chtx, &dma_cfg)) {
 			dev_err(dev, "dma tx config failed\n");
 			dma_release_channel(qspi->dma_chtx);
@@ -502,7 +511,13 @@ static void stm32_qspi_dma_setup(struct stm32_qspi *qspi)
 		}
 	}
 
+out:
 	init_completion(&qspi->dma_completion);
+
+	if (ret != -EPROBE_DEFER)
+		ret = 0;
+
+	return ret;
 }
 
 static void stm32_qspi_dma_free(struct stm32_qspi *qspi)
@@ -608,7 +623,10 @@ static int stm32_qspi_probe(struct platform_device *pdev)
 
 	qspi->dev = dev;
 	platform_set_drvdata(pdev, qspi);
-	stm32_qspi_dma_setup(qspi);
+	ret = stm32_qspi_dma_setup(qspi);
+	if (ret)
+		goto err;
+
 	mutex_init(&qspi->lock);
 
 	ctrl->mode_bits = SPI_RX_DUAL | SPI_RX_QUAD
-- 
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


  parent reply	other threads:[~2019-12-12 13:56 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-12 13:55 [PATCH 0/9] spi: " Peter Ujfalusi
2019-12-12 13:55 ` [PATCH 1/9] spi: atmel: " Peter Ujfalusi
2019-12-16 12:06   ` Applied "spi: atmel: Use dma_request_chan() instead dma_request_slave_channel()" to the spi tree Mark Brown
2019-12-12 13:55 ` [PATCH 2/9] spi: bcm2835: Release the DMA channel if probe fails after dma_init Peter Ujfalusi
2019-12-16 11:34   ` Nicolas Saenz Julienne
2019-12-16 12:06   ` Applied "spi: bcm2835: Release the DMA channel if probe fails after dma_init" to the spi tree Mark Brown
2019-12-12 13:55 ` [PATCH 3/9] spi: bcm2835: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
2019-12-16 12:06   ` Applied "spi: bcm2835: Use dma_request_chan() instead dma_request_slave_channel()" to the spi tree Mark Brown
2019-12-12 13:55 ` [PATCH 4/9] spi: img-spfi: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
2019-12-16 12:06   ` Applied "spi: img-spfi: Use dma_request_chan() instead dma_request_slave_channel()" to the spi tree Mark Brown
2019-12-12 13:55 ` [PATCH 5/9] spi: mxs: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
2019-12-16 12:06   ` Applied "spi: mxs: Use dma_request_chan() instead dma_request_slave_channel()" to the spi tree Mark Brown
2019-12-12 13:55 ` [PATCH 6/9] spi: sirf: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
2019-12-16 12:06   ` Applied "spi: sirf: Use dma_request_chan() instead dma_request_slave_channel()" to the spi tree Mark Brown
2019-12-12 13:55 ` [PATCH 7/9] spi: spi-fsl-dspi: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
2019-12-16 12:06   ` Applied "spi: spi-fsl-dspi: Use dma_request_chan() instead dma_request_slave_channel()" to the spi tree Mark Brown
2019-12-12 13:55 ` Peter Ujfalusi [this message]
2019-12-16 12:06   ` Applied "spi: stm32-qspi: " Mark Brown
2019-12-12 13:55 ` [PATCH 9/9] spi: stm32: Use dma_request_chan() instead dma_request_slave_channel() Peter Ujfalusi
2019-12-16 12:05   ` Applied "spi: stm32: Use dma_request_chan() instead dma_request_slave_channel()" to the spi tree Mark Brown

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=20191212135550.4634-9-peter.ujfalusi@ti.com \
    --to=peter.ujfalusi@ti.com \
    --cc=alexandre.torgue@st.com \
    --cc=baohua@kernel.org \
    --cc=broonie@kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=nsaenzjulienne@suse.de \
    --cc=rjui@broadcom.com \
    --cc=s.hauer@pengutronix.de \
    --cc=sbranden@broadcom.com \
    --cc=shawnguo@kernel.org \
    --cc=vkoul@kernel.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

all inboxes | Powered by JetHome®