Skip to content

Commit

Permalink
watchdog: starfive: Check pm_runtime_enabled() before decrementing us…
Browse files Browse the repository at this point in the history
…age counter

[ Upstream commit 8bc22a2f1bf0f402029087fcb53130233a544fed ]

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: db728ea ("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>
Link: https://lore.kernel.org/r/20240119082722.1133024-1-jisheng.teoh@starfivetech.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
JiShengTeoh authored and Sasha Levin committed Mar 26, 2024
1 parent 712e89d commit 6d20a6b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions drivers/watchdog/starfive-wdt.c
Expand Up @@ -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;

Expand Down

0 comments on commit 6d20a6b

Please sign in to comment.