mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] watchdog: starfive: Check pm_runtime_enabled() before decrementing usage counter
@ 2024-01-19  8:27 Ji Sheng Teoh
  2024-01-19 12:53 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Ji Sheng Teoh @ 2024-01-19  8:27 UTC (permalink / raw)
  To: Xingyu Wu, Samin Guo, Wim Van Sebroeck, Guenter Roeck,
	Emil Renner Berthing
  Cc: Ley Foon Tan, linux-watchdog, linux-kernel

In the probe function, pm_runtime_put_sync() will fail on platform with
runtime PM disabled.
Check if runtime PM is enabled before calling pm_runtime_put_sync() to
fix it.

Fixes: db728ea9c7be ("drivers: watchdog: Add StarFive Watchdog driver")
Signed-off-by: Xingyu Wu <xingyu.wu@starfivetech.com>
Signed-off-by: Ley Foon Tan <leyfoon.tan@starfivetech.com>
Signed-off-by: Ji Sheng Teoh <jisheng.teoh@starfivetech.com>
---
 drivers/watchdog/starfive-wdt.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/watchdog/starfive-wdt.c b/drivers/watchdog/starfive-wdt.c
index e28ead24c520..df68ae4acbd7 100644
--- a/drivers/watchdog/starfive-wdt.c
+++ b/drivers/watchdog/starfive-wdt.c
@@ -494,8 +494,13 @@ static int starfive_wdt_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_exit;
 
-	if (!early_enable)
-		pm_runtime_put_sync(&pdev->dev);
+	if (!early_enable) {
+		if (pm_runtime_enabled(&pdev->dev)) {
+			ret = pm_runtime_put_sync(&pdev->dev);
+			if (ret)
+				goto err_exit;
+		}
+	}
 
 	return 0;
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] watchdog: starfive: Check pm_runtime_enabled() before decrementing usage counter
  2024-01-19  8:27 [PATCH] watchdog: starfive: Check pm_runtime_enabled() before decrementing usage counter Ji Sheng Teoh
@ 2024-01-19 12:53 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2024-01-19 12:53 UTC (permalink / raw)
  To: Ji Sheng Teoh, Xingyu Wu, Samin Guo, Wim Van Sebroeck,
	Emil Renner Berthing
  Cc: Ley Foon Tan, linux-watchdog, linux-kernel

On 1/19/24 00:27, Ji Sheng Teoh wrote:
> In the probe function, pm_runtime_put_sync() will fail on platform with
> runtime PM disabled.
> Check if runtime PM is enabled before calling pm_runtime_put_sync() to
> fix it.
> 
> Fixes: db728ea9c7be ("drivers: watchdog: Add StarFive Watchdog driver")
> Signed-off-by: Xingyu Wu <xingyu.wu@starfivetech.com>
> Signed-off-by: Ley Foon Tan <leyfoon.tan@starfivetech.com>
> Signed-off-by: Ji Sheng Teoh <jisheng.teoh@starfivetech.com>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

Guenter

> ---
>   drivers/watchdog/starfive-wdt.c | 9 +++++++--
>   1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/watchdog/starfive-wdt.c b/drivers/watchdog/starfive-wdt.c
> index e28ead24c520..df68ae4acbd7 100644
> --- a/drivers/watchdog/starfive-wdt.c
> +++ b/drivers/watchdog/starfive-wdt.c
> @@ -494,8 +494,13 @@ static int starfive_wdt_probe(struct platform_device *pdev)
>   	if (ret)
>   		goto err_exit;
>   
> -	if (!early_enable)
> -		pm_runtime_put_sync(&pdev->dev);
> +	if (!early_enable) {
> +		if (pm_runtime_enabled(&pdev->dev)) {
> +			ret = pm_runtime_put_sync(&pdev->dev);
> +			if (ret)
> +				goto err_exit;
> +		}
> +	}
>   
>   	return 0;
>   


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-19 12:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-19  8:27 [PATCH] watchdog: starfive: Check pm_runtime_enabled() before decrementing usage counter Ji Sheng Teoh
2024-01-19 12:53 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®