summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-09-02 11:58:20 -0700
committerMaciej Wereski <m.wereski@partner.samsung.com>2015-03-18 09:47:11 +0100
commit8ff51b75dc12ab5c5114311a7002a7e19e642791 (patch)
tree58a543b0ccd27534f395efc6bc24e6aa55004ce7 /include
parentb3416182dae5bc78eaaa516c80057654b2963de7 (diff)
downloadlinux-3.10-8ff51b75dc12ab5c5114311a7002a7e19e642791.tar.gz
linux-3.10-8ff51b75dc12ab5c5114311a7002a7e19e642791.tar.bz2
linux-3.10-8ff51b75dc12ab5c5114311a7002a7e19e642791.zip
lockref: uninline lockref helper functions
They aren't very good to inline, since they already call external functions (the spinlock code), and we're going to create rather more complicated versions of them that can do the reference count updates locklessly. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/lockref.h66
1 files changed, 4 insertions, 62 deletions
diff --git a/include/linux/lockref.h b/include/linux/lockref.h
index 0ea026092d1..4c0af31c8d4 100644
--- a/include/linux/lockref.h
+++ b/include/linux/lockref.h
@@ -21,67 +21,9 @@ struct lockref {
unsigned int count;
};
-/**
- * lockref_get - Increments reference count unconditionally
- * @lockcnt: pointer to lockref structure
- *
- * This operation is only valid if you already hold a reference
- * to the object, so you know the count cannot be zero.
- */
-static inline void lockref_get(struct lockref *lockref)
-{
- spin_lock(&lockref->lock);
- lockref->count++;
- spin_unlock(&lockref->lock);
-}
-
-/**
- * lockref_get_not_zero - Increments count unless the count is 0
- * @lockcnt: pointer to lockref structure
- * Return: 1 if count updated successfully or 0 if count is 0
- */
-static inline int lockref_get_not_zero(struct lockref *lockref)
-{
- int retval = 0;
-
- spin_lock(&lockref->lock);
- if (lockref->count) {
- lockref->count++;
- retval = 1;
- }
- spin_unlock(&lockref->lock);
- return retval;
-}
-
-/**
- * lockref_get_or_lock - Increments count unless the count is 0
- * @lockcnt: pointer to lockref structure
- * Return: 1 if count updated successfully or 0 if count was zero
- * and we got the lock instead.
- */
-static inline int lockref_get_or_lock(struct lockref *lockref)
-{
- spin_lock(&lockref->lock);
- if (!lockref->count)
- return 0;
- lockref->count++;
- spin_unlock(&lockref->lock);
- return 1;
-}
-
-/**
- * lockref_put_or_lock - decrements count unless count <= 1 before decrement
- * @lockcnt: pointer to lockref structure
- * Return: 1 if count updated successfully or 0 if count <= 1 and lock taken
- */
-static inline int lockref_put_or_lock(struct lockref *lockref)
-{
- spin_lock(&lockref->lock);
- if (lockref->count <= 1)
- return 0;
- lockref->count--;
- spin_unlock(&lockref->lock);
- return 1;
-}
+extern void lockref_get(struct lockref *);
+extern int lockref_get_not_zero(struct lockref *);
+extern int lockref_get_or_lock(struct lockref *);
+extern int lockref_put_or_lock(struct lockref *);
#endif /* __LINUX_LOCKREF_H */