Lines Matching defs: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.
58 * function returns 0, you still can not count on the kref from remaining in
59 * memory. Only use the return value if you want to see if the kref is now
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);
71 static inline int kref_put_mutex(struct kref *kref,
72 void (*release)(struct kref *kref),
75 if (refcount_dec_and_mutex_lock(&kref->refcount, lock)) {
76 release(kref);
82 static inline int kref_put_lock(struct kref *kref,
83 void (*release)(struct kref *kref),
86 if (refcount_dec_and_lock(&kref->refcount, lock)) {
87 release(kref);
95 * @kref: object.
109 static inline int __must_check kref_get_unless_zero(struct kref *kref)
111 return refcount_inc_not_zero(&kref->refcount);