diff mbox

[2/3] power: clock_ops.c: check return of clk_enable() in pm_clk_resume()

Message ID 1389445540-21426-2-git-send-email-ben.dooks@codethink.co.uk (mailing list archive)
State Superseded
Headers show

Commit Message

Ben Dooks Jan. 11, 2014, 1:05 p.m. UTC
The clk_enable() call in the pm_clk_resume() call returns an error
that is not being checked. If clk_enable() fails then we should
not set the state of the clock to PCE_STATUS_ENABLED.

Note, the issue of warning the user if this fails has not been
addressed in this patch as this is not the only place the driver
calls clk_enable().

Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-pm@vger.kernel.org
Cc: linux-sh@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Reviewed-by: Ian Molton <ian.molton@codethink.co.uk>
---
 drivers/base/power/clock_ops.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Rafael J. Wysocki Jan. 13, 2014, 7:55 p.m. UTC | #1
On Saturday, January 11, 2014 01:05:39 PM Ben Dooks wrote:
> The clk_enable() call in the pm_clk_resume() call returns an error
> that is not being checked. If clk_enable() fails then we should
> not set the state of the clock to PCE_STATUS_ENABLED.
> 
> Note, the issue of warning the user if this fails has not been
> addressed in this patch as this is not the only place the driver
> calls clk_enable().
> 
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: Pavel Machek <pavel@ucw.cz>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: linux-pm@vger.kernel.org
> Cc: linux-sh@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
> Reviewed-by: Ian Molton <ian.molton@codethink.co.uk>
> ---
>  drivers/base/power/clock_ops.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/base/power/clock_ops.c b/drivers/base/power/clock_ops.c
> index b9dd8fa..9bb95ab 100644
> --- a/drivers/base/power/clock_ops.c
> +++ b/drivers/base/power/clock_ops.c
> @@ -252,6 +252,7 @@ int pm_clk_resume(struct device *dev)
>  	struct pm_subsys_data *psd = dev_to_psd(dev);
>  	struct pm_clock_entry *ce;
>  	unsigned long flags;
> +	int ret;
>  
>  	dev_dbg(dev, "%s()\n", __func__);
>  
> @@ -262,8 +263,9 @@ int pm_clk_resume(struct device *dev)
>  
>  	list_for_each_entry(ce, &psd->clock_list, node) {
>  		if (ce->status < PCE_STATUS_ERROR) {
> -			clk_enable(ce->clk);
> -			ce->status = PCE_STATUS_ENABLED;
> +			ret = clk_enable(ce->clk);
> +			if (ret == 0)

Can you please use if (!ret) here?

And analogously in patch [3/3]?

> +				ce->status = PCE_STATUS_ENABLED;
>  		}
>  	}
>  
>
Ben Dooks Jan. 14, 2014, 12:02 p.m. UTC | #2
On 13/01/14 19:55, Rafael J. Wysocki wrote:
> On Saturday, January 11, 2014 01:05:39 PM Ben Dooks wrote:

>> @@ -262,8 +263,9 @@ int pm_clk_resume(struct device *dev)
>>
>>   	list_for_each_entry(ce, &psd->clock_list, node) {
>>   		if (ce->status < PCE_STATUS_ERROR) {
>> -			clk_enable(ce->clk);
>> -			ce->status = PCE_STATUS_ENABLED;
>> +			ret = clk_enable(ce->clk);
>> +			if (ret == 0)
>
> Can you please use if (!ret) here?
>
> And analogously in patch [3/3]?

I will fix and re-send today, thanks.
diff mbox

Patch

diff --git a/drivers/base/power/clock_ops.c b/drivers/base/power/clock_ops.c
index b9dd8fa..9bb95ab 100644
--- a/drivers/base/power/clock_ops.c
+++ b/drivers/base/power/clock_ops.c
@@ -252,6 +252,7 @@  int pm_clk_resume(struct device *dev)
 	struct pm_subsys_data *psd = dev_to_psd(dev);
 	struct pm_clock_entry *ce;
 	unsigned long flags;
+	int ret;
 
 	dev_dbg(dev, "%s()\n", __func__);
 
@@ -262,8 +263,9 @@  int pm_clk_resume(struct device *dev)
 
 	list_for_each_entry(ce, &psd->clock_list, node) {
 		if (ce->status < PCE_STATUS_ERROR) {
-			clk_enable(ce->clk);
-			ce->status = PCE_STATUS_ENABLED;
+			ret = clk_enable(ce->clk);
+			if (ret == 0)
+				ce->status = PCE_STATUS_ENABLED;
 		}
 	}