diff options
author | Kyle McMartin <kyle@parisc-linux.org> | 2007-05-29 05:51:13 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2007-05-29 05:51:13 -0400 |
commit | 6197fe4d720ea3e2ee94cdc7ef32d6c0151199de (patch) | |
tree | c521b677a8ca7ab24f12c0e8275a3cbdd00131c0 /arch/sparc/lib | |
parent | 679292993c77c06f7ade4e317c13256b92c2651b (diff) |
[SPARC]: Emulate cmpxchg like parisc
Signed-off-by: Kyle McMartin <kyle@parisc-linux.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc/lib')
-rw-r--r-- | arch/sparc/lib/atomic32.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/arch/sparc/lib/atomic32.c b/arch/sparc/lib/atomic32.c index 559335f4917d..617d29832e19 100644 --- a/arch/sparc/lib/atomic32.c +++ b/arch/sparc/lib/atomic32.c | |||
@@ -2,6 +2,7 @@ | |||
2 | * atomic32.c: 32-bit atomic_t implementation | 2 | * atomic32.c: 32-bit atomic_t implementation |
3 | * | 3 | * |
4 | * Copyright (C) 2004 Keith M Wesolowski | 4 | * Copyright (C) 2004 Keith M Wesolowski |
5 | * Copyright (C) 2007 Kyle McMartin | ||
5 | * | 6 | * |
6 | * Based on asm-parisc/atomic.h Copyright (C) 2000 Philipp Rumpf | 7 | * Based on asm-parisc/atomic.h Copyright (C) 2000 Philipp Rumpf |
7 | */ | 8 | */ |
@@ -117,3 +118,17 @@ unsigned long ___change_bit(unsigned long *addr, unsigned long mask) | |||
117 | return old & mask; | 118 | return old & mask; |
118 | } | 119 | } |
119 | EXPORT_SYMBOL(___change_bit); | 120 | EXPORT_SYMBOL(___change_bit); |
121 | |||
122 | unsigned long __cmpxchg_u32(volatile u32 *ptr, u32 old, u32 new) | ||
123 | { | ||
124 | unsigned long flags; | ||
125 | u32 prev; | ||
126 | |||
127 | spin_lock_irqsave(ATOMIC_HASH(addr), flags); | ||
128 | if ((prev = *ptr) == old) | ||
129 | *ptr = new; | ||
130 | spin_unlock_irqrestore(ATOMIC_HASH(addr), flags); | ||
131 | |||
132 | return (unsigned long)prev; | ||
133 | } | ||
134 | EXPORT_SYMBOL(__cmpxchg_u32); | ||