diff mbox series

[v1,3/6] pwm: tegra: Use devm function for pm_runtime_enable()

Message ID a7b7386ee7705b25cc1cd345c188e14978ab2e9d.1784030076.git.ukleinek@kernel.org
State Handled Elsewhere
Headers show
Series pwm: tegra: Cleanups and .get_state() | expand

Commit Message

Uwe Kleine-König July 14, 2026, 12:02 p.m. UTC
This simplifies the error paths as pwm_runtime_disable() is called
automatatically by the driver core.

Note that pwm_runtime_disable() is the right function to undo
pm_runtime_enable(); pm_runtime_force_suspend() "should only be used
during system-wide PM transitions to sleep states".

Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
---
 drivers/pwm/pwm-tegra.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Mikko Perttunen July 15, 2026, 4:31 a.m. UTC | #1
On Tuesday, July 14, 2026 9:02 PM Uwe Kleine-König wrote:
> This simplifies the error paths as pwm_runtime_disable() is called
> automatatically by the driver core.

Typo, s/ta//

> 
> Note that pwm_runtime_disable() is the right function to undo
> pm_runtime_enable(); pm_runtime_force_suspend() "should only be used
> during system-wide PM transitions to sleep states".
> 
> Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
> ---
>  drivers/pwm/pwm-tegra.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/pwm/pwm-tegra.c b/drivers/pwm/pwm-tegra.c
> index dba9a05675e3..e99e1c5b18c3 100644
> --- a/drivers/pwm/pwm-tegra.c
> +++ b/drivers/pwm/pwm-tegra.c
> @@ -361,7 +361,10 @@ static int tegra_pwm_probe(struct platform_device *pdev)
>  		 */
>  		return ret;
>  
> -	pm_runtime_enable(dev);
> +	ret = devm_pm_runtime_enable(dev);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "Failed to enable runtime PM\n");
> +
>  	ret = pm_runtime_resume_and_get(dev);
>  	if (ret)
>  		return dev_err_probe(dev, ret, "Failed to runtime resume device\n");
> @@ -410,7 +413,6 @@ static int tegra_pwm_probe(struct platform_device *pdev)
>  	return 0;
>  put_pm:
>  	pm_runtime_put_sync_suspend(dev);
> -	pm_runtime_force_suspend(dev);
>  	return ret;
>  }
>  
> @@ -422,8 +424,6 @@ static void tegra_pwm_remove(struct platform_device *pdev)
>  	pwmchip_remove(chip);
>  
>  	reset_control_assert(pc->rst);
> -
> -	pm_runtime_force_suspend(&pdev->dev);

I'm guessing the pm_runtime_force_suspend was there to runtime_suspend
the device if it was on. I agree that pm_runtime_force_suspend is not
the right way to do that, but some replacement would be needed.

Thank you
Mikko

>  }
>  
>  static int __maybe_unused tegra_pwm_runtime_suspend(struct device *dev)
> -- 
> 2.55.0.11.g153666a7d9bb
> 
>
diff mbox series

Patch

diff --git a/drivers/pwm/pwm-tegra.c b/drivers/pwm/pwm-tegra.c
index dba9a05675e3..e99e1c5b18c3 100644
--- a/drivers/pwm/pwm-tegra.c
+++ b/drivers/pwm/pwm-tegra.c
@@ -361,7 +361,10 @@  static int tegra_pwm_probe(struct platform_device *pdev)
 		 */
 		return ret;
 
-	pm_runtime_enable(dev);
+	ret = devm_pm_runtime_enable(dev);
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to enable runtime PM\n");
+
 	ret = pm_runtime_resume_and_get(dev);
 	if (ret)
 		return dev_err_probe(dev, ret, "Failed to runtime resume device\n");
@@ -410,7 +413,6 @@  static int tegra_pwm_probe(struct platform_device *pdev)
 	return 0;
 put_pm:
 	pm_runtime_put_sync_suspend(dev);
-	pm_runtime_force_suspend(dev);
 	return ret;
 }
 
@@ -422,8 +424,6 @@  static void tegra_pwm_remove(struct platform_device *pdev)
 	pwmchip_remove(chip);
 
 	reset_control_assert(pc->rst);
-
-	pm_runtime_force_suspend(&pdev->dev);
 }
 
 static int __maybe_unused tegra_pwm_runtime_suspend(struct device *dev)