fbdev: platforming hecubafb and n411
[linux-2.6/mini2440.git] / include / asm-sh / cmpxchg-irq.h
blob43049ec0554b474ed5367ee10602f895a8bb03c0
1 #ifndef __ASM_SH_CMPXCHG_IRQ_H
2 #define __ASM_SH_CMPXCHG_IRQ_H
4 static inline unsigned long xchg_u32(volatile u32 *m, unsigned long val)
6 unsigned long flags, retval;
8 local_irq_save(flags);
9 retval = *m;
10 *m = val;
11 local_irq_restore(flags);
12 return retval;
15 static inline unsigned long xchg_u8(volatile u8 *m, unsigned long val)
17 unsigned long flags, retval;
19 local_irq_save(flags);
20 retval = *m;
21 *m = val & 0xff;
22 local_irq_restore(flags);
23 return retval;
26 static inline unsigned long __cmpxchg_u32(volatile int *m, unsigned long old,
27 unsigned long new)
29 __u32 retval;
30 unsigned long flags;
32 local_irq_save(flags);
33 retval = *m;
34 if (retval == old)
35 *m = new;
36 local_irq_restore(flags); /* implies memory barrier */
37 return retval;
40 #endif /* __ASM_SH_CMPXCHG_IRQ_H */