Re: [PATCH v1] PM: runtime: Fix conditional guard definitions

From: Dhruva Gole

Date: Mon Oct 27 2025 - 01:15:25 EST


On Oct 20, 2025 at 17:03:28 +0200, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
>
> Since pm_runtime_get_active() returns 0 on success, all of the
> DEFINE_GUARD_COND() macros in pm_runtime.h need the "_RET == 0"
> condition at the end of the argument list or they would not work
> correctly.
>
> Fixes: 9a0abc39450a ("PM: runtime: Add auto-cleanup macros for "resume and get" operations")
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
> Link: https://lore.kernel.org/linux-pm/202510191529.BCyjKlLQ-lkp@xxxxxxxxx/
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
> ---
> include/linux/pm_runtime.h | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> --- a/include/linux/pm_runtime.h
> +++ b/include/linux/pm_runtime.h
> @@ -629,13 +629,13 @@ DEFINE_GUARD(pm_runtime_active_auto, str
> * device.
> */
> DEFINE_GUARD_COND(pm_runtime_active, _try,
> - pm_runtime_get_active(_T, RPM_TRANSPARENT))
> + pm_runtime_get_active(_T, RPM_TRANSPARENT), _RET == 0)
> DEFINE_GUARD_COND(pm_runtime_active, _try_enabled,
> - pm_runtime_resume_and_get(_T))
> + pm_runtime_resume_and_get(_T), _RET == 0)
> DEFINE_GUARD_COND(pm_runtime_active_auto, _try,
> - pm_runtime_get_active(_T, RPM_TRANSPARENT))
> + pm_runtime_get_active(_T, RPM_TRANSPARENT), _RET == 0)
> DEFINE_GUARD_COND(pm_runtime_active_auto, _try_enabled,
> - pm_runtime_resume_and_get(_T))
> + pm_runtime_resume_and_get(_T), _RET == 0)

The 3-argument form automatically assumes success, so we were
essentially ignoring RET val. This seems correct now.

Reviewed-by: Dhruva Gole <d-gole@xxxxxx>

Best regards,
Dhruva Gole
Texas Instruments Incorporated