Lines Matching refs:kref
2 * kref.c - library routines for handling generic reference counted objects
14 #include <linux/kref.h>
19 * @kref: object in question.
21 void kref_init(struct kref *kref)
23 atomic_set(&kref->refcount,1);
29 * @kref: object.
31 void kref_get(struct kref *kref)
33 WARN_ON(!atomic_read(&kref->refcount));
34 atomic_inc(&kref->refcount);
40 * @kref: object.
48 * function returns 0, you still can not count on the kref from remaining in
49 * memory. Only use the return value if you want to see if the kref is now
52 int kref_put(struct kref *kref, void (*release)(struct kref *kref))
55 WARN_ON(release == (void (*)(struct kref *))kfree);
57 if (atomic_dec_and_test(&kref->refcount)) {
58 release(kref);