X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Fkref.c;h=9ecd6e86561034f2a097bcc027765704e124f7df;hb=765426e8ee4c0ab2bc9d44951f4865b8494cdbd0;hp=0d07cc31c818108a5d9e3bc26444957108bad721;hpb=274ec7a8c07036bd02e8f2301456e443ef30b8a8;p=linux-2.6-omap-h63xx.git diff --git a/lib/kref.c b/lib/kref.c index 0d07cc31c81..9ecd6e86561 100644 --- a/lib/kref.c +++ b/lib/kref.c @@ -14,13 +14,24 @@ #include #include +/** + * kref_set - initialize object and set refcount to requested number. + * @kref: object in question. + * @num: initial reference counter + */ +void kref_set(struct kref *kref, int num) +{ + atomic_set(&kref->refcount, num); + smp_mb(); +} + /** * kref_init - initialize object. * @kref: object in question. */ void kref_init(struct kref *kref) { - atomic_set(&kref->refcount,1); + kref_set(kref, 1); } /** @@ -31,6 +42,7 @@ void kref_get(struct kref *kref) { WARN_ON(!atomic_read(&kref->refcount)); atomic_inc(&kref->refcount); + smp_mb__after_atomic_inc(); } /** @@ -59,6 +71,7 @@ int kref_put(struct kref *kref, void (*release)(struct kref *kref)) return 0; } +EXPORT_SYMBOL(kref_set); EXPORT_SYMBOL(kref_init); EXPORT_SYMBOL(kref_get); EXPORT_SYMBOL(kref_put);