summaryrefslogtreecommitdiff
path: root/include/linux/lockref.h
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2025-12-09 09:18:57 +0100
committerLinus Torvalds <torvalds@linux-foundation.org>2025-12-10 05:58:51 +0900
commit12eef14bcbac77bd08dc5693ad5818e69993246f (patch)
tree25e0c32e5e299bdd4bb5019c390deeb8ac47f07f /include/linux/lockref.h
parentc752c21c90b808a059ae8e0070ff7566a65f8577 (diff)
lockref: add a __cond_lock annotation for lockref_put_or_lock
Add a cond_lock annotation for lockref_put_or_lock to make sparse happy with using it. Note that for this the return value has to be double-inverted as the return value convention of lockref_put_or_lock is inverted compared to _trylock conventions expected by __cond_lock, as lockref_put_or_lock returns true when it did not need to take the lock. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/lockref.h')
-rw-r--r--include/linux/lockref.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/include/linux/lockref.h b/include/linux/lockref.h
index 676721ee878d..815d871fadfc 100644
--- a/include/linux/lockref.h
+++ b/include/linux/lockref.h
@@ -50,6 +50,8 @@ void lockref_get(struct lockref *lockref);
int lockref_put_return(struct lockref *lockref);
bool lockref_get_not_zero(struct lockref *lockref);
bool lockref_put_or_lock(struct lockref *lockref);
+#define lockref_put_or_lock(_lockref) \
+ (!__cond_lock((_lockref)->lock, !lockref_put_or_lock(_lockref)))
void lockref_mark_dead(struct lockref *lockref);
bool lockref_get_not_dead(struct lockref *lockref);