]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mmc: dw_mmc: Use devm_* functions in dw_mmc platform driver
authorThomas Abraham <thomas.abraham@linaro.org>
Mon, 17 Sep 2012 18:16:36 +0000 (18:16 +0000)
committerChris Ball <cjb@laptop.org>
Wed, 19 Sep 2012 08:29:48 +0000 (16:29 +0800)
Use devm_* managed functions for simpler error handling.

Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org>
Acked-by: Will Newton <will.newton@imgtec.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
drivers/mmc/host/dw_mmc-pltfm.c

index 528d37b93651dae79a0e50e8f3c76e2c28c85be9..ce7be1ac66211e088e3cf37d5d708a7fad7c749a 100644 (file)
@@ -27,38 +27,27 @@ static int __devinit dw_mci_pltfm_probe(struct platform_device *pdev)
        struct resource *regs;
        int ret;
 
-       host = kzalloc(sizeof(struct dw_mci), GFP_KERNEL);
+       host = devm_kzalloc(&pdev->dev, sizeof(struct dw_mci), GFP_KERNEL);
        if (!host)
                return -ENOMEM;
 
        regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       if (!regs) {
-               ret = -ENXIO;
-               goto err_free;
-       }
+       if (!regs)
+               return -ENXIO;
 
        host->irq = platform_get_irq(pdev, 0);
-       if (host->irq < 0) {
-               ret = host->irq;
-               goto err_free;
-       }
+       if (host->irq < 0)
+               return host->irq;
 
        host->dev = &pdev->dev;
        host->irq_flags = 0;
        host->pdata = pdev->dev.platform_data;
-       ret = -ENOMEM;
-       host->regs = ioremap(regs->start, resource_size(regs));
+       host->regs = devm_request_and_ioremap(&pdev->dev, regs);
        if (!host->regs)
-               goto err_free;
+               return -ENOMEM;
+
        platform_set_drvdata(pdev, host);
        ret = dw_mci_probe(host);
-       if (ret)
-               goto err_out;
-       return ret;
-err_out:
-       iounmap(host->regs);
-err_free:
-       kfree(host);
        return ret;
 }
 
@@ -68,8 +57,6 @@ static int __devexit dw_mci_pltfm_remove(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, NULL);
        dw_mci_remove(host);
-       iounmap(host->regs);
-       kfree(host);
        return 0;
 }