spinlock.c 890 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // SPDX-License-Identifier: GPL-2.0
  2. #include <linux/spinlock.h>
  3. __rust_helper void rust_helper___spin_lock_init(spinlock_t *lock,
  4. const char *name,
  5. struct lock_class_key *key)
  6. {
  7. #ifdef CONFIG_DEBUG_SPINLOCK
  8. # if defined(CONFIG_PREEMPT_RT)
  9. __spin_lock_init(lock, name, key, false);
  10. # else /*!CONFIG_PREEMPT_RT */
  11. __raw_spin_lock_init(spinlock_check(lock), name, key, LD_WAIT_CONFIG);
  12. # endif /* CONFIG_PREEMPT_RT */
  13. #else /* !CONFIG_DEBUG_SPINLOCK */
  14. spin_lock_init(lock);
  15. #endif /* CONFIG_DEBUG_SPINLOCK */
  16. }
  17. __rust_helper void rust_helper_spin_lock(spinlock_t *lock)
  18. {
  19. spin_lock(lock);
  20. }
  21. __rust_helper void rust_helper_spin_unlock(spinlock_t *lock)
  22. {
  23. spin_unlock(lock);
  24. }
  25. __rust_helper int rust_helper_spin_trylock(spinlock_t *lock)
  26. {
  27. return spin_trylock(lock);
  28. }
  29. __rust_helper void rust_helper_spin_assert_is_held(spinlock_t *lock)
  30. {
  31. lockdep_assert_held(lock);
  32. }