diff options
author | Jarkko Nikula <jarkko.nikula@bitmer.com> | 2014-02-22 11:01:41 -0500 |
---|---|---|
committer | Chris Ball <chris@printf.net> | 2014-02-22 13:17:31 -0500 |
commit | 64ac16ec80bc5aacdc2549226f2c0d48d185123c (patch) | |
tree | 0612c783f0065459defe8a629d3eb5bdfcf00a80 /drivers/mmc/host/omap.c | |
parent | 2ca5dc6ffa3d9fefadfff0fee77e1ad52e2c0b72 (diff) |
mmc: omap: Convert to devm_ioremap_resource
Simplify probe and cleanup code by using devm_ioremap_resource. This also
makes probe code to follow more common allocate private struct followed by
other initialization style.
Signed-off-by: Jarkko Nikula <jarkko.nikula@bitmer.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Tested-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Chris Ball <chris@printf.net>
Diffstat (limited to 'drivers/mmc/host/omap.c')
-rw-r--r-- | drivers/mmc/host/omap.c | 41 |
1 files changed, 12 insertions, 29 deletions
diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c index 0d669cfa6af6..e4c7a0380a63 100644 --- a/drivers/mmc/host/omap.c +++ b/drivers/mmc/host/omap.c | |||
@@ -1334,22 +1334,19 @@ static int mmc_omap_probe(struct platform_device *pdev) | |||
1334 | return -EPROBE_DEFER; | 1334 | return -EPROBE_DEFER; |
1335 | } | 1335 | } |
1336 | 1336 | ||
1337 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1337 | host = devm_kzalloc(&pdev->dev, sizeof(struct mmc_omap_host), |
1338 | GFP_KERNEL); | ||
1339 | if (host == NULL) | ||
1340 | return -ENOMEM; | ||
1341 | |||
1338 | irq = platform_get_irq(pdev, 0); | 1342 | irq = platform_get_irq(pdev, 0); |
1339 | if (res == NULL || irq < 0) | 1343 | if (irq < 0) |
1340 | return -ENXIO; | 1344 | return -ENXIO; |
1341 | 1345 | ||
1342 | res = request_mem_region(res->start, resource_size(res), | 1346 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
1343 | pdev->name); | 1347 | host->virt_base = devm_ioremap_resource(&pdev->dev, res); |
1344 | if (res == NULL) | 1348 | if (IS_ERR(host->virt_base)) |
1345 | return -EBUSY; | 1349 | return PTR_ERR(host->virt_base); |
1346 | |||
1347 | host = devm_kzalloc(&pdev->dev, sizeof(struct mmc_omap_host), | ||
1348 | GFP_KERNEL); | ||
1349 | if (host == NULL) { | ||
1350 | ret = -ENOMEM; | ||
1351 | goto err_free_mem_region; | ||
1352 | } | ||
1353 | 1350 | ||
1354 | INIT_WORK(&host->slot_release_work, mmc_omap_slot_release_work); | 1351 | INIT_WORK(&host->slot_release_work, mmc_omap_slot_release_work); |
1355 | INIT_WORK(&host->send_stop_work, mmc_omap_send_stop_work); | 1352 | INIT_WORK(&host->send_stop_work, mmc_omap_send_stop_work); |
@@ -1374,15 +1371,9 @@ static int mmc_omap_probe(struct platform_device *pdev) | |||
1374 | host->irq = irq; | 1371 | host->irq = irq; |
1375 | host->use_dma = 1; | 1372 | host->use_dma = 1; |
1376 | host->phys_base = res->start; | 1373 | host->phys_base = res->start; |
1377 | host->virt_base = ioremap(res->start, resource_size(res)); | ||
1378 | if (!host->virt_base) | ||
1379 | goto err_ioremap; | ||
1380 | |||
1381 | host->iclk = clk_get(&pdev->dev, "ick"); | 1374 | host->iclk = clk_get(&pdev->dev, "ick"); |
1382 | if (IS_ERR(host->iclk)) { | 1375 | if (IS_ERR(host->iclk)) |
1383 | ret = PTR_ERR(host->iclk); | 1376 | return PTR_ERR(host->iclk); |
1384 | goto err_free_mmc_host; | ||
1385 | } | ||
1386 | clk_enable(host->iclk); | 1377 | clk_enable(host->iclk); |
1387 | 1378 | ||
1388 | host->fclk = clk_get(&pdev->dev, "fck"); | 1379 | host->fclk = clk_get(&pdev->dev, "fck"); |
@@ -1460,11 +1451,6 @@ err_free_dma: | |||
1460 | err_free_iclk: | 1451 | err_free_iclk: |
1461 | clk_disable(host->iclk); | 1452 | clk_disable(host->iclk); |
1462 | clk_put(host->iclk); | 1453 | clk_put(host->iclk); |
1463 | err_free_mmc_host: | ||
1464 | iounmap(host->virt_base); | ||
1465 | err_ioremap: | ||
1466 | err_free_mem_region: | ||
1467 | release_mem_region(res->start, resource_size(res)); | ||
1468 | return ret; | 1454 | return ret; |
1469 | } | 1455 | } |
1470 | 1456 | ||
@@ -1492,9 +1478,6 @@ static int mmc_omap_remove(struct platform_device *pdev) | |||
1492 | if (host->dma_rx) | 1478 | if (host->dma_rx) |
1493 | dma_release_channel(host->dma_rx); | 1479 | dma_release_channel(host->dma_rx); |
1494 | 1480 | ||
1495 | iounmap(host->virt_base); | ||
1496 | release_mem_region(pdev->resource[0].start, | ||
1497 | pdev->resource[0].end - pdev->resource[0].start + 1); | ||
1498 | destroy_workqueue(host->mmc_omap_wq); | 1481 | destroy_workqueue(host->mmc_omap_wq); |
1499 | 1482 | ||
1500 | return 0; | 1483 | return 0; |