diff mbox series

clk: imx: scu: Fix pm_runtime_get_sync() error checking

Message ID 20220412065719.17735-1-linmq006@gmail.com (mailing list archive)
State New, archived
Headers show
Series clk: imx: scu: Fix pm_runtime_get_sync() error checking | expand

Commit Message

Miaoqian Lin April 12, 2022, 6:57 a.m. UTC
If the device is already in a runtime PM enabled state
pm_runtime_get_sync() will return 1, so a test for negative
value should be used to check for errors.

Fixes: 78edeb080330 ("clk: imx: scu: add runtime pm support")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 drivers/clk/imx/clk-scu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Abel Vesa April 18, 2022, 11:54 a.m. UTC | #1
On 22-04-12 06:57:18, Miaoqian Lin wrote:
> If the device is already in a runtime PM enabled state
> pm_runtime_get_sync() will return 1, so a test for negative
> value should be used to check for errors.
>
> Fixes: 78edeb080330 ("clk: imx: scu: add runtime pm support")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>

Reviewed-by: Abel Vesa <abel.vesa@nxp.com>

> ---
>  drivers/clk/imx/clk-scu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/clk/imx/clk-scu.c b/drivers/clk/imx/clk-scu.c
> index 083da31dc3ea..18c6190eeffd 100644
> --- a/drivers/clk/imx/clk-scu.c
> +++ b/drivers/clk/imx/clk-scu.c
> @@ -529,7 +529,7 @@ static int imx_clk_scu_probe(struct platform_device *pdev)
>  		pm_runtime_enable(dev);
>
>  		ret = pm_runtime_get_sync(dev);
> -		if (ret) {
> +		if (ret < 0) {
>  			pm_genpd_remove_device(dev);
>  			pm_runtime_disable(dev);
>  			return ret;
> --
> 2.17.1
>
Stephen Boyd April 22, 2022, 1:20 a.m. UTC | #2
Quoting Miaoqian Lin (2022-04-11 23:57:18)
> If the device is already in a runtime PM enabled state
> pm_runtime_get_sync() will return 1, so a test for negative
> value should be used to check for errors.

Maybe it should use pm_runtime_resume_and_get() instead?

> 
> Fixes: 78edeb080330 ("clk: imx: scu: add runtime pm support")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
> ---
>  drivers/clk/imx/clk-scu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/clk/imx/clk-scu.c b/drivers/clk/imx/clk-scu.c
> index 083da31dc3ea..18c6190eeffd 100644
> --- a/drivers/clk/imx/clk-scu.c
> +++ b/drivers/clk/imx/clk-scu.c
> @@ -529,7 +529,7 @@ static int imx_clk_scu_probe(struct platform_device *pdev)
>                 pm_runtime_enable(dev);
>  
>                 ret = pm_runtime_get_sync(dev);
> -               if (ret) {
> +               if (ret < 0) {
>                         pm_genpd_remove_device(dev);
>                         pm_runtime_disable(dev);
>                         return ret;
> -- 
> 2.17.1
>
Miaoqian Lin April 22, 2022, 1:32 a.m. UTC | #3
On 2022/4/22 9:20, Stephen Boyd wrote:
> Quoting Miaoqian Lin (2022-04-11 23:57:18)
>> If the device is already in a runtime PM enabled state
>> pm_runtime_get_sync() will return 1, so a test for negative
>> value should be used to check for errors.
> Maybe it should use pm_runtime_resume_and_get() instead?
Fair enough,I will send patch v2.
>> Fixes: 78edeb080330 ("clk: imx: scu: add runtime pm support")
>> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
>> ---
>>  drivers/clk/imx/clk-scu.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/clk/imx/clk-scu.c b/drivers/clk/imx/clk-scu.c
>> index 083da31dc3ea..18c6190eeffd 100644
>> --- a/drivers/clk/imx/clk-scu.c
>> +++ b/drivers/clk/imx/clk-scu.c
>> @@ -529,7 +529,7 @@ static int imx_clk_scu_probe(struct platform_device *pdev)
>>                 pm_runtime_enable(dev);
>>  
>>                 ret = pm_runtime_get_sync(dev);
>> -               if (ret) {
>> +               if (ret < 0) {
>>                         pm_genpd_remove_device(dev);
>>                         pm_runtime_disable(dev);
>>                         return ret;
>> -- 
>> 2.17.1
>>
diff mbox series

Patch

diff --git a/drivers/clk/imx/clk-scu.c b/drivers/clk/imx/clk-scu.c
index 083da31dc3ea..18c6190eeffd 100644
--- a/drivers/clk/imx/clk-scu.c
+++ b/drivers/clk/imx/clk-scu.c
@@ -529,7 +529,7 @@  static int imx_clk_scu_probe(struct platform_device *pdev)
 		pm_runtime_enable(dev);
 
 		ret = pm_runtime_get_sync(dev);
-		if (ret) {
+		if (ret < 0) {
 			pm_genpd_remove_device(dev);
 			pm_runtime_disable(dev);
 			return ret;