diff options
Diffstat (limited to 'drivers/mmc/host/sdhci-s3c.c')
-rw-r--r-- | drivers/mmc/host/sdhci-s3c.c | 40 |
1 files changed, 9 insertions, 31 deletions
diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c index 47bb04390f9c..93c5d62fcaff 100644 --- a/drivers/mmc/host/sdhci-s3c.c +++ b/drivers/mmc/host/sdhci-s3c.c | |||
@@ -413,7 +413,7 @@ static void sdhci_s3c_setup_card_detect_gpio(struct sdhci_s3c *sc) | |||
413 | struct s3c_sdhci_platdata *pdata = sc->pdata; | 413 | struct s3c_sdhci_platdata *pdata = sc->pdata; |
414 | struct device *dev = &sc->pdev->dev; | 414 | struct device *dev = &sc->pdev->dev; |
415 | 415 | ||
416 | if (gpio_request(pdata->ext_cd_gpio, "SDHCI EXT CD") == 0) { | 416 | if (devm_gpio_request(dev, pdata->ext_cd_gpio, "SDHCI EXT CD") == 0) { |
417 | sc->ext_cd_gpio = pdata->ext_cd_gpio; | 417 | sc->ext_cd_gpio = pdata->ext_cd_gpio; |
418 | sc->ext_cd_irq = gpio_to_irq(pdata->ext_cd_gpio); | 418 | sc->ext_cd_irq = gpio_to_irq(pdata->ext_cd_gpio); |
419 | if (sc->ext_cd_irq && | 419 | if (sc->ext_cd_irq && |
@@ -494,7 +494,7 @@ static int __devinit sdhci_s3c_parse_dt(struct device *dev, | |||
494 | if (of_get_property(node, "cd-inverted", NULL)) | 494 | if (of_get_property(node, "cd-inverted", NULL)) |
495 | pdata->ext_cd_gpio_invert = 1; | 495 | pdata->ext_cd_gpio_invert = 1; |
496 | } else if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) { | 496 | } else if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) { |
497 | ret = gpio_request(gpio, "sdhci-cd"); | 497 | ret = devm_gpio_request(dev, gpio, "sdhci-cd"); |
498 | if (ret) { | 498 | if (ret) { |
499 | dev_err(dev, "card detect gpio request failed\n"); | 499 | dev_err(dev, "card detect gpio request failed\n"); |
500 | return -EINVAL; | 500 | return -EINVAL; |
@@ -508,28 +508,20 @@ static int __devinit sdhci_s3c_parse_dt(struct device *dev, | |||
508 | gpio = of_get_gpio(node, cnt); | 508 | gpio = of_get_gpio(node, cnt); |
509 | if (!gpio_is_valid(gpio)) { | 509 | if (!gpio_is_valid(gpio)) { |
510 | dev_err(dev, "invalid gpio[%d]\n", cnt); | 510 | dev_err(dev, "invalid gpio[%d]\n", cnt); |
511 | goto err_free_dt_cd_gpio; | 511 | return -EINVAL; |
512 | } | 512 | } |
513 | ourhost->gpios[cnt] = gpio; | 513 | ourhost->gpios[cnt] = gpio; |
514 | } | 514 | } |
515 | 515 | ||
516 | for (cnt = 0; cnt < NUM_GPIOS(pdata->max_width); cnt++) { | 516 | for (cnt = 0; cnt < NUM_GPIOS(pdata->max_width); cnt++) { |
517 | ret = gpio_request(ourhost->gpios[cnt], "sdhci-gpio"); | 517 | ret = devm_gpio_request(dev, ourhost->gpios[cnt], "sdhci-gpio"); |
518 | if (ret) { | 518 | if (ret) { |
519 | dev_err(dev, "gpio[%d] request failed\n", cnt); | 519 | dev_err(dev, "gpio[%d] request failed\n", cnt); |
520 | goto err_free_dt_gpios; | 520 | return -EINVAL; |
521 | } | 521 | } |
522 | } | 522 | } |
523 | 523 | ||
524 | return 0; | 524 | return 0; |
525 | |||
526 | err_free_dt_gpios: | ||
527 | while (--cnt >= 0) | ||
528 | gpio_free(ourhost->gpios[cnt]); | ||
529 | err_free_dt_cd_gpio: | ||
530 | if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) | ||
531 | gpio_free(ourhost->ext_cd_gpio); | ||
532 | return -EINVAL; | ||
533 | } | 525 | } |
534 | #else | 526 | #else |
535 | static int __devinit sdhci_s3c_parse_dt(struct device *dev, | 527 | static int __devinit sdhci_s3c_parse_dt(struct device *dev, |
@@ -586,13 +578,13 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev) | |||
586 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); | 578 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); |
587 | if (!pdata) { | 579 | if (!pdata) { |
588 | ret = -ENOMEM; | 580 | ret = -ENOMEM; |
589 | goto err_pdata; | 581 | goto err_pdata_io_clk; |
590 | } | 582 | } |
591 | 583 | ||
592 | if (pdev->dev.of_node) { | 584 | if (pdev->dev.of_node) { |
593 | ret = sdhci_s3c_parse_dt(&pdev->dev, host, pdata); | 585 | ret = sdhci_s3c_parse_dt(&pdev->dev, host, pdata); |
594 | if (ret) | 586 | if (ret) |
595 | goto err_pdata; | 587 | goto err_pdata_io_clk; |
596 | } else { | 588 | } else { |
597 | memcpy(pdata, pdev->dev.platform_data, sizeof(*pdata)); | 589 | memcpy(pdata, pdev->dev.platform_data, sizeof(*pdata)); |
598 | sc->ext_cd_gpio = -1; /* invalid gpio number */ | 590 | sc->ext_cd_gpio = -1; /* invalid gpio number */ |
@@ -610,7 +602,7 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev) | |||
610 | if (IS_ERR(sc->clk_io)) { | 602 | if (IS_ERR(sc->clk_io)) { |
611 | dev_err(dev, "failed to get io clock\n"); | 603 | dev_err(dev, "failed to get io clock\n"); |
612 | ret = PTR_ERR(sc->clk_io); | 604 | ret = PTR_ERR(sc->clk_io); |
613 | goto err_io_clk; | 605 | goto err_pdata_io_clk; |
614 | } | 606 | } |
615 | 607 | ||
616 | /* enable the local io clock and keep it running for the moment. */ | 608 | /* enable the local io clock and keep it running for the moment. */ |
@@ -773,13 +765,7 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev) | |||
773 | clk_disable_unprepare(sc->clk_io); | 765 | clk_disable_unprepare(sc->clk_io); |
774 | clk_put(sc->clk_io); | 766 | clk_put(sc->clk_io); |
775 | 767 | ||
776 | err_io_clk: | 768 | err_pdata_io_clk: |
777 | for (ptr = 0; ptr < NUM_GPIOS(sc->pdata->max_width); ptr++) | ||
778 | gpio_free(sc->gpios[ptr]); | ||
779 | if (pdata->cd_type == S3C_SDHCI_CD_INTERNAL) | ||
780 | gpio_free(sc->ext_cd_gpio); | ||
781 | |||
782 | err_pdata: | ||
783 | sdhci_free_host(host); | 769 | sdhci_free_host(host); |
784 | 770 | ||
785 | return ret; | 771 | return ret; |
@@ -798,9 +784,6 @@ static int __devexit sdhci_s3c_remove(struct platform_device *pdev) | |||
798 | if (sc->ext_cd_irq) | 784 | if (sc->ext_cd_irq) |
799 | free_irq(sc->ext_cd_irq, sc); | 785 | free_irq(sc->ext_cd_irq, sc); |
800 | 786 | ||
801 | if (gpio_is_valid(sc->ext_cd_gpio)) | ||
802 | gpio_free(sc->ext_cd_gpio); | ||
803 | |||
804 | #ifdef CONFIG_PM_RUNTIME | 787 | #ifdef CONFIG_PM_RUNTIME |
805 | if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL) | 788 | if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL) |
806 | clk_prepare_enable(sc->clk_io); | 789 | clk_prepare_enable(sc->clk_io); |
@@ -821,11 +804,6 @@ static int __devexit sdhci_s3c_remove(struct platform_device *pdev) | |||
821 | clk_disable_unprepare(sc->clk_io); | 804 | clk_disable_unprepare(sc->clk_io); |
822 | clk_put(sc->clk_io); | 805 | clk_put(sc->clk_io); |
823 | 806 | ||
824 | if (pdev->dev.of_node) { | ||
825 | for (ptr = 0; ptr < NUM_GPIOS(sc->pdata->max_width); ptr++) | ||
826 | gpio_free(sc->gpios[ptr]); | ||
827 | } | ||
828 | |||
829 | sdhci_free_host(host); | 807 | sdhci_free_host(host); |
830 | platform_set_drvdata(pdev, NULL); | 808 | platform_set_drvdata(pdev, NULL); |
831 | 809 | ||