diff options
| author | Jeff Garzik <jgarzik@pobox.com> | 2005-09-23 19:03:21 -0400 |
|---|---|---|
| committer | Jeff Garzik <jgarzik@pobox.com> | 2005-09-23 19:03:21 -0400 |
| commit | 536f8098026bde1368bbfcbcb9682a7637b73df2 (patch) | |
| tree | cf83d2e1afa503b6aeba103b55cd1da0af4e7a4c /arch/mips/lib/dec_and_lock.c | |
| parent | e86ee6682b649183c11013a98be02f25e9ae399d (diff) | |
| parent | 3fd07d3bf0077dcc0f5a33d2eb1938ea050da8da (diff) | |
Merge /spare/repo/linux-2.6/
Diffstat (limited to 'arch/mips/lib/dec_and_lock.c')
| -rw-r--r-- | arch/mips/lib/dec_and_lock.c | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/arch/mips/lib/dec_and_lock.c b/arch/mips/lib/dec_and_lock.c deleted file mode 100644 index fd82c84a93b7..000000000000 --- a/arch/mips/lib/dec_and_lock.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * MIPS version of atomic_dec_and_lock() using cmpxchg - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. - */ - -#include <linux/module.h> -#include <linux/spinlock.h> -#include <asm/atomic.h> -#include <asm/system.h> - -/* - * This is an implementation of the notion of "decrement a - * reference count, and return locked if it decremented to zero". - * - * This implementation can be used on any architecture that - * has a cmpxchg, and where atomic->value is an int holding - * the value of the atomic (i.e. the high bits aren't used - * for a lock or anything like that). - */ -int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock) -{ - int counter; - int newcount; - - for (;;) { - counter = atomic_read(atomic); - newcount = counter - 1; - if (!newcount) - break; /* do it the slow way */ - - newcount = cmpxchg(&atomic->counter, counter, newcount); - if (newcount == counter) - return 0; - } - - spin_lock(lock); - if (atomic_dec_and_test(atomic)) - return 1; - spin_unlock(lock); - return 0; -} - -EXPORT_SYMBOL(_atomic_dec_and_lock); |
