riscv_locks.h 667 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * SPDX-License-Identifier: BSD-2-Clause
  3. *
  4. * Copyright (c) 2019 Western Digital Corporation or its affiliates.
  5. *
  6. * Authors:
  7. * Anup Patel <anup.patel@wdc.com>
  8. */
  9. #ifndef __RISCV_LOCKS_H__
  10. #define __RISCV_LOCKS_H__
  11. typedef struct {
  12. volatile long lock;
  13. } spinlock_t;
  14. #define __RISCV_SPIN_UNLOCKED 0
  15. #define SPIN_LOCK_INIT(_lptr) (_lptr)->lock = __RISCV_SPIN_UNLOCKED
  16. #define SPIN_LOCK_INITIALIZER \
  17. { \
  18. .lock = __RISCV_SPIN_UNLOCKED, \
  19. }
  20. int spin_lock_check(spinlock_t *lock);
  21. int spin_trylock(spinlock_t *lock);
  22. void spin_lock(spinlock_t *lock);
  23. void spin_unlock(spinlock_t *lock);
  24. #endif