aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/kref.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/kref.c b/lib/kref.c
index a6dc3ec328e0..9ecd6e865610 100644
--- a/lib/kref.c
+++ b/lib/kref.c
@@ -15,13 +15,23 @@
15#include <linux/module.h> 15#include <linux/module.h>
16 16
17/** 17/**
18 * kref_set - initialize object and set refcount to requested number.
19 * @kref: object in question.
20 * @num: initial reference counter
21 */
22void kref_set(struct kref *kref, int num)
23{
24 atomic_set(&kref->refcount, num);
25 smp_mb();
26}
27
28/**
18 * kref_init - initialize object. 29 * kref_init - initialize object.
19 * @kref: object in question. 30 * @kref: object in question.
20 */ 31 */
21void kref_init(struct kref *kref) 32void kref_init(struct kref *kref)
22{ 33{
23 atomic_set(&kref->refcount,1); 34 kref_set(kref, 1);
24 smp_mb();
25} 35}
26 36
27/** 37/**
@@ -61,6 +71,7 @@ int kref_put(struct kref *kref, void (*release)(struct kref *kref))
61 return 0; 71 return 0;
62} 72}
63 73
74EXPORT_SYMBOL(kref_set);
64EXPORT_SYMBOL(kref_init); 75EXPORT_SYMBOL(kref_init);
65EXPORT_SYMBOL(kref_get); 76EXPORT_SYMBOL(kref_get);
66EXPORT_SYMBOL(kref_put); 77EXPORT_SYMBOL(kref_put);