aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulia Lawall <Julia.Lawall@lip6.fr>2012-03-08 23:24:53 -0500
committerChris Ball <cjb@laptop.org>2012-04-05 20:32:16 -0400
commit9bda6da7ff7d35ef757e235aae559e679d3a9493 (patch)
treefb2e3eeb8d6175d6f82aa6a9de376a10d2f3b0a4
parent1d4dc338bb7cbbadcb5a527b1b0e897b5cde1701 (diff)
mmc: sdhci-s3c: use devm_ functions
The various devm_ functions allocate memory that is released when a driver detaches. This patch uses these functions for data that is allocated in the probe function of a platform device and is only freed in the remove function. By using devm_ioremap, it also removes a potential memory leak, because there was no call to iounmap in the probe function. The call to platform_get_resource was moved just to make it closer to the place where its result it used. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Chris Ball <cjb@laptop.org>
-rw-r--r--drivers/mmc/host/sdhci-s3c.c27
1 files changed, 3 insertions, 24 deletions
diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
index e81a0339ab5c..c3144cb21325 100644
--- a/drivers/mmc/host/sdhci-s3c.c
+++ b/drivers/mmc/host/sdhci-s3c.c
@@ -443,12 +443,6 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
443 return irq; 443 return irq;
444 } 444 }
445 445
446 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
447 if (!res) {
448 dev_err(dev, "no memory specified\n");
449 return -ENOENT;
450 }
451
452 host = sdhci_alloc_host(dev, sizeof(struct sdhci_s3c)); 446 host = sdhci_alloc_host(dev, sizeof(struct sdhci_s3c));
453 if (IS_ERR(host)) { 447 if (IS_ERR(host)) {
454 dev_err(dev, "sdhci_alloc_host() failed\n"); 448 dev_err(dev, "sdhci_alloc_host() failed\n");
@@ -513,15 +507,8 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
513 goto err_no_busclks; 507 goto err_no_busclks;
514 } 508 }
515 509
516 sc->ioarea = request_mem_region(res->start, resource_size(res), 510 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
517 mmc_hostname(host->mmc)); 511 host->ioaddr = devm_request_and_ioremap(&pdev->dev, res);
518 if (!sc->ioarea) {
519 dev_err(dev, "failed to reserve register area\n");
520 ret = -ENXIO;
521 goto err_req_regs;
522 }
523
524 host->ioaddr = ioremap_nocache(res->start, resource_size(res));
525 if (!host->ioaddr) { 512 if (!host->ioaddr) {
526 dev_err(dev, "failed to map registers\n"); 513 dev_err(dev, "failed to map registers\n");
527 ret = -ENXIO; 514 ret = -ENXIO;
@@ -606,7 +593,7 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
606 ret = sdhci_add_host(host); 593 ret = sdhci_add_host(host);
607 if (ret) { 594 if (ret) {
608 dev_err(dev, "sdhci_add_host() failed\n"); 595 dev_err(dev, "sdhci_add_host() failed\n");
609 goto err_add_host; 596 goto err_req_regs;
610 } 597 }
611 598
612 /* The following two methods of card detection might call 599 /* The following two methods of card detection might call
@@ -620,10 +607,6 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
620 607
621 return 0; 608 return 0;
622 609
623 err_add_host:
624 release_resource(sc->ioarea);
625 kfree(sc->ioarea);
626
627 err_req_regs: 610 err_req_regs:
628 for (ptr = 0; ptr < MAX_BUS_CLK; ptr++) { 611 for (ptr = 0; ptr < MAX_BUS_CLK; ptr++) {
629 if (sc->clk_bus[ptr]) { 612 if (sc->clk_bus[ptr]) {
@@ -669,10 +652,6 @@ static int __devexit sdhci_s3c_remove(struct platform_device *pdev)
669 clk_disable(sc->clk_io); 652 clk_disable(sc->clk_io);
670 clk_put(sc->clk_io); 653 clk_put(sc->clk_io);
671 654
672 iounmap(host->ioaddr);
673 release_resource(sc->ioarea);
674 kfree(sc->ioarea);
675
676 sdhci_free_host(host); 655 sdhci_free_host(host);
677 platform_set_drvdata(pdev, NULL); 656 platform_set_drvdata(pdev, NULL);
678 657