cmpxchg-irq.h 825 B

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