PageRenderTime 29ms CodeModel.GetById 17ms app.highlight 7ms RepoModel.GetById 2ms app.codeStats 0ms

/Ethereal-msm8939-beta9/arch/metag/include/asm/cmpxchg_irq.h

https://bitbucket.org/MilosStamenkovic95/etherealos
C Header | 42 lines | 34 code | 8 blank | 0 comment | 2 complexity | d235188d257bdb5e2ccb719f7e9e2b12 MD5 | raw file
 1#ifndef __ASM_METAG_CMPXCHG_IRQ_H
 2#define __ASM_METAG_CMPXCHG_IRQ_H
 3
 4#include <linux/irqflags.h>
 5
 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
17static inline unsigned long xchg_u8(volatile u8 *m, unsigned long val)
18{
19	unsigned long flags, retval;
20
21	local_irq_save(flags);
22	retval = *m;
23	*m = val & 0xff;
24	local_irq_restore(flags);
25	return retval;
26}
27
28static inline unsigned long __cmpxchg_u32(volatile int *m, unsigned long old,
29					  unsigned long new)
30{
31	__u32 retval;
32	unsigned long flags;
33
34	local_irq_save(flags);
35	retval = *m;
36	if (retval == old)
37		*m = new;
38	local_irq_restore(flags);       /* implies memory barrier  */
39	return retval;
40}
41
42#endif /* __ASM_METAG_CMPXCHG_IRQ_H */