]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blob - arch/sh/include/asm/cmpxchg-irq.h
Merge remote-tracking branch 'asoc/fix/rt5645' into asoc-linus
[mirror_ubuntu-focal-kernel.git] / arch / sh / include / asm / cmpxchg-irq.h
1 #ifndef __ASM_SH_CMPXCHG_IRQ_H
2 #define __ASM_SH_CMPXCHG_IRQ_H
3
4 #include <linux/irqflags.h>
5
6 static 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
17 static 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
28 static 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
39 static 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 */