aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeungwon Jeon <tgih.jun@samsung.com>2012-11-28 05:26:03 -0500
committerChris Ball <cjb@laptop.org>2012-12-06 13:55:10 -0500
commit780f22af85991be4f7c51c512726eee931707fff (patch)
tree14a8eaa37d105db14909b2de69b9ceb981acb18e
parent047a9ce790077193e43acccedba0e2294cf4c89d (diff)
mmc: dw_mmc: use devres functions in dw_mmc
Use managed device resource functions for easy handling. This makes driver simpler in the routine of error and exit. Signed-off-by: Seungwon Jeon <tgih.jun@samsung.com> Acked-by: James Hogan <james.hogan@imgtec.com> Signed-off-by: Chris Ball <cjb@laptop.org>
-rw-r--r--drivers/mmc/host/dw_mmc.c43
1 files changed, 14 insertions, 29 deletions
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index 73420296b268..6785d62ef047 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -1914,7 +1914,7 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id)
1914#endif /* CONFIG_MMC_DW_IDMAC */ 1914#endif /* CONFIG_MMC_DW_IDMAC */
1915 } 1915 }
1916 1916
1917 host->vmmc = regulator_get(mmc_dev(mmc), "vmmc"); 1917 host->vmmc = devm_regulator_get(mmc_dev(mmc), "vmmc");
1918 if (IS_ERR(host->vmmc)) { 1918 if (IS_ERR(host->vmmc)) {
1919 pr_info("%s: no vmmc regulator found\n", mmc_hostname(mmc)); 1919 pr_info("%s: no vmmc regulator found\n", mmc_hostname(mmc));
1920 host->vmmc = NULL; 1920 host->vmmc = NULL;
@@ -1963,7 +1963,7 @@ static void dw_mci_cleanup_slot(struct dw_mci_slot *slot, unsigned int id)
1963static void dw_mci_init_dma(struct dw_mci *host) 1963static void dw_mci_init_dma(struct dw_mci *host)
1964{ 1964{
1965 /* Alloc memory for sg translation */ 1965 /* Alloc memory for sg translation */
1966 host->sg_cpu = dma_alloc_coherent(host->dev, PAGE_SIZE, 1966 host->sg_cpu = dmam_alloc_coherent(host->dev, PAGE_SIZE,
1967 &host->sg_dma, GFP_KERNEL); 1967 &host->sg_dma, GFP_KERNEL);
1968 if (!host->sg_cpu) { 1968 if (!host->sg_cpu) {
1969 dev_err(host->dev, "%s: could not alloc DMA memory\n", 1969 dev_err(host->dev, "%s: could not alloc DMA memory\n",
@@ -2112,26 +2112,24 @@ int dw_mci_probe(struct dw_mci *host)
2112 return -ENODEV; 2112 return -ENODEV;
2113 } 2113 }
2114 2114
2115 host->biu_clk = clk_get(host->dev, "biu"); 2115 host->biu_clk = devm_clk_get(host->dev, "biu");
2116 if (IS_ERR(host->biu_clk)) { 2116 if (IS_ERR(host->biu_clk)) {
2117 dev_dbg(host->dev, "biu clock not available\n"); 2117 dev_dbg(host->dev, "biu clock not available\n");
2118 } else { 2118 } else {
2119 ret = clk_prepare_enable(host->biu_clk); 2119 ret = clk_prepare_enable(host->biu_clk);
2120 if (ret) { 2120 if (ret) {
2121 dev_err(host->dev, "failed to enable biu clock\n"); 2121 dev_err(host->dev, "failed to enable biu clock\n");
2122 clk_put(host->biu_clk);
2123 return ret; 2122 return ret;
2124 } 2123 }
2125 } 2124 }
2126 2125
2127 host->ciu_clk = clk_get(host->dev, "ciu"); 2126 host->ciu_clk = devm_clk_get(host->dev, "ciu");
2128 if (IS_ERR(host->ciu_clk)) { 2127 if (IS_ERR(host->ciu_clk)) {
2129 dev_dbg(host->dev, "ciu clock not available\n"); 2128 dev_dbg(host->dev, "ciu clock not available\n");
2130 } else { 2129 } else {
2131 ret = clk_prepare_enable(host->ciu_clk); 2130 ret = clk_prepare_enable(host->ciu_clk);
2132 if (ret) { 2131 if (ret) {
2133 dev_err(host->dev, "failed to enable ciu clock\n"); 2132 dev_err(host->dev, "failed to enable ciu clock\n");
2134 clk_put(host->ciu_clk);
2135 goto err_clk_biu; 2133 goto err_clk_biu;
2136 } 2134 }
2137 } 2135 }
@@ -2233,7 +2231,8 @@ int dw_mci_probe(struct dw_mci *host)
2233 if (!host->card_workqueue) 2231 if (!host->card_workqueue)
2234 goto err_dmaunmap; 2232 goto err_dmaunmap;
2235 INIT_WORK(&host->card_work, dw_mci_work_routine_card); 2233 INIT_WORK(&host->card_work, dw_mci_work_routine_card);
2236 ret = request_irq(host->irq, dw_mci_interrupt, host->irq_flags, "dw-mci", host); 2234 ret = devm_request_irq(host->dev, host->irq, dw_mci_interrupt,
2235 host->irq_flags, "dw-mci", host);
2237 if (ret) 2236 if (ret)
2238 goto err_workqueue; 2237 goto err_workqueue;
2239 2238
@@ -2271,7 +2270,7 @@ int dw_mci_probe(struct dw_mci *host)
2271 } else { 2270 } else {
2272 dev_dbg(host->dev, "attempted to initialize %d slots, " 2271 dev_dbg(host->dev, "attempted to initialize %d slots, "
2273 "but failed on all\n", host->num_slots); 2272 "but failed on all\n", host->num_slots);
2274 goto err_init_slot; 2273 goto err_workqueue;
2275 } 2274 }
2276 2275
2277 /* 2276 /*
@@ -2291,33 +2290,24 @@ int dw_mci_probe(struct dw_mci *host)
2291 2290
2292 return 0; 2291 return 0;
2293 2292
2294err_init_slot:
2295 free_irq(host->irq, host);
2296
2297err_workqueue: 2293err_workqueue:
2298 destroy_workqueue(host->card_workqueue); 2294 destroy_workqueue(host->card_workqueue);
2299 2295
2300err_dmaunmap: 2296err_dmaunmap:
2301 if (host->use_dma && host->dma_ops->exit) 2297 if (host->use_dma && host->dma_ops->exit)
2302 host->dma_ops->exit(host); 2298 host->dma_ops->exit(host);
2303 dma_free_coherent(host->dev, PAGE_SIZE,
2304 host->sg_cpu, host->sg_dma);
2305 2299
2306 if (host->vmmc) { 2300 if (host->vmmc)
2307 regulator_disable(host->vmmc); 2301 regulator_disable(host->vmmc);
2308 regulator_put(host->vmmc);
2309 }
2310 2302
2311err_clk_ciu: 2303err_clk_ciu:
2312 if (!IS_ERR(host->ciu_clk)) { 2304 if (!IS_ERR(host->ciu_clk))
2313 clk_disable_unprepare(host->ciu_clk); 2305 clk_disable_unprepare(host->ciu_clk);
2314 clk_put(host->ciu_clk); 2306
2315 }
2316err_clk_biu: 2307err_clk_biu:
2317 if (!IS_ERR(host->biu_clk)) { 2308 if (!IS_ERR(host->biu_clk))
2318 clk_disable_unprepare(host->biu_clk); 2309 clk_disable_unprepare(host->biu_clk);
2319 clk_put(host->biu_clk); 2310
2320 }
2321 return ret; 2311 return ret;
2322} 2312}
2323EXPORT_SYMBOL(dw_mci_probe); 2313EXPORT_SYMBOL(dw_mci_probe);
@@ -2339,24 +2329,19 @@ void dw_mci_remove(struct dw_mci *host)
2339 mci_writel(host, CLKENA, 0); 2329 mci_writel(host, CLKENA, 0);
2340 mci_writel(host, CLKSRC, 0); 2330 mci_writel(host, CLKSRC, 0);
2341 2331
2342 free_irq(host->irq, host);
2343 destroy_workqueue(host->card_workqueue); 2332 destroy_workqueue(host->card_workqueue);
2344 dma_free_coherent(host->dev, PAGE_SIZE, host->sg_cpu, host->sg_dma);
2345 2333
2346 if (host->use_dma && host->dma_ops->exit) 2334 if (host->use_dma && host->dma_ops->exit)
2347 host->dma_ops->exit(host); 2335 host->dma_ops->exit(host);
2348 2336
2349 if (host->vmmc) { 2337 if (host->vmmc)
2350 regulator_disable(host->vmmc); 2338 regulator_disable(host->vmmc);
2351 regulator_put(host->vmmc);
2352 }
2353 2339
2354 if (!IS_ERR(host->ciu_clk)) 2340 if (!IS_ERR(host->ciu_clk))
2355 clk_disable_unprepare(host->ciu_clk); 2341 clk_disable_unprepare(host->ciu_clk);
2342
2356 if (!IS_ERR(host->biu_clk)) 2343 if (!IS_ERR(host->biu_clk))
2357 clk_disable_unprepare(host->biu_clk); 2344 clk_disable_unprepare(host->biu_clk);
2358 clk_put(host->ciu_clk);
2359 clk_put(host->biu_clk);
2360} 2345}
2361EXPORT_SYMBOL(dw_mci_remove); 2346EXPORT_SYMBOL(dw_mci_remove);
2362 2347