diff options
author | Thomas Abraham <thomas.abraham@linaro.org> | 2012-09-17 14:16:36 -0400 |
---|---|---|
committer | Chris Ball <cjb@laptop.org> | 2012-10-03 10:05:14 -0400 |
commit | bb8bdc77efdecc868d522691487d261ac32d3237 (patch) | |
tree | 9cc750b06ebd1c00a2c4c226a67ce856d2ae2f42 /drivers/mmc | |
parent | 4a90920c6b39a3af26470cfc26b8e5ec9c4e7f3c (diff) |
mmc: dw_mmc: Use devm_* functions in dw_mmc platform driver
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>
Diffstat (limited to 'drivers/mmc')
-rw-r--r-- | drivers/mmc/host/dw_mmc-pltfm.c | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/drivers/mmc/host/dw_mmc-pltfm.c b/drivers/mmc/host/dw_mmc-pltfm.c index 528d37b93651..ce7be1ac6621 100644 --- a/drivers/mmc/host/dw_mmc-pltfm.c +++ b/drivers/mmc/host/dw_mmc-pltfm.c | |||
@@ -27,38 +27,27 @@ static int __devinit dw_mci_pltfm_probe(struct platform_device *pdev) | |||
27 | struct resource *regs; | 27 | struct resource *regs; |
28 | int ret; | 28 | int ret; |
29 | 29 | ||
30 | host = kzalloc(sizeof(struct dw_mci), GFP_KERNEL); | 30 | host = devm_kzalloc(&pdev->dev, sizeof(struct dw_mci), GFP_KERNEL); |
31 | if (!host) | 31 | if (!host) |
32 | return -ENOMEM; | 32 | return -ENOMEM; |
33 | 33 | ||
34 | regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 34 | regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
35 | if (!regs) { | 35 | if (!regs) |
36 | ret = -ENXIO; | 36 | return -ENXIO; |
37 | goto err_free; | ||
38 | } | ||
39 | 37 | ||
40 | host->irq = platform_get_irq(pdev, 0); | 38 | host->irq = platform_get_irq(pdev, 0); |
41 | if (host->irq < 0) { | 39 | if (host->irq < 0) |
42 | ret = host->irq; | 40 | return host->irq; |
43 | goto err_free; | ||
44 | } | ||
45 | 41 | ||
46 | host->dev = &pdev->dev; | 42 | host->dev = &pdev->dev; |
47 | host->irq_flags = 0; | 43 | host->irq_flags = 0; |
48 | host->pdata = pdev->dev.platform_data; | 44 | host->pdata = pdev->dev.platform_data; |
49 | ret = -ENOMEM; | 45 | host->regs = devm_request_and_ioremap(&pdev->dev, regs); |
50 | host->regs = ioremap(regs->start, resource_size(regs)); | ||
51 | if (!host->regs) | 46 | if (!host->regs) |
52 | goto err_free; | 47 | return -ENOMEM; |
48 | |||
53 | platform_set_drvdata(pdev, host); | 49 | platform_set_drvdata(pdev, host); |
54 | ret = dw_mci_probe(host); | 50 | ret = dw_mci_probe(host); |
55 | if (ret) | ||
56 | goto err_out; | ||
57 | return ret; | ||
58 | err_out: | ||
59 | iounmap(host->regs); | ||
60 | err_free: | ||
61 | kfree(host); | ||
62 | return ret; | 51 | return ret; |
63 | } | 52 | } |
64 | 53 | ||
@@ -68,8 +57,6 @@ static int __devexit dw_mci_pltfm_remove(struct platform_device *pdev) | |||
68 | 57 | ||
69 | platform_set_drvdata(pdev, NULL); | 58 | platform_set_drvdata(pdev, NULL); |
70 | dw_mci_remove(host); | 59 | dw_mci_remove(host); |
71 | iounmap(host->regs); | ||
72 | kfree(host); | ||
73 | return 0; | 60 | return 0; |
74 | } | 61 | } |
75 | 62 | ||