All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
To: Ulf Hansson <ulf.hansson@linaro.org>,
	Paul Cercueil <paul@crapouillou.net>
Cc: linux-mmc@vger.kernel.org, linux-mips@linux-mips.org,
	James Hogan <jhogan@kernel.org>,
	Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Subject: [PATCH 03/14] mmc: jz4740: Fix error exit path in driver's probe
Date: Fri,  9 Mar 2018 12:12:08 -0300	[thread overview]
Message-ID: <20180309151219.18723-4-ezequiel@vanguardiasur.com.ar> (raw)
In-Reply-To: <20180309151219.18723-1-ezequiel@vanguardiasur.com.ar>

From: Paul Cercueil <paul@crapouillou.net>

Currently, if jz4740_mmc_request_gpios() fails, the driver
tries to release DMA resources. This is wrong because DMA
is requested at a later stage.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
[Ezequiel: cleanup commit message]
Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
---
 drivers/mmc/host/jz4740_mmc.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/mmc/host/jz4740_mmc.c b/drivers/mmc/host/jz4740_mmc.c
index 5a85a3017711..636741ac9031 100644
--- a/drivers/mmc/host/jz4740_mmc.c
+++ b/drivers/mmc/host/jz4740_mmc.c
@@ -1006,7 +1006,7 @@ static int jz4740_mmc_probe(struct platform_device* pdev)
 
 	ret = jz4740_mmc_request_gpios(mmc, pdev);
 	if (ret)
-		goto err_release_dma;
+		goto err_free_host;
 
 	mmc->ops = &jz4740_mmc_ops;
 	mmc->f_min = JZ_MMC_CLK_RATE / 128;
@@ -1038,16 +1038,17 @@ static int jz4740_mmc_probe(struct platform_device* pdev)
 	jz4740_mmc_clock_disable(host);
 	timer_setup(&host->timeout_timer, jz4740_mmc_timeout, 0);
 
-	host->use_dma = true;
-	if (host->use_dma && jz4740_mmc_acquire_dma_channels(host) != 0)
-		host->use_dma = false;
+	ret = jz4740_mmc_acquire_dma_channels(host);
+	if (ret == -EPROBE_DEFER)
+		goto err_free_irq;
+	host->use_dma = !ret;
 
 	platform_set_drvdata(pdev, host);
 	ret = mmc_add_host(mmc);
 
 	if (ret) {
 		dev_err(&pdev->dev, "Failed to add mmc host: %d\n", ret);
-		goto err_free_irq;
+		goto err_release_dma;
 	}
 	dev_info(&pdev->dev, "JZ SD/MMC card driver registered\n");
 
@@ -1057,13 +1058,13 @@ static int jz4740_mmc_probe(struct platform_device* pdev)
 
 	return 0;
 
+err_release_dma:
+	if (host->use_dma)
+		jz4740_mmc_release_dma_channels(host);
 err_free_irq:
 	free_irq(host->irq, host);
 err_free_gpios:
 	jz4740_mmc_free_gpios(pdev);
-err_release_dma:
-	if (host->use_dma)
-		jz4740_mmc_release_dma_channels(host);
 err_free_host:
 	mmc_free_host(mmc);
 
-- 
2.16.2

  parent reply	other threads:[~2018-03-09 15:14 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-09 15:12 [PATCH 00/14] Enable SD/MMC on JZ4780 SoCs Ezequiel Garcia
2018-03-09 15:12 ` [PATCH 01/14] mmc: jz4780: Order headers alphabetically Ezequiel Garcia
2018-03-09 15:12 ` [PATCH 02/14] mmc: jz4740: Use dev_get_platdata Ezequiel Garcia
2018-03-09 15:12 ` Ezequiel Garcia [this message]
2018-03-09 15:12 ` [PATCH 04/14] mmc: jz4740: Reset the device requesting the interrupt Ezequiel Garcia
2018-03-09 15:12 ` [PATCH 05/14] mmc: jz4740: Introduce devicetree probe Ezequiel Garcia
2018-03-09 15:12 ` [PATCH 06/14] mmc: dt-bindings: add MMC support to JZ4740 SoC Ezequiel Garcia
2018-03-09 15:12 ` [PATCH 07/14] mmc: jz4740: Set clock rate to mmc->f_max rather than JZ_MMC_CLK_RATE Ezequiel Garcia
2018-03-09 15:12 ` [PATCH 08/14] mmc: jz4740: Add support for the JZ4780 Ezequiel Garcia
2018-03-09 17:51   ` [PATCH 08/14] mmc: jz4740: Add support for the JZ4780, Paul Cercueil
2018-03-09 22:31     ` your mail James Hogan
2018-03-09 22:31       ` James Hogan
2018-03-10 22:44     ` [PATCH 08/14] mmc: jz4740: Add support for the JZ4780 Ezequiel Garcia
2018-03-10 17:04   ` Mathieu Malaterre
2018-03-10 17:11   ` Mathieu Malaterre
2018-03-09 15:12 ` [PATCH 09/14] mmc: jz4740: Fix race condition in IRQ mask update Ezequiel Garcia
2018-03-09 22:49   ` James Hogan
2018-03-10 22:46     ` Ezequiel Garcia
2018-03-09 15:12 ` [PATCH 10/14] mmc: jz4740: Use dma_request_chan() Ezequiel Garcia
2018-03-09 15:12 ` [PATCH 11/14] MIPS: dts: jz4780: Add DMA controller node to the devicetree Ezequiel Garcia
2018-03-09 23:13   ` James Hogan
2018-03-11  1:31     ` Ezequiel Garcia
2018-03-09 15:12 ` [PATCH 12/14] MIPS: dts: jz4780: Add MMC " Ezequiel Garcia
2018-03-09 23:24   ` James Hogan
2018-03-09 15:12 ` [PATCH 13/14] MIPS: dts: ci20: Enable DMA and MMC in " Ezequiel Garcia
2018-03-09 23:39   ` James Hogan
2018-03-09 15:12 ` [PATCH 14/14] MIPS: configs: ci20: Enable DMA and MMC support Ezequiel Garcia
2018-03-09 23:30   ` James Hogan
2018-03-10 17:02 ` [PATCH 00/14] Enable SD/MMC on JZ4780 SoCs Mathieu Malaterre
2018-03-10 22:17   ` Ezequiel Garcia
2018-03-12 16:26     ` James Hogan
2018-03-12 17:15     ` Mathieu Malaterre

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=20180309151219.18723-4-ezequiel@vanguardiasur.com.ar \
    --to=ezequiel@vanguardiasur.com.ar \
    --cc=jhogan@kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=paul@crapouillou.net \
    --cc=ulf.hansson@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.