diff mbox series

[1/2] PM: runtime: Define pm_runtime_put cleanup helper

Message ID 20250422230534.2295291-2-alex.williamson@redhat.com
State New
Headers show
Series PCI/PM: Elevate PM usage during reset probing | expand

Commit Message

Alex Williamson April 22, 2025, 11:05 p.m. UTC
Define a cleanup helper for use with __free to automatically drop the
device usage count when out of scope.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
 include/linux/pm_runtime.h | 2 ++
 1 file changed, 2 insertions(+)

Comments

Rafael J. Wysocki April 23, 2025, 12:21 p.m. UTC | #1
On Wed, Apr 23, 2025 at 1:05 AM Alex Williamson
<alex.williamson@redhat.com> wrote:
>
> Define a cleanup helper for use with __free to automatically drop the
> device usage count when out of scope.
>
> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>

Acked-by: Rafael J. Wysocki <rafael@kernel.org>

> ---
>  include/linux/pm_runtime.h | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
> index 7fb5a459847e..69d4b2929ee6 100644
> --- a/include/linux/pm_runtime.h
> +++ b/include/linux/pm_runtime.h
> @@ -466,6 +466,8 @@ static inline int pm_runtime_put(struct device *dev)
>         return __pm_runtime_idle(dev, RPM_GET_PUT | RPM_ASYNC);
>  }
>
> +DEFINE_FREE(pm_runtime_put, struct device *, if (_T) pm_runtime_put(_T))
> +
>  /**
>   * __pm_runtime_put_autosuspend - Drop device usage counter and queue autosuspend if 0.
>   * @dev: Target device.
> --
> 2.48.1
>
diff mbox series

Patch

diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
index 7fb5a459847e..69d4b2929ee6 100644
--- a/include/linux/pm_runtime.h
+++ b/include/linux/pm_runtime.h
@@ -466,6 +466,8 @@  static inline int pm_runtime_put(struct device *dev)
 	return __pm_runtime_idle(dev, RPM_GET_PUT | RPM_ASYNC);
 }
 
+DEFINE_FREE(pm_runtime_put, struct device *, if (_T) pm_runtime_put(_T))
+
 /**
  * __pm_runtime_put_autosuspend - Drop device usage counter and queue autosuspend if 0.
  * @dev: Target device.