[v4,05/10] memory: tegra20-emc: Replace clk_get_sys with devm_clk_get
diff mbox series

Message ID 20190616233551.6838-6-digetx@gmail.com
State New
Headers show
Series
  • memory: tegra: Introduce Tegra30 EMC driver
Related show

Commit Message

Dmitry Osipenko June 16, 2019, 11:35 p.m. UTC
There is no problem for drivers to request pll_m and pll_p clocks for
the device, hence there is no need to use clk_get_sys() and it could be
replaced with devm_clk_get() for consistency.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/memory/tegra/tegra20-emc.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

Comments

Thierry Reding June 17, 2019, 9:46 a.m. UTC | #1
On Mon, Jun 17, 2019 at 02:35:46AM +0300, Dmitry Osipenko wrote:
> There is no problem for drivers to request pll_m and pll_p clocks for
> the device, hence there is no need to use clk_get_sys() and it could be
> replaced with devm_clk_get() for consistency.
> 
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
>  drivers/memory/tegra/tegra20-emc.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/memory/tegra/tegra20-emc.c b/drivers/memory/tegra/tegra20-emc.c
> index 43aef3614b65..527aa4b90e95 100644
> --- a/drivers/memory/tegra/tegra20-emc.c
> +++ b/drivers/memory/tegra/tegra20-emc.c
> @@ -527,33 +527,29 @@ static int tegra_emc_probe(struct platform_device *pdev)
>  		goto unset_cb;
>  	}
>  
> -	emc->pll_m = clk_get_sys(NULL, "pll_m");
> +	emc->pll_m = devm_clk_get(&pdev->dev, "pll_m");

Interesting... I didn't know that clk_get() had a fallback path to
return clk_get_sys() if the named clock wasn't found in DT. That's
nice.

Looks good to me.

Thierry

>  	if (IS_ERR(emc->pll_m)) {
>  		err = PTR_ERR(emc->pll_m);
>  		dev_err(&pdev->dev, "failed to get pll_m clock: %d\n", err);
>  		goto unset_cb;
>  	}
>  
> -	emc->backup_clk = clk_get_sys(NULL, "pll_p");
> +	emc->backup_clk = devm_clk_get(&pdev->dev, "pll_p");
>  	if (IS_ERR(emc->backup_clk)) {
>  		err = PTR_ERR(emc->backup_clk);
>  		dev_err(&pdev->dev, "failed to get pll_p clock: %d\n", err);
> -		goto put_pll_m;
> +		goto unset_cb;
>  	}
>  
>  	err = clk_notifier_register(emc->clk, &emc->clk_nb);
>  	if (err) {
>  		dev_err(&pdev->dev, "failed to register clk notifier: %d\n",
>  			err);
> -		goto put_backup;
> +		goto unset_cb;
>  	}
>  
>  	return 0;
>  
> -put_backup:
> -	clk_put(emc->backup_clk);
> -put_pll_m:
> -	clk_put(emc->pll_m);
>  unset_cb:
>  	tegra20_clk_set_emc_round_callback(NULL, NULL);
>  
> -- 
> 2.22.0
>
Dmitry Osipenko June 17, 2019, 3:01 p.m. UTC | #2
17.06.2019 12:46, Thierry Reding пишет:
> On Mon, Jun 17, 2019 at 02:35:46AM +0300, Dmitry Osipenko wrote:
>> There is no problem for drivers to request pll_m and pll_p clocks for
>> the device, hence there is no need to use clk_get_sys() and it could be
>> replaced with devm_clk_get() for consistency.
>>
>> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
>> ---
>>  drivers/memory/tegra/tegra20-emc.c | 12 ++++--------
>>  1 file changed, 4 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/memory/tegra/tegra20-emc.c b/drivers/memory/tegra/tegra20-emc.c
>> index 43aef3614b65..527aa4b90e95 100644
>> --- a/drivers/memory/tegra/tegra20-emc.c
>> +++ b/drivers/memory/tegra/tegra20-emc.c
>> @@ -527,33 +527,29 @@ static int tegra_emc_probe(struct platform_device *pdev)
>>  		goto unset_cb;
>>  	}
>>  
>> -	emc->pll_m = clk_get_sys(NULL, "pll_m");
>> +	emc->pll_m = devm_clk_get(&pdev->dev, "pll_m");
> 
> Interesting... I didn't know that clk_get() had a fallback path to
> return clk_get_sys() if the named clock wasn't found in DT. That's
> nice.
> 
> Looks good to me.

Yes, I didn't know either until recently. Thanks!

Patch
diff mbox series

diff --git a/drivers/memory/tegra/tegra20-emc.c b/drivers/memory/tegra/tegra20-emc.c
index 43aef3614b65..527aa4b90e95 100644
--- a/drivers/memory/tegra/tegra20-emc.c
+++ b/drivers/memory/tegra/tegra20-emc.c
@@ -527,33 +527,29 @@  static int tegra_emc_probe(struct platform_device *pdev)
 		goto unset_cb;
 	}
 
-	emc->pll_m = clk_get_sys(NULL, "pll_m");
+	emc->pll_m = devm_clk_get(&pdev->dev, "pll_m");
 	if (IS_ERR(emc->pll_m)) {
 		err = PTR_ERR(emc->pll_m);
 		dev_err(&pdev->dev, "failed to get pll_m clock: %d\n", err);
 		goto unset_cb;
 	}
 
-	emc->backup_clk = clk_get_sys(NULL, "pll_p");
+	emc->backup_clk = devm_clk_get(&pdev->dev, "pll_p");
 	if (IS_ERR(emc->backup_clk)) {
 		err = PTR_ERR(emc->backup_clk);
 		dev_err(&pdev->dev, "failed to get pll_p clock: %d\n", err);
-		goto put_pll_m;
+		goto unset_cb;
 	}
 
 	err = clk_notifier_register(emc->clk, &emc->clk_nb);
 	if (err) {
 		dev_err(&pdev->dev, "failed to register clk notifier: %d\n",
 			err);
-		goto put_backup;
+		goto unset_cb;
 	}
 
 	return 0;
 
-put_backup:
-	clk_put(emc->backup_clk);
-put_pll_m:
-	clk_put(emc->pll_m);
 unset_cb:
 	tegra20_clk_set_emc_round_callback(NULL, NULL);