atomic.h 840 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __ASM_SH_ATOMIC_H
  3. #define __ASM_SH_ATOMIC_H
  4. #if defined(CONFIG_CPU_J2)
  5. #include <asm-generic/atomic.h>
  6. #else
  7. /*
  8. * Atomic operations that C can't guarantee us. Useful for
  9. * resource counting etc..
  10. *
  11. */
  12. #include <linux/compiler.h>
  13. #include <linux/types.h>
  14. #include <asm/cmpxchg.h>
  15. #include <asm/barrier.h>
  16. #define arch_atomic_read(v) READ_ONCE((v)->counter)
  17. #define arch_atomic_set(v,i) WRITE_ONCE((v)->counter, (i))
  18. #if defined(CONFIG_GUSA_RB)
  19. #include <asm/atomic-grb.h>
  20. #elif defined(CONFIG_CPU_SH4A)
  21. #include <asm/atomic-llsc.h>
  22. #else
  23. #include <asm/atomic-irq.h>
  24. #endif
  25. #define arch_atomic_xchg(v, new) (arch_xchg(&((v)->counter), new))
  26. #define arch_atomic_cmpxchg(v, o, n) (arch_cmpxchg(&((v)->counter), (o), (n)))
  27. #endif /* CONFIG_CPU_J2 */
  28. #endif /* __ASM_SH_ATOMIC_H */