Lines Matching refs:kref
24 struct kref { struct
32 static inline void kref_init(struct kref *kref) in kref_init() argument
34 atomic_set(&kref->refcount, 1); in kref_init()
41 static inline void kref_get(struct kref *kref) in kref_get() argument
47 WARN_ON_ONCE(atomic_inc_return(&kref->refcount) < 2); in kref_get()
68 static inline int kref_sub(struct kref *kref, unsigned int count, in kref_sub() argument
69 void (*release)(struct kref *kref)) in kref_sub() argument
73 if (atomic_sub_and_test((int) count, &kref->refcount)) { in kref_sub()
74 release(kref); in kref_sub()
97 static inline int kref_put(struct kref *kref, void (*release)(struct kref *kref)) in kref_put() argument
99 return kref_sub(kref, 1, release); in kref_put()
115 static inline int kref_put_spinlock_irqsave(struct kref *kref, in kref_put_spinlock_irqsave() argument
116 void (*release)(struct kref *kref), in kref_put_spinlock_irqsave() argument
122 if (atomic_add_unless(&kref->refcount, -1, 1)) in kref_put_spinlock_irqsave()
125 if (atomic_dec_and_test(&kref->refcount)) { in kref_put_spinlock_irqsave()
126 release(kref); in kref_put_spinlock_irqsave()
134 static inline int kref_put_mutex(struct kref *kref, in kref_put_mutex() argument
135 void (*release)(struct kref *kref), in kref_put_mutex() argument
139 if (unlikely(!atomic_add_unless(&kref->refcount, -1, 1))) { in kref_put_mutex()
141 if (unlikely(!atomic_dec_and_test(&kref->refcount))) { in kref_put_mutex()
145 release(kref); in kref_put_mutex()
167 static inline int __must_check kref_get_unless_zero(struct kref *kref) in kref_get_unless_zero() argument
169 return atomic_add_unless(&kref->refcount, 1, 0); in kref_get_unless_zero()