diff mbox

[3/6] mmc: sh-mmcif: use devm_ for clock management

Message ID 1396347954-13740-4-git-send-email-ben.dooks@codethink.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Ben Dooks April 1, 2014, 10:25 a.m. UTC
---
 drivers/mmc/host/sh_mmcif.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

Comments

Geert Uytterhoeven April 1, 2014, 10:59 a.m. UTC | #1
On Tue, Apr 1, 2014 at 12:25 PM, Ben Dooks <ben.dooks@codethink.co.uk> wrote:
> -       host->hclk = clk_get(&pdev->dev, NULL);
> +       host->hclk = devm_clk_get(&pdev->dev, NULL);
>         if (IS_ERR(host->hclk)) {
>                 ret = PTR_ERR(host->hclk);
>                 dev_err(&pdev->dev, "cannot get clock: %d\n", ret);
> -               goto eclkget;
> +               goto err_pm;
>         }
>         ret = sh_mmcif_clk_update(host);
>         if (ret < 0)
> -               goto eclkupdate;
> +               goto err_clk;

This goto doesn't look correct to me. If sh_mmcif_clk_update() failed,
the clock was not enabled nor prepared. "goto err_pm"?

>         ret = pm_runtime_resume(&pdev->dev);
>         if (ret < 0)
> -               goto eresume;
> +               goto err_clk;
>
>         INIT_DELAYED_WORK(&host->timeout_work, mmcif_timeout_work);
>
> @@ -1486,13 +1486,11 @@ ereqirq1:
>         free_irq(irq[0], host);
>  ereqirq0:
>         pm_runtime_suspend(&pdev->dev);
> -eresume:
> +err_clk:
>         clk_disable_unprepare(host->hclk);
> -eclkupdate:
> -       clk_put(host->hclk);
> -eclkget:
> +err_pm:
>         pm_runtime_disable(&pdev->dev);
> -eofparse:
> +err_host:
>         mmc_free_host(mmc);
>         return ret;

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ben Dooks April 1, 2014, 11:25 a.m. UTC | #2
On 01/04/14 11:59, Geert Uytterhoeven wrote:
> On Tue, Apr 1, 2014 at 12:25 PM, Ben Dooks <ben.dooks@codethink.co.uk> wrote:
>> -       host->hclk = clk_get(&pdev->dev, NULL);
>> +       host->hclk = devm_clk_get(&pdev->dev, NULL);
>>          if (IS_ERR(host->hclk)) {
>>                  ret = PTR_ERR(host->hclk);
>>                  dev_err(&pdev->dev, "cannot get clock: %d\n", ret);
>> -               goto eclkget;
>> +               goto err_pm;
>>          }
>>          ret = sh_mmcif_clk_update(host);
>>          if (ret < 0)
>> -               goto eclkupdate;
>> +               goto err_clk;
>
> This goto doesn't look correct to me. If sh_mmcif_clk_update() failed,
> the clock was not enabled nor prepared. "goto err_pm"?

Yes, I think the clk_prepare_enable() call there is the only failure
mode.

As a note, we should probably check all systems that use it and see if
we can remove the clock management code in here as the pm_runtime will
also be doing this.
diff mbox

Patch

diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
index be6be2b..c006310 100644
--- a/drivers/mmc/host/sh_mmcif.c
+++ b/drivers/mmc/host/sh_mmcif.c
@@ -1393,7 +1393,7 @@  static int sh_mmcif_probe(struct platform_device *pdev)
 
 	ret = mmc_of_parse(mmc);
 	if (ret < 0)
-		goto eofparse;
+		goto err_host;
 
 	host		= mmc_priv(mmc);
 	host->mmc	= mmc;
@@ -1423,19 +1423,19 @@  static int sh_mmcif_probe(struct platform_device *pdev)
 	pm_runtime_enable(&pdev->dev);
 	host->power = false;
 
-	host->hclk = clk_get(&pdev->dev, NULL);
+	host->hclk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(host->hclk)) {
 		ret = PTR_ERR(host->hclk);
 		dev_err(&pdev->dev, "cannot get clock: %d\n", ret);
-		goto eclkget;
+		goto err_pm;
 	}
 	ret = sh_mmcif_clk_update(host);
 	if (ret < 0)
-		goto eclkupdate;
+		goto err_clk;
 
 	ret = pm_runtime_resume(&pdev->dev);
 	if (ret < 0)
-		goto eresume;
+		goto err_clk;
 
 	INIT_DELAYED_WORK(&host->timeout_work, mmcif_timeout_work);
 
@@ -1486,13 +1486,11 @@  ereqirq1:
 	free_irq(irq[0], host);
 ereqirq0:
 	pm_runtime_suspend(&pdev->dev);
-eresume:
+err_clk:
 	clk_disable_unprepare(host->hclk);
-eclkupdate:
-	clk_put(host->hclk);
-eclkget:
+err_pm:
 	pm_runtime_disable(&pdev->dev);
-eofparse:
+err_host:
 	mmc_free_host(mmc);
 	return ret;
 }