diff options
| author | Steve French <sfrench@us.ibm.com> | 2006-03-30 22:35:56 -0500 |
|---|---|---|
| committer | Steve French <sfrench@us.ibm.com> | 2006-03-30 22:35:56 -0500 |
| commit | d62e54abca1146981fc9f98f85ff398a113a22c2 (patch) | |
| tree | 870420dbc4c65e716dcef8a802aafdc0ef97a8b4 /lib/kref.c | |
| parent | fd4a0b92db6a57cba8d03efbe1cebf91f9124ce0 (diff) | |
| parent | ce362c009250340358a7221f3cdb7954cbf19c01 (diff) | |
Merge with /pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'lib/kref.c')
| -rw-r--r-- | lib/kref.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/kref.c b/lib/kref.c index 0d07cc31c818..4a467faf1367 100644 --- a/lib/kref.c +++ b/lib/kref.c | |||
| @@ -52,7 +52,12 @@ int kref_put(struct kref *kref, void (*release)(struct kref *kref)) | |||
| 52 | WARN_ON(release == NULL); | 52 | WARN_ON(release == NULL); |
| 53 | WARN_ON(release == (void (*)(struct kref *))kfree); | 53 | WARN_ON(release == (void (*)(struct kref *))kfree); |
| 54 | 54 | ||
| 55 | if (atomic_dec_and_test(&kref->refcount)) { | 55 | /* |
| 56 | * if current count is one, we are the last user and can release object | ||
| 57 | * right now, avoiding an atomic operation on 'refcount' | ||
| 58 | */ | ||
| 59 | if ((atomic_read(&kref->refcount) == 1) || | ||
| 60 | (atomic_dec_and_test(&kref->refcount))) { | ||
| 56 | release(kref); | 61 | release(kref); |
| 57 | return 1; | 62 | return 1; |
| 58 | } | 63 | } |
