Skip to content

Commit

Permalink
parisc: unify implementations of __cmpxchg_u{8,32,64}
Browse files Browse the repository at this point in the history
identical except for type name involved

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
  • Loading branch information
Al Viro authored and Paul E. McKenney committed Apr 10, 2024
1 parent 29b8e53 commit 7e00072
Showing 1 changed file with 16 additions and 35 deletions.
51 changes: 16 additions & 35 deletions arch/parisc/lib/bitops.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,38 +56,19 @@ unsigned long notrace __xchg8(char x, volatile char *ptr)
}


u64 notrace __cmpxchg_u64(volatile u64 *ptr, u64 old, u64 new)
{
unsigned long flags;
u64 prev;

_atomic_spin_lock_irqsave(ptr, flags);
if ((prev = *ptr) == old)
*ptr = new;
_atomic_spin_unlock_irqrestore(ptr, flags);
return prev;
}

u32 notrace __cmpxchg_u32(volatile u32 *ptr, u32 old, u32 new)
{
unsigned long flags;
u32 prev;

_atomic_spin_lock_irqsave(ptr, flags);
if ((prev = *ptr) == old)
*ptr = new;
_atomic_spin_unlock_irqrestore(ptr, flags);
return prev;
}

u8 notrace __cmpxchg_u8(volatile u8 *ptr, u8 old, u8 new)
{
unsigned long flags;
u8 prev;

_atomic_spin_lock_irqsave(ptr, flags);
if ((prev = *ptr) == old)
*ptr = new;
_atomic_spin_unlock_irqrestore(ptr, flags);
return prev;
}
#define CMPXCHG(T) \
T notrace __cmpxchg_##T(volatile T *ptr, T old, T new) \
{ \
unsigned long flags; \
T prev; \
\
_atomic_spin_lock_irqsave(ptr, flags); \
if ((prev = *ptr) == old) \
*ptr = new; \
_atomic_spin_unlock_irqrestore(ptr, flags); \
return prev; \
}

CMPXCHG(u64)
CMPXCHG(u32)
CMPXCHG(u8)

0 comments on commit 7e00072

Please sign in to comment.