[PATCH v6 09/13] gpio: mxc: use cleanup guard for pm_runtime_get_noresume() balance

Andy Shevchenko andy.shevchenko at gmail.com
Mon Oct 12 02:38:37 PDT 2026


On Sun, Oct 11, 2026 at 2:54 PM Peng Fan (OSS) <peng.fan at oss.nxp.com> wrote:
>
> pm_runtime_get_noresume() in probe must be balanced by
> pm_runtime_put_noidle() on error paths, or pm_runtime_put_autosuspend()
> on success. devm_pm_runtime_get_noresume() cannot be used here because
> its devres action (pm_runtime_put_noidle()) would fire on unbind in
> addition to the success-path pm_runtime_put_autosuspend(), causing a
> usage counter underflow.
>
> Use a __free guard to automatically call pm_runtime_put_noidle() on
> error paths, and disarm it with no_free_ptr() before the success-path
> pm_runtime_put_autosuspend().

...

> +DEFINE_FREE(pm_runtime_put_noidle, struct device *, if (_T) pm_runtime_put_noidle(_T))

Please, split this to a separate patch and move it directly to pm_runtime.h.

-- 
With Best Regards,
Andy Shevchenko



More information about the linux-arm-kernel mailing list