* [PATCH] mmc: pxamci: fix the device-tree probe deferral path
@ 2016-02-03 22:19 Robert Jarzmik
2016-02-04 11:11 ` Ulf Hansson
0 siblings, 1 reply; 4+ messages in thread
From: Robert Jarzmik @ 2016-02-03 22:19 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.
Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
---
drivers/mmc/host/pxamci.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c
index 28a057fae0a1..405ec339a1b8 100644
--- a/drivers/mmc/host/pxamci.c
+++ b/drivers/mmc/host/pxamci.c
@@ -657,7 +657,7 @@ static int pxamci_probe(struct platform_device *pdev)
if (!r || irq < 0)
return -ENXIO;
- r = request_mem_region(r->start, SZ_4K, DRIVER_NAME);
+ r = devm_request_mem_region(&pdev->dev, r->start, SZ_4K, DRIVER_NAME);
if (!r)
return -EBUSY;
@@ -840,7 +840,6 @@ out:
}
if (mmc)
mmc_free_host(mmc);
- release_resource(r);
return ret;
}
--
2.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] mmc: pxamci: fix the device-tree probe deferral path
2016-02-03 22:19 [PATCH] mmc: pxamci: fix the device-tree probe deferral path Robert Jarzmik
@ 2016-02-04 11:11 ` Ulf Hansson
2016-02-04 20:28 ` Robert Jarzmik
0 siblings, 1 reply; 4+ messages in thread
From: Ulf Hansson @ 2016-02-04 11:11 UTC (permalink / raw)
To: Robert Jarzmik; +Cc: linux-mmc, linux-kernel
On 3 February 2016 at 23:19, 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.
>
> Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
> ---
> drivers/mmc/host/pxamci.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c
> index 28a057fae0a1..405ec339a1b8 100644
> --- a/drivers/mmc/host/pxamci.c
> +++ b/drivers/mmc/host/pxamci.c
> @@ -657,7 +657,7 @@ static int pxamci_probe(struct platform_device *pdev)
> if (!r || irq < 0)
> return -ENXIO;
>
> - r = request_mem_region(r->start, SZ_4K, DRIVER_NAME);
> + r = devm_request_mem_region(&pdev->dev, r->start, SZ_4K, DRIVER_NAME);
I suggest you replace also the ioremap call, thus using
devm_ioremap_resource() is convenient.
> if (!r)
> return -EBUSY;
>
> @@ -840,7 +840,6 @@ out:
> }
> if (mmc)
> mmc_free_host(mmc);
> - release_resource(r);
This looks wrong.
> return ret;
> }
>
> --
> 2.1.4
>
Perhaps it's just easier to convert the probe function to use all
devm_* functions, as for example irqs isn't freed either.
In that way, you will solve all problems of also leaking memory in one go.
Kind regards
Uffe
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mmc: pxamci: fix the device-tree probe deferral path
2016-02-04 11:11 ` Ulf Hansson
@ 2016-02-04 20:28 ` Robert Jarzmik
0 siblings, 0 replies; 4+ messages in thread
From: Robert Jarzmik @ 2016-02-04 20:28 UTC (permalink / raw)
To: Ulf Hansson; +Cc: linux-mmc, linux-kernel
Ulf Hansson <ulf.hansson@linaro.org> writes:
> On 3 February 2016 at 23:19, 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.
>>
>> Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
>> ---
>> drivers/mmc/host/pxamci.c | 3 +--
>> 1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c
>> index 28a057fae0a1..405ec339a1b8 100644
>> --- a/drivers/mmc/host/pxamci.c
>> +++ b/drivers/mmc/host/pxamci.c
>> @@ -657,7 +657,7 @@ static int pxamci_probe(struct platform_device *pdev)
>> if (!r || irq < 0)
>> return -ENXIO;
>>
>> - r = request_mem_region(r->start, SZ_4K, DRIVER_NAME);
>> + r = devm_request_mem_region(&pdev->dev, r->start, SZ_4K, DRIVER_NAME);
>
> I suggest you replace also the ioremap call, thus using
> devm_ioremap_resource() is convenient.
Yes, of course, for v2.
>> @@ -840,7 +840,6 @@ out:
>> }
>> if (mmc)
>> mmc_free_host(mmc);
>> - release_resource(r);
>
> This looks wrong.
Hum. Why so ?
> Perhaps it's just easier to convert the probe function to use all
> devm_* functions, as for example irqs isn't freed either.
You're very right.
Actually the first patch I had was with devm_irq_request(), and then I reverted
that chunk, thinking I was overdoing it, and that this didn't belong to this
commit.
Silly me, hein ?
> In that way, you will solve all problems of also leaking memory in one go.
Sure.
Cheers.
--
Robert
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mmc: pxamci: fix the device-tree probe deferral path
@ 2016-02-04 20:28 ` Robert Jarzmik
0 siblings, 0 replies; 4+ messages in thread
From: Robert Jarzmik @ 2016-02-04 20:28 UTC (permalink / raw)
To: Ulf Hansson; +Cc: linux-mmc, linux-kernel
Ulf Hansson <ulf.hansson@linaro.org> writes:
> On 3 February 2016 at 23:19, 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.
>>
>> Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
>> ---
>> drivers/mmc/host/pxamci.c | 3 +--
>> 1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c
>> index 28a057fae0a1..405ec339a1b8 100644
>> --- a/drivers/mmc/host/pxamci.c
>> +++ b/drivers/mmc/host/pxamci.c
>> @@ -657,7 +657,7 @@ static int pxamci_probe(struct platform_device *pdev)
>> if (!r || irq < 0)
>> return -ENXIO;
>>
>> - r = request_mem_region(r->start, SZ_4K, DRIVER_NAME);
>> + r = devm_request_mem_region(&pdev->dev, r->start, SZ_4K, DRIVER_NAME);
>
> I suggest you replace also the ioremap call, thus using
> devm_ioremap_resource() is convenient.
Yes, of course, for v2.
>> @@ -840,7 +840,6 @@ out:
>> }
>> if (mmc)
>> mmc_free_host(mmc);
>> - release_resource(r);
>
> This looks wrong.
Hum. Why so ?
> Perhaps it's just easier to convert the probe function to use all
> devm_* functions, as for example irqs isn't freed either.
You're very right.
Actually the first patch I had was with devm_irq_request(), and then I reverted
that chunk, thinking I was overdoing it, and that this didn't belong to this
commit.
Silly me, hein ?
> In that way, you will solve all problems of also leaking memory in one go.
Sure.
Cheers.
--
Robert
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-02-04 20:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-03 22:19 [PATCH] mmc: pxamci: fix the device-tree probe deferral path Robert Jarzmik
2016-02-04 11:11 ` Ulf Hansson
2016-02-04 20:28 ` Robert Jarzmik
2016-02-04 20:28 ` Robert Jarzmik
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.