Lines Matching defs:lockref

3 #include <linux/lockref.h>
13 struct lockref old; \
15 old.lock_count = READ_ONCE(lockref->lock_count); \
17 struct lockref new = old, prev = old; \
19 old.lock_count = cmpxchg64_relaxed(&lockref->lock_count, \
38 * @lockref: pointer to lockref structure
43 void lockref_get(struct lockref *lockref)
51 spin_lock(&lockref->lock);
52 lockref->count++;
53 spin_unlock(&lockref->lock);
59 * @lockref: pointer to lockref structure
62 int lockref_get_not_zero(struct lockref *lockref)
74 spin_lock(&lockref->lock);
76 if (lockref->count > 0) {
77 lockref->count++;
80 spin_unlock(&lockref->lock);
87 * @lockref: pointer to lockref structure
90 int lockref_put_not_zero(struct lockref *lockref)
102 spin_lock(&lockref->lock);
104 if (lockref->count > 1) {
105 lockref->count--;
108 spin_unlock(&lockref->lock);
115 * @lockref: pointer to lockref structure
119 int lockref_get_or_lock(struct lockref *lockref)
129 spin_lock(&lockref->lock);
130 if (lockref->count <= 0)
132 lockref->count++;
133 spin_unlock(&lockref->lock);
140 * @lockref: pointer to lockref structure
143 * If the lockref was dead or locked, return an error.
145 int lockref_put_return(struct lockref *lockref)
160 * @lockref: pointer to lockref structure
163 int lockref_put_or_lock(struct lockref *lockref)
173 spin_lock(&lockref->lock);
174 if (lockref->count <= 1)
176 lockref->count--;
177 spin_unlock(&lockref->lock);
183 * lockref_mark_dead - mark lockref dead
184 * @lockref: pointer to lockref structure
186 void lockref_mark_dead(struct lockref *lockref)
188 assert_spin_locked(&lockref->lock);
189 lockref->count = -128;
195 * @lockref: pointer to lockref structure
196 * Return: 1 if count updated successfully or 0 if lockref was dead
198 int lockref_get_not_dead(struct lockref *lockref)
210 spin_lock(&lockref->lock);
212 if (lockref->count >= 0) {
213 lockref->count++;
216 spin_unlock(&lockref->lock);