From: lautriv <lautriv@coldplug.net>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Alexey Charkov <alchark@gmail.com>,
Fabio Estevam <festevam@gmail.com>,
Tony Prisk <linux@prisktech.co.nz>, Chris Ball <chris@printf.net>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mmc: wmt-sdmmc: fix unmatched release_mem_region
Date: Tue, 25 Nov 2014 23:34:18 +0100 [thread overview]
Message-ID: <547503EA.3030907@coldplug.net> (raw)
In-Reply-To: <CAPDyKFqNHQUStQiRJ3Bn7JnbMn-xJ=TUaWXijJcuO9z97xcmDw@mail.gmail.com>
On 11/24/2014 09:34 AM, Ulf Hansson wrote:
> On 20 November 2014 at 15:45, lautriv <lautriv@coldplug.net> wrote:
>> From b0509e27e33326e6dccd67d8ebe67e2bdb0cfdde Mon Sep 17 00:00:00 2001
>> From: Helmut Stengele <lautriv@coldplug.net>
>> Date: Thu, 20 Nov 2014 15:27:40 +0100
>> Subject: [PATCH] mmc: wmt-sdmmc: fix unmatched release_mem_region
>>
>> Current code calls release_mem_region upon module unload
>> without requesting the region first. This patch fixes it
>> by moving to a devres-based ioremap implementation, which
>> handles requesting and releasing memory region internally.
>>
>> This also makes the error/unload paths a bit simpler.
>>
>> Signed-off-by: Helmut Stengele <lautriv@coldplug.net>
>> ---
>>
>> This is a corrected patch based on the one Alexey sent for me.
>> I sent it already but since i'm not used to send something upstream
>> it was an attached file and obviously rejected.
>> Patch is tested on bare-metal ( wm8850 ) and works like suspected.
>>
>> drivers/mmc/host/wmt-sdmmc.c | 14 +++++---------
>> 1 file changed, 5 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/mmc/host/wmt-sdmmc.c b/drivers/mmc/host/wmt-sdmmc.c
>> index 54181b4..bcaa0cc 100644
>> --- a/drivers/mmc/host/wmt-sdmmc.c
>> +++ b/drivers/mmc/host/wmt-sdmmc.c
>> @@ -759,6 +759,7 @@ static int wmt_mci_probe(struct platform_device *pdev)
>> const struct wmt_mci_caps *wmt_caps;
>> int ret;
>> int regular_irq, dma_irq;
>> + struct resource *res;
>>
>> if (!of_id || !of_id->data) {
>> dev_err(&pdev->dev, "Controller capabilities data missing\n");
>> @@ -813,10 +814,11 @@ static int wmt_mci_probe(struct platform_device *pdev)
>> if (of_get_property(np, "cd-inverted", NULL))
>> priv->cd_inverted = 1;
>>
>> - priv->sdmmc_base = of_iomap(np, 0);
>> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> + priv->sdmmc_base = devm_ioremap_resource(&pdev->dev, res);
> You should check the return value from devm_ioremap_resource() with IS_ERR().
>
>> if (!priv->sdmmc_base) {
>> dev_err(&pdev->dev, "Failed to map IO space\n");
> This print can be removed, devm_ioremap_resource() handles that.
>
>> - ret = -ENOMEM;
>> + ret = PTR_ERR(priv->sdmmc_base);
>> goto fail2;
>> }
>>
>> @@ -826,7 +828,7 @@ static int wmt_mci_probe(struct platform_device *pdev)
>> ret = request_irq(regular_irq, wmt_mci_regular_isr, 0, "sdmmc", priv);
>> if (ret) {
>> dev_err(&pdev->dev, "Register regular IRQ fail\n");
>> - goto fail3;
>> + goto fail2;
>> }
>>
>> ret = request_irq(dma_irq, wmt_mci_dma_isr, 0, "sdmmc", priv);
>> @@ -869,8 +871,6 @@ fail5:
>> free_irq(dma_irq, priv);
>> fail4:
>> free_irq(regular_irq, priv);
>> -fail3:
>> - iounmap(priv->sdmmc_base);
>> fail2:
>> mmc_free_host(mmc);
>> fail1:
>> @@ -881,7 +881,6 @@ static int wmt_mci_remove(struct platform_device *pdev)
>> {
>> struct mmc_host *mmc;
>> struct wmt_mci_priv *priv;
>> - struct resource *res;
>> u32 reg_tmp;
>>
>> mmc = platform_get_drvdata(pdev);
>> @@ -909,9 +908,6 @@ static int wmt_mci_remove(struct platform_device *pdev)
>> clk_disable_unprepare(priv->clk_sdmmc);
>> clk_put(priv->clk_sdmmc);
>>
>> - res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> - release_mem_region(res->start, resource_size(res));
>> -
>> mmc_free_host(mmc);
>>
>> dev_info(&pdev->dev, "WMT MCI device removed\n");
>> --
>> 2.1.3
>>
>>
> Kind regards
> Uffe
>
Thanks for the hint, will do so. ( Sent the wrong patch by accident anyway )
WARNING: multiple messages have this Message-ID (diff)
From: lautriv@coldplug.net (lautriv)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] mmc: wmt-sdmmc: fix unmatched release_mem_region
Date: Tue, 25 Nov 2014 23:34:18 +0100 [thread overview]
Message-ID: <547503EA.3030907@coldplug.net> (raw)
In-Reply-To: <CAPDyKFqNHQUStQiRJ3Bn7JnbMn-xJ=TUaWXijJcuO9z97xcmDw@mail.gmail.com>
On 11/24/2014 09:34 AM, Ulf Hansson wrote:
> On 20 November 2014 at 15:45, lautriv <lautriv@coldplug.net> wrote:
>> From b0509e27e33326e6dccd67d8ebe67e2bdb0cfdde Mon Sep 17 00:00:00 2001
>> From: Helmut Stengele <lautriv@coldplug.net>
>> Date: Thu, 20 Nov 2014 15:27:40 +0100
>> Subject: [PATCH] mmc: wmt-sdmmc: fix unmatched release_mem_region
>>
>> Current code calls release_mem_region upon module unload
>> without requesting the region first. This patch fixes it
>> by moving to a devres-based ioremap implementation, which
>> handles requesting and releasing memory region internally.
>>
>> This also makes the error/unload paths a bit simpler.
>>
>> Signed-off-by: Helmut Stengele <lautriv@coldplug.net>
>> ---
>>
>> This is a corrected patch based on the one Alexey sent for me.
>> I sent it already but since i'm not used to send something upstream
>> it was an attached file and obviously rejected.
>> Patch is tested on bare-metal ( wm8850 ) and works like suspected.
>>
>> drivers/mmc/host/wmt-sdmmc.c | 14 +++++---------
>> 1 file changed, 5 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/mmc/host/wmt-sdmmc.c b/drivers/mmc/host/wmt-sdmmc.c
>> index 54181b4..bcaa0cc 100644
>> --- a/drivers/mmc/host/wmt-sdmmc.c
>> +++ b/drivers/mmc/host/wmt-sdmmc.c
>> @@ -759,6 +759,7 @@ static int wmt_mci_probe(struct platform_device *pdev)
>> const struct wmt_mci_caps *wmt_caps;
>> int ret;
>> int regular_irq, dma_irq;
>> + struct resource *res;
>>
>> if (!of_id || !of_id->data) {
>> dev_err(&pdev->dev, "Controller capabilities data missing\n");
>> @@ -813,10 +814,11 @@ static int wmt_mci_probe(struct platform_device *pdev)
>> if (of_get_property(np, "cd-inverted", NULL))
>> priv->cd_inverted = 1;
>>
>> - priv->sdmmc_base = of_iomap(np, 0);
>> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> + priv->sdmmc_base = devm_ioremap_resource(&pdev->dev, res);
> You should check the return value from devm_ioremap_resource() with IS_ERR().
>
>> if (!priv->sdmmc_base) {
>> dev_err(&pdev->dev, "Failed to map IO space\n");
> This print can be removed, devm_ioremap_resource() handles that.
>
>> - ret = -ENOMEM;
>> + ret = PTR_ERR(priv->sdmmc_base);
>> goto fail2;
>> }
>>
>> @@ -826,7 +828,7 @@ static int wmt_mci_probe(struct platform_device *pdev)
>> ret = request_irq(regular_irq, wmt_mci_regular_isr, 0, "sdmmc", priv);
>> if (ret) {
>> dev_err(&pdev->dev, "Register regular IRQ fail\n");
>> - goto fail3;
>> + goto fail2;
>> }
>>
>> ret = request_irq(dma_irq, wmt_mci_dma_isr, 0, "sdmmc", priv);
>> @@ -869,8 +871,6 @@ fail5:
>> free_irq(dma_irq, priv);
>> fail4:
>> free_irq(regular_irq, priv);
>> -fail3:
>> - iounmap(priv->sdmmc_base);
>> fail2:
>> mmc_free_host(mmc);
>> fail1:
>> @@ -881,7 +881,6 @@ static int wmt_mci_remove(struct platform_device *pdev)
>> {
>> struct mmc_host *mmc;
>> struct wmt_mci_priv *priv;
>> - struct resource *res;
>> u32 reg_tmp;
>>
>> mmc = platform_get_drvdata(pdev);
>> @@ -909,9 +908,6 @@ static int wmt_mci_remove(struct platform_device *pdev)
>> clk_disable_unprepare(priv->clk_sdmmc);
>> clk_put(priv->clk_sdmmc);
>>
>> - res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> - release_mem_region(res->start, resource_size(res));
>> -
>> mmc_free_host(mmc);
>>
>> dev_info(&pdev->dev, "WMT MCI device removed\n");
>> --
>> 2.1.3
>>
>>
> Kind regards
> Uffe
>
Thanks for the hint, will do so. ( Sent the wrong patch by accident anyway )
next prev parent reply other threads:[~2014-11-25 22:34 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-09 21:12 [PATCH] mmc: wmt-sdmmc: fix unmatched release_mem_region Alexey Charkov
2014-11-09 21:12 ` Alexey Charkov
2014-11-09 21:55 ` Fabio Estevam
2014-11-09 21:55 ` Fabio Estevam
2014-11-09 22:18 ` lautriv
2014-11-09 22:18 ` lautriv
2014-11-10 5:15 ` Alexey Charkov
2014-11-10 5:15 ` Alexey Charkov
2014-11-10 20:17 ` lautriv
2014-11-10 20:17 ` lautriv
2014-11-20 14:45 ` lautriv
2014-11-20 14:45 ` lautriv
2014-11-24 8:34 ` Ulf Hansson
2014-11-24 8:34 ` Ulf Hansson
2014-11-25 22:34 ` lautriv [this message]
2014-11-25 22:34 ` lautriv
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=547503EA.3030907@coldplug.net \
--to=lautriv@coldplug.net \
--cc=alchark@gmail.com \
--cc=chris@printf.net \
--cc=festevam@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=linux@prisktech.co.nz \
--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.