cmpxchg-irq.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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_u16(volatile u16 *m, unsigned long val)
  14. {
  15. unsigned long flags, retval;
  16. local_irq_save(flags);
  17. retval = *m;
  18. *m = val;
  19. local_irq_restore(flags);
  20. return retval;
  21. }
  22. static inline unsigned long xchg_u8(volatile u8 *m, unsigned long val)
  23. {
  24. unsigned long flags, retval;
  25. local_irq_save(flags);
  26. retval = *m;
  27. *m = val & 0xff;
  28. local_irq_restore(flags);
  29. return retval;
  30. }
  31. static inline unsigned long __cmpxchg_u32(volatile int *m, unsigned long old,
  32. unsigned long new)
  33. {
  34. __u32 retval;
  35. unsigned long flags;
  36. local_irq_save(flags);
  37. retval = *m;
  38. if (retval == old)
  39. *m = new;
  40. local_irq_restore(flags); /* implies memory barrier */
  41. return retval;
  42. }
  43. #endif /* __ASM_SH_CMPXCHG_IRQ_H */