diff mbox series

PM: runtime: Annotate pm_runtime_resume_and_get() as __must_check

Message ID 174f49e0-628d-f5e4-2f99-874524fb9f5e@gmail.com
State New
Headers show
Series PM: runtime: Annotate pm_runtime_resume_and_get() as __must_check | expand

Commit Message

Heiner Kallweit Dec. 23, 2021, 7:21 a.m. UTC
In the error case this function returns w/o the usage counter being
incremented. Not checking the return code will likely result in a
usage counter imbalance in the error case therefore.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 include/linux/pm_runtime.h | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Rafael J. Wysocki Dec. 30, 2021, 3:34 p.m. UTC | #1
On Thu, Dec 23, 2021 at 8:21 AM Heiner Kallweit <hkallweit1@gmail.com> wrote:
>
> In the error case this function returns w/o the usage counter being
> incremented. Not checking the return code will likely result in a
> usage counter imbalance in the error case therefore.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
>  include/linux/pm_runtime.h | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
> index eddd66d42..aa106f5fb 100644
> --- a/include/linux/pm_runtime.h
> +++ b/include/linux/pm_runtime.h
> @@ -384,9 +384,8 @@ static inline int pm_runtime_get(struct device *dev)
>   * The possible return values of this function are the same as for
>   * pm_runtime_resume() and the runtime PM usage counter of @dev remains
>   * incremented in all cases, even if it returns an error code.
> - * Consider using pm_runtime_resume_and_get() instead of it, especially
> - * if its return value is checked by the caller, as this is likely to result
> - * in cleaner code.
> + * Consider using pm_runtime_resume_and_get() instead of it if its return
> + * value is checked by the caller, as this is likely to result in cleaner code.
>   */
>  static inline int pm_runtime_get_sync(struct device *dev)
>  {
> @@ -401,7 +400,7 @@ static inline int pm_runtime_get_sync(struct device *dev)
>   * PM usage counter. Return 0 if the runtime PM usage counter of @dev has been
>   * incremented or a negative error code otherwise.
>   */
> -static inline int pm_runtime_resume_and_get(struct device *dev)
> +static inline __must_check int pm_runtime_resume_and_get(struct device *dev)
>  {
>         int ret;
>
> --

Applied as 5.17 material, thanks!
diff mbox series

Patch

diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
index eddd66d42..aa106f5fb 100644
--- a/include/linux/pm_runtime.h
+++ b/include/linux/pm_runtime.h
@@ -384,9 +384,8 @@  static inline int pm_runtime_get(struct device *dev)
  * The possible return values of this function are the same as for
  * pm_runtime_resume() and the runtime PM usage counter of @dev remains
  * incremented in all cases, even if it returns an error code.
- * Consider using pm_runtime_resume_and_get() instead of it, especially
- * if its return value is checked by the caller, as this is likely to result
- * in cleaner code.
+ * Consider using pm_runtime_resume_and_get() instead of it if its return
+ * value is checked by the caller, as this is likely to result in cleaner code.
  */
 static inline int pm_runtime_get_sync(struct device *dev)
 {
@@ -401,7 +400,7 @@  static inline int pm_runtime_get_sync(struct device *dev)
  * PM usage counter. Return 0 if the runtime PM usage counter of @dev has been
  * incremented or a negative error code otherwise.
  */
-static inline int pm_runtime_resume_and_get(struct device *dev)
+static inline __must_check int pm_runtime_resume_and_get(struct device *dev)
 {
 	int ret;