1f15cbe6fSPaul Mundt #ifndef __ASM_SH_CMPXCHG_IRQ_H 2f15cbe6fSPaul Mundt #define __ASM_SH_CMPXCHG_IRQ_H 3f15cbe6fSPaul Mundt 4f15cbe6fSPaul Mundt static inline unsigned long xchg_u32(volatile u32 *m, unsigned long val) 5f15cbe6fSPaul Mundt { 6f15cbe6fSPaul Mundt unsigned long flags, retval; 7f15cbe6fSPaul Mundt 8f15cbe6fSPaul Mundt local_irq_save(flags); 9f15cbe6fSPaul Mundt retval = *m; 10f15cbe6fSPaul Mundt *m = val; 11f15cbe6fSPaul Mundt local_irq_restore(flags); 12f15cbe6fSPaul Mundt return retval; 13f15cbe6fSPaul Mundt } 14f15cbe6fSPaul Mundt 15f15cbe6fSPaul Mundt static inline unsigned long xchg_u8(volatile u8 *m, unsigned long val) 16f15cbe6fSPaul Mundt { 17f15cbe6fSPaul Mundt unsigned long flags, retval; 18f15cbe6fSPaul Mundt 19f15cbe6fSPaul Mundt local_irq_save(flags); 20f15cbe6fSPaul Mundt retval = *m; 21f15cbe6fSPaul Mundt *m = val & 0xff; 22f15cbe6fSPaul Mundt local_irq_restore(flags); 23f15cbe6fSPaul Mundt return retval; 24f15cbe6fSPaul Mundt } 25f15cbe6fSPaul Mundt 26f15cbe6fSPaul Mundt static inline unsigned long __cmpxchg_u32(volatile int *m, unsigned long old, 27f15cbe6fSPaul Mundt unsigned long new) 28f15cbe6fSPaul Mundt { 29f15cbe6fSPaul Mundt __u32 retval; 30f15cbe6fSPaul Mundt unsigned long flags; 31f15cbe6fSPaul Mundt 32f15cbe6fSPaul Mundt local_irq_save(flags); 33f15cbe6fSPaul Mundt retval = *m; 34f15cbe6fSPaul Mundt if (retval == old) 35f15cbe6fSPaul Mundt *m = new; 36f15cbe6fSPaul Mundt local_irq_restore(flags); /* implies memory barrier */ 37f15cbe6fSPaul Mundt return retval; 38f15cbe6fSPaul Mundt } 39f15cbe6fSPaul Mundt 40f15cbe6fSPaul Mundt #endif /* __ASM_SH_CMPXCHG_IRQ_H */ 41