From: jonas.jensen@gmail.com (Jonas Jensen)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4] mmc: moxart: fix probe logic
Date: Tue, 3 Feb 2015 16:55:54 +0100 [thread overview]
Message-ID: <1422978954-14547-1-git-send-email-jonas.jensen@gmail.com> (raw)
In-Reply-To: <6294882.EhDcdWGRYz@wuerfel>
From: Arnd Bergmann <arnd@arndb.de>
Jonas Jensen wanted to submit a patch for these, but apparently
forgot about it. I stumbled over this symptom first:
drivers/built-in.o: In function `moxart_probe':
:(.text+0x2af128): undefined reference to `of_dma_request_slave_channel'
This is because of_dma_request_slave_channel is an internal helper
and not exported to loadable module. I'm changing the driver to
use dma_request_slave_channel_reason() instead.
Further problems from inspection:
* The remove function must not call kfree on the host pointer,
because it is allocated together with the mmc_host.
* The clock is never released
* The dma_cap_mask_t is completely unused and can be removed
* deferred probing does not work if the dma driver is loaded
after the mmc driver.
This patch should fix all of the above.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Jonas Jensen <jonas.jensen@gmail.com>
---
Notes:
This is a forward of Arnd's v2 patch.
v2: do not call clk_put() on an error pointer
v3: fix NULL dereference on host->clk
v4: rework to use devm_clk_get()
Applies to next-20150113
drivers/mmc/host/moxart-mmc.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/drivers/mmc/host/moxart-mmc.c b/drivers/mmc/host/moxart-mmc.c
index d2a1ef6..6cb4053 100644
--- a/drivers/mmc/host/moxart-mmc.c
+++ b/drivers/mmc/host/moxart-mmc.c
@@ -17,6 +17,7 @@
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/delay.h>
+#include <linux/errno.h>
#include <linux/interrupt.h>
#include <linux/blkdev.h>
#include <linux/dma-mapping.h>
@@ -562,7 +563,6 @@ static int moxart_probe(struct platform_device *pdev)
struct dma_slave_config cfg;
struct clk *clk;
void __iomem *reg_mmc;
- dma_cap_mask_t mask;
int irq, ret;
u32 i;
@@ -586,9 +586,9 @@ static int moxart_probe(struct platform_device *pdev)
goto out;
}
- clk = of_clk_get(node, 0);
+ clk = devm_clk_get(dev, 0);
if (IS_ERR(clk)) {
- dev_err(dev, "of_clk_get failed\n");
+ dev_err(dev, "devm_clk_get failed\n");
ret = PTR_ERR(clk);
goto out;
}
@@ -603,9 +603,6 @@ static int moxart_probe(struct platform_device *pdev)
if (ret)
goto out;
- dma_cap_zero(mask);
- dma_cap_set(DMA_SLAVE, mask);
-
host = mmc_priv(mmc);
host->mmc = mmc;
host->base = reg_mmc;
@@ -613,8 +610,8 @@ static int moxart_probe(struct platform_device *pdev)
host->timeout = msecs_to_jiffies(1000);
host->sysclk = clk_get_rate(clk);
host->fifo_width = readl(host->base + REG_FEATURE) << 2;
- host->dma_chan_tx = of_dma_request_slave_channel(node, "tx");
- host->dma_chan_rx = of_dma_request_slave_channel(node, "rx");
+ host->dma_chan_tx = dma_request_slave_channel_reason(dev, "tx");
+ host->dma_chan_rx = dma_request_slave_channel_reason(dev, "rx");
spin_lock_init(&host->lock);
@@ -624,6 +621,11 @@ static int moxart_probe(struct platform_device *pdev)
mmc->ocr_avail = 0xffff00; /* Support 2.0v - 3.6v power. */
if (IS_ERR(host->dma_chan_tx) || IS_ERR(host->dma_chan_rx)) {
+ if (PTR_ERR(host->dma_chan_tx) == -EPROBE_DEFER ||
+ PTR_ERR(host->dma_chan_rx) == -EPROBE_DEFER) {
+ ret = -EPROBE_DEFER;
+ goto out;
+ }
dev_dbg(dev, "PIO mode transfer enabled\n");
host->have_dma = false;
} else {
@@ -702,9 +704,6 @@ static int moxart_remove(struct platform_device *pdev)
writel(readl(host->base + REG_CLOCK_CONTROL) | CLK_OFF,
host->base + REG_CLOCK_CONTROL);
}
-
- kfree(host);
-
return 0;
}
--
1.8.2.1
next prev parent reply other threads:[~2015-02-03 15:55 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-29 16:15 [PATCH] mmc: moxart: fix probe logic Arnd Bergmann
2015-01-29 17:01 ` Russell King - ARM Linux
2015-01-29 22:04 ` Arnd Bergmann
2015-01-29 22:06 ` [PATCH v2] " Arnd Bergmann
2015-02-02 10:52 ` Jonas Jensen
2015-02-02 14:58 ` Arnd Bergmann
2015-02-02 15:43 ` [PATCH v3] " Jonas Jensen
2015-02-02 20:03 ` Arnd Bergmann
2015-02-03 15:55 ` Jonas Jensen [this message]
2015-02-04 8:40 ` [PATCH v4] " Ulf Hansson
2015-02-03 8:02 ` [PATCH v3] " Ulf Hansson
2015-02-03 9:06 ` Arnd Bergmann
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=1422978954-14547-1-git-send-email-jonas.jensen@gmail.com \
--to=jonas.jensen@gmail.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).