Skip to content

Commit 7e00072

Browse files
Al Viropaulmckrcu
authored andcommitted
parisc: unify implementations of __cmpxchg_u{8,32,64}
identical except for type name involved Signed-off-by: Al Viro <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 29b8e53 commit 7e00072

File tree

1 file changed

+16
-35
lines changed

1 file changed

+16
-35
lines changed

arch/parisc/lib/bitops.c

Lines changed: 16 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -56,38 +56,19 @@ unsigned long notrace __xchg8(char x, volatile char *ptr)
5656
}
5757

5858

59-
u64 notrace __cmpxchg_u64(volatile u64 *ptr, u64 old, u64 new)
60-
{
61-
unsigned long flags;
62-
u64 prev;
63-
64-
_atomic_spin_lock_irqsave(ptr, flags);
65-
if ((prev = *ptr) == old)
66-
*ptr = new;
67-
_atomic_spin_unlock_irqrestore(ptr, flags);
68-
return prev;
69-
}
70-
71-
u32 notrace __cmpxchg_u32(volatile u32 *ptr, u32 old, u32 new)
72-
{
73-
unsigned long flags;
74-
u32 prev;
75-
76-
_atomic_spin_lock_irqsave(ptr, flags);
77-
if ((prev = *ptr) == old)
78-
*ptr = new;
79-
_atomic_spin_unlock_irqrestore(ptr, flags);
80-
return prev;
81-
}
82-
83-
u8 notrace __cmpxchg_u8(volatile u8 *ptr, u8 old, u8 new)
84-
{
85-
unsigned long flags;
86-
u8 prev;
87-
88-
_atomic_spin_lock_irqsave(ptr, flags);
89-
if ((prev = *ptr) == old)
90-
*ptr = new;
91-
_atomic_spin_unlock_irqrestore(ptr, flags);
92-
return prev;
93-
}
59+
#define CMPXCHG(T) \
60+
T notrace __cmpxchg_##T(volatile T *ptr, T old, T new) \
61+
{ \
62+
unsigned long flags; \
63+
T prev; \
64+
\
65+
_atomic_spin_lock_irqsave(ptr, flags); \
66+
if ((prev = *ptr) == old) \
67+
*ptr = new; \
68+
_atomic_spin_unlock_irqrestore(ptr, flags); \
69+
return prev; \
70+
}
71+
72+
CMPXCHG(u64)
73+
CMPXCHG(u32)
74+
CMPXCHG(u8)

0 commit comments

Comments
 (0)