All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heiner Kallweit <hkallweit1@gmail.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Linux PM <linux-pm@vger.kernel.org>
Subject: [PATCH] PM: runtime: Annotate pm_runtime_resume_and_get() as __must_check
Date: Thu, 23 Dec 2021 08:21:41 +0100	[thread overview]
Message-ID: <174f49e0-628d-f5e4-2f99-874524fb9f5e@gmail.com> (raw)

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;
 
-- 
2.34.1


             reply	other threads:[~2021-12-23  7:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-23  7:21 Heiner Kallweit [this message]
2021-12-30 15:34 ` [PATCH] PM: runtime: Annotate pm_runtime_resume_and_get() as __must_check Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=174f49e0-628d-f5e4-2f99-874524fb9f5e@gmail.com \
    --to=hkallweit1@gmail.com \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.