diff mbox series

[v2] iio: adc: rockchip_saradc: fix missing clk_disable_unprepare() on error in rockchip_saradc_resume

Message ID 20201103074909.195465-1-miaoqinglang@huawei.com (mailing list archive)
State New, archived
Headers show
Series [v2] iio: adc: rockchip_saradc: fix missing clk_disable_unprepare() on error in rockchip_saradc_resume | expand

Commit Message

Qinglang Miao Nov. 3, 2020, 7:49 a.m. UTC
Fix the missing clk_disable_unprepare() of info->pclk
before return from rockchip_saradc_resume in the error
handling case when fails to prepare and enable info->clk.

Fixes: 44d6f2ef94f9 ("iio: adc: add driver for Rockchip saradc")
Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
---
 drivers/iio/adc/rockchip_saradc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Qinglang Miao Nov. 3, 2020, 8:20 a.m. UTC | #1
在 2020/11/3 15:49, Qinglang Miao 写道:
> Fix the missing clk_disable_unprepare() of info->pclk
> before return from rockchip_saradc_resume in the error
> handling case when fails to prepare and enable info->clk.
> 
> Fixes: 44d6f2ef94f9 ("iio: adc: add driver for Rockchip saradc")
> Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
> ---
>   drivers/iio/adc/rockchip_saradc.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/adc/rockchip_saradc.c b/drivers/iio/adc/rockchip_saradc.c
> index 1f3d7d639..5eb566274 100644
> --- a/drivers/iio/adc/rockchip_saradc.c
> +++ b/drivers/iio/adc/rockchip_saradc.c
> @@ -461,9 +461,10 @@ static int rockchip_saradc_resume(struct device *dev)
>   		return ret;
>   
>   	ret = clk_prepare_enable(info->clk);
> -	if (ret)
> +	if (ret) {
> +		clk_disable_unprepare(info->pclk);
>   		return ret;
> -
> +	}
>   	return ret;
>   }
>   #endif
> 
Hi everyone,

I made a careless mistake for adding v2 as subject-prefix, this patch is 
the base version actually.

Sorry about that.

Thanks.
Robin Murphy Nov. 3, 2020, 11:11 a.m. UTC | #2
On 2020-11-03 07:49, Qinglang Miao wrote:
> Fix the missing clk_disable_unprepare() of info->pclk
> before return from rockchip_saradc_resume in the error
> handling case when fails to prepare and enable info->clk.
> 
> Fixes: 44d6f2ef94f9 ("iio: adc: add driver for Rockchip saradc")
> Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
> ---
>   drivers/iio/adc/rockchip_saradc.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/adc/rockchip_saradc.c b/drivers/iio/adc/rockchip_saradc.c
> index 1f3d7d639..5eb566274 100644
> --- a/drivers/iio/adc/rockchip_saradc.c
> +++ b/drivers/iio/adc/rockchip_saradc.c
> @@ -461,9 +461,10 @@ static int rockchip_saradc_resume(struct device *dev)
>   		return ret;
>   
>   	ret = clk_prepare_enable(info->clk);
> -	if (ret)
> +	if (ret) {
> +		clk_disable_unprepare(info->pclk);
>   		return ret;

No need to add braces, just replace this utterly pointless "early" return ;)

Robin.

> -
> +	}
>   	return ret;
>   }
>   #endif
>
Qinglang Miao Nov. 3, 2020, 12:04 p.m. UTC | #3
在 2020/11/3 19:11, Robin Murphy 写道:
> On 2020-11-03 07:49, Qinglang Miao wrote:
>> Fix the missing clk_disable_unprepare() of info->pclk
>> before return from rockchip_saradc_resume in the error
>> handling case when fails to prepare and enable info->clk.
>>
>> Fixes: 44d6f2ef94f9 ("iio: adc: add driver for Rockchip saradc")
>> Signed-off-by: Qinglang Miao <miaoqinglang@huawei.com>
>> ---
>>   drivers/iio/adc/rockchip_saradc.c | 5 +++--
>>   1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/iio/adc/rockchip_saradc.c 
>> b/drivers/iio/adc/rockchip_saradc.c
>> index 1f3d7d639..5eb566274 100644
>> --- a/drivers/iio/adc/rockchip_saradc.c
>> +++ b/drivers/iio/adc/rockchip_saradc.c
>> @@ -461,9 +461,10 @@ static int rockchip_saradc_resume(struct device 
>> *dev)
>>           return ret;
>>       ret = clk_prepare_enable(info->clk);
>> -    if (ret)
>> +    if (ret) {
>> +        clk_disable_unprepare(info->pclk);
>>           return ret;
> 
> No need to add braces, just replace this utterly pointless "early" 
> return ;)
> 
> Robin.
You are right Robin, thanks a lot! :D

I've sent a 'real' v2 patch based on your advice.
> 
>> -
>> +    }
>>       return ret;
>>   }
>>   #endif
>>
> .
diff mbox series

Patch

diff --git a/drivers/iio/adc/rockchip_saradc.c b/drivers/iio/adc/rockchip_saradc.c
index 1f3d7d639..5eb566274 100644
--- a/drivers/iio/adc/rockchip_saradc.c
+++ b/drivers/iio/adc/rockchip_saradc.c
@@ -461,9 +461,10 @@  static int rockchip_saradc_resume(struct device *dev)
 		return ret;
 
 	ret = clk_prepare_enable(info->clk);
-	if (ret)
+	if (ret) {
+		clk_disable_unprepare(info->pclk);
 		return ret;
-
+	}
 	return ret;
 }
 #endif