From 7c8ebb55fde8786cd16d95659ff73675bedc287c Mon Sep 17 00:00:00 2001
From: Helmut Stengele <lautriv@coldplug.net>
Date: Mon, 10 Nov 2014 11:26:51 +0100
Subject: [PATCH] mmc: vt8500: change resource-mapping to devm_*
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>
---
drivers/mmc/host/wmt-sdmmc.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
@@ -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);
if (!priv->sdmmc_base) {
dev_err(&pdev->dev, "Failed to map IO space\n");
- 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);
@@ -904,14 +903,9 @@ static int wmt_mci_remove(struct platform_device *pdev)
free_irq(priv->irq_regular, priv);
free_irq(priv->irq_dma, priv);
- iounmap(priv->sdmmc_base);
-
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");
--
1.7.10.4