* [PATCH v2] mmc: pxamci: fix the device-tree probe deferral path
@ 2016-02-06 21:14 Robert Jarzmik
2016-02-08 9:19 ` Ulf Hansson
0 siblings, 1 reply; 3+ messages in thread
From: Robert Jarzmik @ 2016-02-06 21:14 UTC (permalink / raw)
To: Ulf Hansson; +Cc: linux-mmc, linux-kernel, Robert Jarzmik
When the gpio driver is probed after the mmc one, the read/write gpio
and card detection one return -EPROBE_DEFER. Unfortunately, the memory
region remains requested, and upon the next probe, the probe will fail
anyway with -EBUSY.
Fix this by releasing the memory resource upon probe failure.
More broadly, this patch uses devm_*() primitives whenever possible in
the probe function.
Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
---
Since v1: broaden the devm_*() enveloppe
---
drivers/mmc/host/pxamci.c | 24 +++++++-----------------
1 file changed, 7 insertions(+), 17 deletions(-)
diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c
index 28a057fae0a1..a672b9259d34 100644
--- a/drivers/mmc/host/pxamci.c
+++ b/drivers/mmc/host/pxamci.c
@@ -654,12 +654,8 @@ static int pxamci_probe(struct platform_device *pdev)
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
irq = platform_get_irq(pdev, 0);
- if (!r || irq < 0)
- return -ENXIO;
-
- r = request_mem_region(r->start, SZ_4K, DRIVER_NAME);
- if (!r)
- return -EBUSY;
+ if (irq < 0)
+ return irq;
mmc = mmc_alloc_host(sizeof(struct pxamci_host), &pdev->dev);
if (!mmc) {
@@ -727,9 +723,9 @@ static int pxamci_probe(struct platform_device *pdev)
host->irq = irq;
host->imask = MMC_I_MASK_ALL;
- host->base = ioremap(r->start, SZ_4K);
- if (!host->base) {
- ret = -ENOMEM;
+ host->base = devm_ioremap_resource(&pdev->dev, r);
+ if (IS_ERR(host->base)) {
+ ret = PTR_ERR(host->base);
goto out;
}
@@ -742,7 +738,8 @@ static int pxamci_probe(struct platform_device *pdev)
writel(64, host->base + MMC_RESTO);
writel(host->imask, host->base + MMC_I_MASK);
- ret = request_irq(host->irq, pxamci_irq, 0, DRIVER_NAME, host);
+ ret = devm_request_irq(&pdev->dev, host->irq, pxamci_irq, 0,
+ DRIVER_NAME, host);
if (ret)
goto out;
@@ -833,14 +830,11 @@ out:
dma_release_channel(host->dma_chan_rx);
if (host->dma_chan_tx)
dma_release_channel(host->dma_chan_tx);
- if (host->base)
- iounmap(host->base);
if (host->clk)
clk_put(host->clk);
}
if (mmc)
mmc_free_host(mmc);
- release_resource(r);
return ret;
}
@@ -870,17 +864,13 @@ static int pxamci_remove(struct platform_device *pdev)
END_CMD_RES|PRG_DONE|DATA_TRAN_DONE,
host->base + MMC_I_MASK);
- free_irq(host->irq, host);
dmaengine_terminate_all(host->dma_chan_rx);
dmaengine_terminate_all(host->dma_chan_tx);
dma_release_channel(host->dma_chan_rx);
dma_release_channel(host->dma_chan_tx);
- iounmap(host->base);
clk_put(host->clk);
- release_resource(host->res);
-
mmc_free_host(mmc);
}
return 0;
--
2.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] mmc: pxamci: fix the device-tree probe deferral path
2016-02-06 21:14 [PATCH v2] mmc: pxamci: fix the device-tree probe deferral path Robert Jarzmik
@ 2016-02-08 9:19 ` Ulf Hansson
2016-02-08 14:16 ` Robert Jarzmik
0 siblings, 1 reply; 3+ messages in thread
From: Ulf Hansson @ 2016-02-08 9:19 UTC (permalink / raw)
To: Robert Jarzmik; +Cc: linux-mmc, linux-kernel@vger.kernel.org
On 6 February 2016 at 22:14, Robert Jarzmik <robert.jarzmik@free.fr> wrote:
> When the gpio driver is probed after the mmc one, the read/write gpio
> and card detection one return -EPROBE_DEFER. Unfortunately, the memory
> region remains requested, and upon the next probe, the probe will fail
> anyway with -EBUSY.
>
> Fix this by releasing the memory resource upon probe failure.
>
> More broadly, this patch uses devm_*() primitives whenever possible in
> the probe function.
There's actually also clocks and regulators that may be converted to
use the devm* functions.
Do you want to do that as a part of this patch as well? Otherwise I
can apply as is.
Kind regards
Uffe
>
> Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
> ---
> Since v1: broaden the devm_*() enveloppe
> ---
> drivers/mmc/host/pxamci.c | 24 +++++++-----------------
> 1 file changed, 7 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c
> index 28a057fae0a1..a672b9259d34 100644
> --- a/drivers/mmc/host/pxamci.c
> +++ b/drivers/mmc/host/pxamci.c
> @@ -654,12 +654,8 @@ static int pxamci_probe(struct platform_device *pdev)
>
> r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> irq = platform_get_irq(pdev, 0);
> - if (!r || irq < 0)
> - return -ENXIO;
> -
> - r = request_mem_region(r->start, SZ_4K, DRIVER_NAME);
> - if (!r)
> - return -EBUSY;
> + if (irq < 0)
> + return irq;
>
> mmc = mmc_alloc_host(sizeof(struct pxamci_host), &pdev->dev);
> if (!mmc) {
> @@ -727,9 +723,9 @@ static int pxamci_probe(struct platform_device *pdev)
> host->irq = irq;
> host->imask = MMC_I_MASK_ALL;
>
> - host->base = ioremap(r->start, SZ_4K);
> - if (!host->base) {
> - ret = -ENOMEM;
> + host->base = devm_ioremap_resource(&pdev->dev, r);
> + if (IS_ERR(host->base)) {
> + ret = PTR_ERR(host->base);
> goto out;
> }
>
> @@ -742,7 +738,8 @@ static int pxamci_probe(struct platform_device *pdev)
> writel(64, host->base + MMC_RESTO);
> writel(host->imask, host->base + MMC_I_MASK);
>
> - ret = request_irq(host->irq, pxamci_irq, 0, DRIVER_NAME, host);
> + ret = devm_request_irq(&pdev->dev, host->irq, pxamci_irq, 0,
> + DRIVER_NAME, host);
> if (ret)
> goto out;
>
> @@ -833,14 +830,11 @@ out:
> dma_release_channel(host->dma_chan_rx);
> if (host->dma_chan_tx)
> dma_release_channel(host->dma_chan_tx);
> - if (host->base)
> - iounmap(host->base);
> if (host->clk)
> clk_put(host->clk);
> }
> if (mmc)
> mmc_free_host(mmc);
> - release_resource(r);
> return ret;
> }
>
> @@ -870,17 +864,13 @@ static int pxamci_remove(struct platform_device *pdev)
> END_CMD_RES|PRG_DONE|DATA_TRAN_DONE,
> host->base + MMC_I_MASK);
>
> - free_irq(host->irq, host);
> dmaengine_terminate_all(host->dma_chan_rx);
> dmaengine_terminate_all(host->dma_chan_tx);
> dma_release_channel(host->dma_chan_rx);
> dma_release_channel(host->dma_chan_tx);
> - iounmap(host->base);
>
> clk_put(host->clk);
>
> - release_resource(host->res);
> -
> mmc_free_host(mmc);
> }
> return 0;
> --
> 2.1.4
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] mmc: pxamci: fix the device-tree probe deferral path
2016-02-08 9:19 ` Ulf Hansson
@ 2016-02-08 14:16 ` Robert Jarzmik
0 siblings, 0 replies; 3+ messages in thread
From: Robert Jarzmik @ 2016-02-08 14:16 UTC (permalink / raw)
To: Ulf Hansson; +Cc: linux-mmc, linux-kernel@vger.kernel.org
Ulf Hansson <ulf.hansson@linaro.org> writes:
> On 6 February 2016 at 22:14, Robert Jarzmik <robert.jarzmik@free.fr> wrote:
>> When the gpio driver is probed after the mmc one, the read/write gpio
>> and card detection one return -EPROBE_DEFER. Unfortunately, the memory
>> region remains requested, and upon the next probe, the probe will fail
>> anyway with -EBUSY.
>>
>> Fix this by releasing the memory resource upon probe failure.
>>
>> More broadly, this patch uses devm_*() primitives whenever possible in
>> the probe function.
>
> There's actually also clocks and regulators that may be converted to
> use the devm* functions.
> Do you want to do that as a part of this patch as well? Otherwise I
> can apply as is.
Yes, I will add the regulator and clock in this patch, you're right, this makes
sense to me, v3 on its way.
Cheers.
--
Robert
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-02-08 14:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-06 21:14 [PATCH v2] mmc: pxamci: fix the device-tree probe deferral path Robert Jarzmik
2016-02-08 9:19 ` Ulf Hansson
2016-02-08 14:16 ` Robert Jarzmik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox