Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Robert P. J. Day | 932fb06 | 2010-03-13 07:58:13 -0500 | [diff] [blame] | 2 | * kref.h - library routines for handling generic reference counted objects |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2004 Greg Kroah-Hartman <greg@kroah.com> |
| 5 | * Copyright (C) 2004 IBM Corp. |
| 6 | * |
| 7 | * based on kobject.h which was: |
| 8 | * Copyright (C) 2002-2003 Patrick Mochel <mochel@osdl.org> |
| 9 | * Copyright (C) 2002-2003 Open Source Development Labs |
| 10 | * |
| 11 | * This file is released under the GPLv2. |
| 12 | * |
| 13 | */ |
| 14 | |
| 15 | #ifndef _KREF_H_ |
| 16 | #define _KREF_H_ |
| 17 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <linux/types.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
| 20 | struct kref { |
| 21 | atomic_t refcount; |
| 22 | }; |
| 23 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | void kref_init(struct kref *kref); |
| 25 | void kref_get(struct kref *kref); |
| 26 | int kref_put(struct kref *kref, void (*release) (struct kref *kref)); |
Thomas Hellstrom | ecf7ace | 2010-11-16 15:21:07 +0100 | [diff] [blame] | 27 | int kref_sub(struct kref *kref, unsigned int count, |
| 28 | void (*release) (struct kref *kref)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | #endif /* _KREF_H_ */ |