diff mbox

[v1] cpufreq: kirkwood-cpufreq:- Handle return value of clk_prepare_enable

Message ID 1494918717-16434-1-git-send-email-arvind.yadav.cs@gmail.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Arvind Yadav May 16, 2017, 7:11 a.m. UTC
Here, Clock enable can failed. So adding an error check for
clk_prepare_enable.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
 drivers/cpufreq/kirkwood-cpufreq.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

Comments

Viresh Kumar May 17, 2017, 4:34 a.m. UTC | #1
On 16-05-17, 12:41, Arvind Yadav wrote:
> Here, Clock enable can failed. So adding an error check for
> clk_prepare_enable.

Rewrite it as:

clk_prepare_enable() can fail here and we must check its return value.

> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
> ---
>  drivers/cpufreq/kirkwood-cpufreq.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/cpufreq/kirkwood-cpufreq.c b/drivers/cpufreq/kirkwood-cpufreq.c
> index 1b9bcd7..4c30103 100644
> --- a/drivers/cpufreq/kirkwood-cpufreq.c
> +++ b/drivers/cpufreq/kirkwood-cpufreq.c
> @@ -127,7 +127,12 @@ static int kirkwood_cpufreq_probe(struct platform_device *pdev)
>  		return PTR_ERR(priv.cpu_clk);
>  	}
>  
> -	clk_prepare_enable(priv.cpu_clk);
> +	err = clk_prepare_enable(priv.cpu_clk);
> +	if (err) {
> +		dev_err(priv.dev, "Unable to prepare cpuclk\n");
> +		return err;
> +	}
> +
>  	kirkwood_freq_table[0].frequency = clk_get_rate(priv.cpu_clk) / 1000;
>  
>  	priv.ddr_clk = of_clk_get_by_name(np, "ddrclk");
> @@ -137,7 +142,11 @@ static int kirkwood_cpufreq_probe(struct platform_device *pdev)
>  		goto out_cpu;
>  	}
>  
> -	clk_prepare_enable(priv.ddr_clk);
> +	err = clk_prepare_enable(priv.ddr_clk);
> +	if (err) {
> +		dev_err(priv.dev, "Unable to prepare ddrclk\n");
> +		goto out_cpu;
> +	}
>  	kirkwood_freq_table[1].frequency = clk_get_rate(priv.ddr_clk) / 1000;
>  
>  	priv.powersave_clk = of_clk_get_by_name(np, "powersave");

There is one more prepare-enable after this. Why not fix that as well
?
Arvind Yadav May 17, 2017, 5:50 a.m. UTC | #2
Yes, I will add check for powersave clk.

Thanks
- Arvind

On Wednesday 17 May 2017 10:04 AM, Viresh Kumar wrote:
> On 16-05-17, 12:41, Arvind Yadav wrote:
>> Here, Clock enable can failed. So adding an error check for
>> clk_prepare_enable.
> Rewrite it as:
>
> clk_prepare_enable() can fail here and we must check its return value.
>
>> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
>> ---
>>   drivers/cpufreq/kirkwood-cpufreq.c | 13 +++++++++++--
>>   1 file changed, 11 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/cpufreq/kirkwood-cpufreq.c b/drivers/cpufreq/kirkwood-cpufreq.c
>> index 1b9bcd7..4c30103 100644
>> --- a/drivers/cpufreq/kirkwood-cpufreq.c
>> +++ b/drivers/cpufreq/kirkwood-cpufreq.c
>> @@ -127,7 +127,12 @@ static int kirkwood_cpufreq_probe(struct platform_device *pdev)
>>   		return PTR_ERR(priv.cpu_clk);
>>   	}
>>   
>> -	clk_prepare_enable(priv.cpu_clk);
>> +	err = clk_prepare_enable(priv.cpu_clk);
>> +	if (err) {
>> +		dev_err(priv.dev, "Unable to prepare cpuclk\n");
>> +		return err;
>> +	}
>> +
>>   	kirkwood_freq_table[0].frequency = clk_get_rate(priv.cpu_clk) / 1000;
>>   
>>   	priv.ddr_clk = of_clk_get_by_name(np, "ddrclk");
>> @@ -137,7 +142,11 @@ static int kirkwood_cpufreq_probe(struct platform_device *pdev)
>>   		goto out_cpu;
>>   	}
>>   
>> -	clk_prepare_enable(priv.ddr_clk);
>> +	err = clk_prepare_enable(priv.ddr_clk);
>> +	if (err) {
>> +		dev_err(priv.dev, "Unable to prepare ddrclk\n");
>> +		goto out_cpu;
>> +	}
>>   	kirkwood_freq_table[1].frequency = clk_get_rate(priv.ddr_clk) / 1000;
>>   
>>   	priv.powersave_clk = of_clk_get_by_name(np, "powersave");
> There is one more prepare-enable after this. Why not fix that as well
> ?
>
diff mbox

Patch

diff --git a/drivers/cpufreq/kirkwood-cpufreq.c b/drivers/cpufreq/kirkwood-cpufreq.c
index 1b9bcd7..4c30103 100644
--- a/drivers/cpufreq/kirkwood-cpufreq.c
+++ b/drivers/cpufreq/kirkwood-cpufreq.c
@@ -127,7 +127,12 @@  static int kirkwood_cpufreq_probe(struct platform_device *pdev)
 		return PTR_ERR(priv.cpu_clk);
 	}
 
-	clk_prepare_enable(priv.cpu_clk);
+	err = clk_prepare_enable(priv.cpu_clk);
+	if (err) {
+		dev_err(priv.dev, "Unable to prepare cpuclk\n");
+		return err;
+	}
+
 	kirkwood_freq_table[0].frequency = clk_get_rate(priv.cpu_clk) / 1000;
 
 	priv.ddr_clk = of_clk_get_by_name(np, "ddrclk");
@@ -137,7 +142,11 @@  static int kirkwood_cpufreq_probe(struct platform_device *pdev)
 		goto out_cpu;
 	}
 
-	clk_prepare_enable(priv.ddr_clk);
+	err = clk_prepare_enable(priv.ddr_clk);
+	if (err) {
+		dev_err(priv.dev, "Unable to prepare ddrclk\n");
+		goto out_cpu;
+	}
 	kirkwood_freq_table[1].frequency = clk_get_rate(priv.ddr_clk) / 1000;
 
 	priv.powersave_clk = of_clk_get_by_name(np, "powersave");