Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 280066
b: refs/heads/master
c: 6261dde
h: refs/heads/master
v: v3
  • Loading branch information
Greg Kroah-Hartman committed Dec 14, 2011
1 parent 8ecfcea commit f1a1da9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3c8ed88974472b928489e3943616500ce2ad0cd8
refs/heads/master: 6261ddee70174372d6a75601f40719b7a5392f3f
15 changes: 10 additions & 5 deletions trunk/include/linux/kref.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#ifndef _KREF_H_
#define _KREF_H_

#include <linux/types.h>
#include <linux/slab.h>
#include <linux/bug.h>
#include <linux/atomic.h>

struct kref {
atomic_t refcount;
Expand Down Expand Up @@ -48,7 +48,10 @@ static inline void kref_get(struct kref *kref)
* @release: pointer to the function that will clean up the object when the
* last reference to the object is released.
* This pointer is required, and it is not acceptable to pass kfree
* in as this function.
* in as this function. If the caller does pass kfree to this
* function, you will be publicly mocked mercilessly by the kref
* maintainer, and anyone else who happens to notice it. You have
* been warned.
*
* Subtract @count from the refcount, and if 0, call release().
* Return 1 if the object was removed, otherwise return 0. Beware, if this
Expand All @@ -60,7 +63,6 @@ static inline int kref_sub(struct kref *kref, unsigned int count,
void (*release)(struct kref *kref))
{
WARN_ON(release == NULL);
WARN_ON(release == (void (*)(struct kref *))kfree);

if (atomic_sub_and_test((int) count, &kref->refcount)) {
release(kref);
Expand All @@ -75,7 +77,10 @@ static inline int kref_sub(struct kref *kref, unsigned int count,
* @release: pointer to the function that will clean up the object when the
* last reference to the object is released.
* This pointer is required, and it is not acceptable to pass kfree
* in as this function.
* in as this function. If the caller does pass kfree to this
* function, you will be publicly mocked mercilessly by the kref
* maintainer, and anyone else who happens to notice it. You have
* been warned.
*
* Decrement the refcount, and if 0, call release().
* Return 1 if the object was removed, otherwise return 0. Beware, if this
Expand Down

0 comments on commit f1a1da9

Please sign in to comment.