sh: support 1 and 2 byte xchg
[deliverable/linux.git] / arch / sh / include / asm / cmpxchg-irq.h
CommitLineData
1efe4ce3
SM
1#ifndef __ASM_SH_CMPXCHG_IRQ_H
2#define __ASM_SH_CMPXCHG_IRQ_H
3
e839ca52
DH
4#include <linux/irqflags.h>
5
1efe4ce3
SM
6static inline unsigned long xchg_u32(volatile u32 *m, unsigned long val)
7{
8 unsigned long flags, retval;
9
10 local_irq_save(flags);
11 retval = *m;
12 *m = val;
13 local_irq_restore(flags);
14 return retval;
15}
16
3226aad8
MT
17static inline unsigned long xchg_u16(volatile u16 *m, unsigned long val)
18{
19 unsigned long flags, retval;
20
21 local_irq_save(flags);
22 retval = *m;
23 *m = val;
24 local_irq_restore(flags);
25 return retval;
26}
27
1efe4ce3
SM
28static inline unsigned long xchg_u8(volatile u8 *m, unsigned long val)
29{
30 unsigned long flags, retval;
31
32 local_irq_save(flags);
33 retval = *m;
34 *m = val & 0xff;
35 local_irq_restore(flags);
36 return retval;
37}
38
39static inline unsigned long __cmpxchg_u32(volatile int *m, unsigned long old,
40 unsigned long new)
41{
42 __u32 retval;
43 unsigned long flags;
44
45 local_irq_save(flags);
46 retval = *m;
47 if (retval == old)
48 *m = new;
49 local_irq_restore(flags); /* implies memory barrier */
50 return retval;
51}
52
53#endif /* __ASM_SH_CMPXCHG_IRQ_H */
This page took 0.701223 seconds and 5 git commands to generate.