diff options
Diffstat (limited to 'arch/sparc')
-rw-r--r-- | arch/sparc/lib/atomic32.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/arch/sparc/lib/atomic32.c b/arch/sparc/lib/atomic32.c index 2e64e8c3e8e5..be46f6545184 100644 --- a/arch/sparc/lib/atomic32.c +++ b/arch/sparc/lib/atomic32.c | |||
@@ -37,17 +37,28 @@ int __atomic_add_return(int i, atomic_t *v) | |||
37 | spin_unlock_irqrestore(ATOMIC_HASH(v), flags); | 37 | spin_unlock_irqrestore(ATOMIC_HASH(v), flags); |
38 | return ret; | 38 | return ret; |
39 | } | 39 | } |
40 | EXPORT_SYMBOL(__atomic_add_return); | ||
40 | 41 | ||
41 | void atomic_set(atomic_t *v, int i) | 42 | int atomic_cmpxchg(atomic_t *v, int old, int new) |
42 | { | 43 | { |
44 | int ret; | ||
43 | unsigned long flags; | 45 | unsigned long flags; |
44 | spin_lock_irqsave(ATOMIC_HASH(v), flags); | ||
45 | 46 | ||
46 | v->counter = i; | 47 | spin_lock_irqsave(ATOMIC_HASH(v), flags); |
48 | ret = v->counter; | ||
49 | if (likely(ret == old)) | ||
50 | v->counter = new; | ||
47 | 51 | ||
48 | spin_unlock_irqrestore(ATOMIC_HASH(v), flags); | 52 | spin_unlock_irqrestore(ATOMIC_HASH(v), flags); |
53 | return ret; | ||
49 | } | 54 | } |
50 | 55 | ||
51 | EXPORT_SYMBOL(__atomic_add_return); | 56 | void atomic_set(atomic_t *v, int i) |
52 | EXPORT_SYMBOL(atomic_set); | 57 | { |
58 | unsigned long flags; | ||
53 | 59 | ||
60 | spin_lock_irqsave(ATOMIC_HASH(v), flags); | ||
61 | v->counter = i; | ||
62 | spin_unlock_irqrestore(ATOMIC_HASH(v), flags); | ||
63 | } | ||
64 | EXPORT_SYMBOL(atomic_set); | ||