Skip to contentSkip to conversation

PM: runtime: Annotate pm_runtime_resume_and_get() as __must_check

PATCH Applied Heiner Kallweit 2 participants 2 messages Dec 23, 2021 – Dec 30, 2021 Power management core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PM: runtime: Annotate pm_runtime_resume_and_get() as __must_check

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.

---
 include/linux/pm_runtime.h | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
include/linux/pm_runtime.h +3 -4
index eddd66d42..aa106f5fb 100644
@@ -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;
 
Signature · 1 line
2.34.1
maintainer Applied
#1 lore raw
Quoted 27 lines · Heiner Kallweit

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.

---
 include/linux/pm_runtime.h | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
include/linux/pm_runtime.h +2 -3
index eddd66d42..aa106f5fb 100644
@@ -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)
 {

include/linux/pm_runtime.h static inline int pm_runtime_get_sync(struct device *dev)

Quoted 9 lines
include/linux/pm_runtime.h +1 -2
@@ -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!