]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - arch/metag/include/asm/cmpxchg_lock1.h
Merge branch 'slab/for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/penber...
[mirror_ubuntu-jammy-kernel.git] / arch / metag / include / asm / cmpxchg_lock1.h
1 #ifndef __ASM_METAG_CMPXCHG_LOCK1_H
2 #define __ASM_METAG_CMPXCHG_LOCK1_H
3
4 #include <asm/global_lock.h>
5
6 /* Use LOCK2 as these have to be atomic w.r.t. ordinary accesses. */
7
8 static inline unsigned long xchg_u32(volatile u32 *m, unsigned long val)
9 {
10 unsigned long flags, retval;
11
12 __global_lock2(flags);
13 fence();
14 retval = *m;
15 *m = val;
16 __global_unlock2(flags);
17 return retval;
18 }
19
20 static inline unsigned long xchg_u8(volatile u8 *m, unsigned long val)
21 {
22 unsigned long flags, retval;
23
24 __global_lock2(flags);
25 fence();
26 retval = *m;
27 *m = val & 0xff;
28 __global_unlock2(flags);
29 return retval;
30 }
31
32 static inline unsigned long __cmpxchg_u32(volatile int *m, unsigned long old,
33 unsigned long new)
34 {
35 __u32 retval;
36 unsigned long flags;
37
38 __global_lock2(flags);
39 retval = *m;
40 if (retval == old) {
41 fence();
42 *m = new;
43 }
44 __global_unlock2(flags);
45 return retval;
46 }
47
48 #endif /* __ASM_METAG_CMPXCHG_LOCK1_H */