Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 230604
b: refs/heads/master
c: e4a683c
h: refs/heads/master
v: v3
  • Loading branch information
Jerome Marchand authored and Jens Axboe committed Jan 5, 2011
1 parent c2cd27a commit 83ea468
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a6e8dc46ff0b7defbfa4f29a71aee263377ec573
refs/heads/master: e4a683c899cd5a49f8d684a054c95bd115a0c005
1 change: 1 addition & 0 deletions trunk/include/linux/kref.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct kref {

void kref_init(struct kref *kref);
void kref_get(struct kref *kref);
int kref_test_and_get(struct kref *kref);
int kref_put(struct kref *kref, void (*release) (struct kref *kref));

#endif /* _KREF_H_ */
12 changes: 12 additions & 0 deletions trunk/lib/kref.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ void kref_get(struct kref *kref)
smp_mb__after_atomic_inc();
}

/**
* kref_test_and_get - increment refcount for object only if refcount is not
* zero.
* @kref: object.
*
* Return non-zero if the refcount was incremented, 0 otherwise
*/
int kref_test_and_get(struct kref *kref)
{
return atomic_inc_not_zero(&kref->refcount);
}

/**
* kref_put - decrement refcount for object.
* @kref: object.
Expand Down

0 comments on commit 83ea468

Please sign in to comment.