diff mbox

[v1,04/11] cpufreq: tegra20: Release clocks properly

Message ID 20180517180056.13336-5-digetx@gmail.com
State Changes Requested, archived
Headers show

Commit Message

Dmitry Osipenko May 17, 2018, 6 p.m. UTC
Properly put requested clocks in the module init/exit code.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/cpufreq/tegra20-cpufreq.c | 31 ++++++++++++++++++++++++++-----
 1 file changed, 26 insertions(+), 5 deletions(-)

Comments

Viresh Kumar May 18, 2018, 1:55 a.m. UTC | #1
On 17-05-18, 21:00, Dmitry Osipenko wrote:
> Properly put requested clocks in the module init/exit code.
> 
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
>  drivers/cpufreq/tegra20-cpufreq.c | 31 ++++++++++++++++++++++++++-----
>  1 file changed, 26 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/cpufreq/tegra20-cpufreq.c b/drivers/cpufreq/tegra20-cpufreq.c
> index 693f9067ba8a..69f033d297e1 100644
> --- a/drivers/cpufreq/tegra20-cpufreq.c
> +++ b/drivers/cpufreq/tegra20-cpufreq.c
> @@ -165,24 +165,45 @@ static struct cpufreq_driver tegra_cpufreq_driver = {
>  
>  static int __init tegra_cpufreq_init(void)
>  {
> +	int err;
> +
>  	cpu_clk = clk_get_sys(NULL, "cclk");
>  	if (IS_ERR(cpu_clk))
>  		return PTR_ERR(cpu_clk);
>  
>  	pll_x_clk = clk_get_sys(NULL, "pll_x");
> -	if (IS_ERR(pll_x_clk))
> -		return PTR_ERR(pll_x_clk);
> +	if (IS_ERR(pll_x_clk)) {
> +		err = PTR_ERR(pll_x_clk);
> +		goto put_cpu;
> +	}
>  
>  	pll_p_clk = clk_get_sys(NULL, "pll_p");
> -	if (IS_ERR(pll_p_clk))
> -		return PTR_ERR(pll_p_clk);
> +	if (IS_ERR(pll_p_clk)) {
> +		err = PTR_ERR(pll_p_clk);
> +		goto put_pll_x;
> +	}
> +
> +	err = cpufreq_register_driver(&tegra_cpufreq_driver);
> +	if (err)
> +		goto put_pll_p;
> +
> +	return 0;
> +
> +put_pll_p:
> +	clk_put(pll_p_clk);
> +put_pll_x:
> +	clk_put(pll_x_clk);
> +put_cpu:
> +	clk_put(cpu_clk);
>  
> -	return cpufreq_register_driver(&tegra_cpufreq_driver);
> +	return err;
>  }
>  
>  static void __exit tegra_cpufreq_exit(void)
>  {
>  	cpufreq_unregister_driver(&tegra_cpufreq_driver);
> +	clk_put(pll_p_clk);
> +	clk_put(pll_x_clk);
>  	clk_put(cpu_clk);
>  }

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Thierry Reding May 18, 2018, 8:37 a.m. UTC | #2
On Thu, May 17, 2018 at 09:00:49PM +0300, Dmitry Osipenko wrote:
> Properly put requested clocks in the module init/exit code.
> 
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
>  drivers/cpufreq/tegra20-cpufreq.c | 31 ++++++++++++++++++++++++++-----
>  1 file changed, 26 insertions(+), 5 deletions(-)

Acked-by: Thierry Reding <treding@nvidia.com>
diff mbox

Patch

diff --git a/drivers/cpufreq/tegra20-cpufreq.c b/drivers/cpufreq/tegra20-cpufreq.c
index 693f9067ba8a..69f033d297e1 100644
--- a/drivers/cpufreq/tegra20-cpufreq.c
+++ b/drivers/cpufreq/tegra20-cpufreq.c
@@ -165,24 +165,45 @@  static struct cpufreq_driver tegra_cpufreq_driver = {
 
 static int __init tegra_cpufreq_init(void)
 {
+	int err;
+
 	cpu_clk = clk_get_sys(NULL, "cclk");
 	if (IS_ERR(cpu_clk))
 		return PTR_ERR(cpu_clk);
 
 	pll_x_clk = clk_get_sys(NULL, "pll_x");
-	if (IS_ERR(pll_x_clk))
-		return PTR_ERR(pll_x_clk);
+	if (IS_ERR(pll_x_clk)) {
+		err = PTR_ERR(pll_x_clk);
+		goto put_cpu;
+	}
 
 	pll_p_clk = clk_get_sys(NULL, "pll_p");
-	if (IS_ERR(pll_p_clk))
-		return PTR_ERR(pll_p_clk);
+	if (IS_ERR(pll_p_clk)) {
+		err = PTR_ERR(pll_p_clk);
+		goto put_pll_x;
+	}
+
+	err = cpufreq_register_driver(&tegra_cpufreq_driver);
+	if (err)
+		goto put_pll_p;
+
+	return 0;
+
+put_pll_p:
+	clk_put(pll_p_clk);
+put_pll_x:
+	clk_put(pll_x_clk);
+put_cpu:
+	clk_put(cpu_clk);
 
-	return cpufreq_register_driver(&tegra_cpufreq_driver);
+	return err;
 }
 
 static void __exit tegra_cpufreq_exit(void)
 {
 	cpufreq_unregister_driver(&tegra_cpufreq_driver);
+	clk_put(pll_p_clk);
+	clk_put(pll_x_clk);
 	clk_put(cpu_clk);
 }