Lines Matching refs:kref
3 * kref.h - library routines for handling generic reference counted objects
19 struct kref {
27 * @kref: object in question.
29 static inline void kref_init(struct kref *kref)
31 refcount_set(&kref->refcount, 1);
34 static inline unsigned int kref_read(const struct kref *kref)
36 return refcount_read(&kref->refcount);
41 * @kref: object.
43 static inline void kref_get(struct kref *kref)
45 refcount_inc(&kref->refcount);
50 * @kref: Object
62 static inline int kref_put(struct kref *kref, void (*release)(struct kref *kref))
64 if (refcount_dec_and_test(&kref->refcount)) {
65 release(kref);
73 * @kref: Object
81 static inline int kref_put_mutex(struct kref *kref,
82 void (*release)(struct kref *kref),
85 if (refcount_dec_and_mutex_lock(&kref->refcount, mutex)) {
86 release(kref);
94 * @kref: Object
102 static inline int kref_put_lock(struct kref *kref,
103 void (*release)(struct kref *kref),
106 if (refcount_dec_and_lock(&kref->refcount, lock)) {
107 release(kref);
115 * @kref: object.
129 static inline int __must_check kref_get_unless_zero(struct kref *kref)
131 return refcount_inc_not_zero(&kref->refcount);