Lines Matching refs:kref
23 struct kref { struct
31 static inline void kref_init(struct kref *kref) in kref_init() argument
33 atomic_set(&kref->refcount, 1); in kref_init()
40 static inline void kref_get(struct kref *kref) in kref_get() argument
46 WARN_ON_ONCE(atomic_inc_return(&kref->refcount) < 2); in kref_get()
67 static inline int kref_sub(struct kref *kref, unsigned int count, in kref_sub() argument
68 void (*release)(struct kref *kref)) in kref_sub() argument
72 if (atomic_sub_and_test((int) count, &kref->refcount)) { in kref_sub()
73 release(kref); in kref_sub()
96 static inline int kref_put(struct kref *kref, void (*release)(struct kref *kref)) in kref_put() argument
98 return kref_sub(kref, 1, release); in kref_put()
101 static inline int kref_put_mutex(struct kref *kref, in kref_put_mutex() argument
102 void (*release)(struct kref *kref), in kref_put_mutex() argument
106 if (unlikely(!atomic_add_unless(&kref->refcount, -1, 1))) { in kref_put_mutex()
108 if (unlikely(!atomic_dec_and_test(&kref->refcount))) { in kref_put_mutex()
112 release(kref); in kref_put_mutex()
134 static inline int __must_check kref_get_unless_zero(struct kref *kref) in kref_get_unless_zero() argument
136 return atomic_add_unless(&kref->refcount, 1, 0); in kref_get_unless_zero()