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.
Showing the changes to include/linux (1 of 2 files). Show all
Unified · Split
| @@ -50,6 +50,8 @@ void lockref_get(struct lockref *lockref); · 49 unmodified lines | |||
| 50 | int lockref_put_return(struct lockref *lockref); | 50 | int lockref_put_return(struct lockref *lockref); |
| 51 | bool lockref_get_not_zero(struct lockref *lockref); | 51 | bool lockref_get_not_zero(struct lockref *lockref); |
| 52 | bool lockref_put_or_lock(struct lockref *lockref); | 52 | bool lockref_put_or_lock(struct lockref *lockref); |
| 53 | #define lockref_put_or_lock(_lockref) \ | ||
| 54 | (!__cond_lock((_lockref)->lock, !lockref_put_or_lock(_lockref))) | ||
| 53 | 55 | ||
| 54 | void lockref_mark_dead(struct lockref *lockref); | 56 | void lockref_mark_dead(struct lockref *lockref); |
| 55 | bool lockref_get_not_dead(struct lockref *lockref); | 57 | bool lockref_get_not_dead(struct lockref *lockref); |