Linux 6.14-rc1
[linux.git] / rust / helpers / spinlock.c
blob42c4bf01a23e4003ea82c65b16bc8f495ad37750
1 // SPDX-License-Identifier: GPL-2.0
3 #include <linux/spinlock.h>
5 void rust_helper___spin_lock_init(spinlock_t *lock, const char *name,
6 struct lock_class_key *key)
8 #ifdef CONFIG_DEBUG_SPINLOCK
9 # if defined(CONFIG_PREEMPT_RT)
10 __spin_lock_init(lock, name, key, false);
11 # else /*!CONFIG_PREEMPT_RT */
12 __raw_spin_lock_init(spinlock_check(lock), name, key, LD_WAIT_CONFIG);
13 # endif /* CONFIG_PREEMPT_RT */
14 #else /* !CONFIG_DEBUG_SPINLOCK */
15 spin_lock_init(lock);
16 #endif /* CONFIG_DEBUG_SPINLOCK */
19 void rust_helper_spin_lock(spinlock_t *lock)
21 spin_lock(lock);
24 void rust_helper_spin_unlock(spinlock_t *lock)
26 spin_unlock(lock);
29 int rust_helper_spin_trylock(spinlock_t *lock)
31 return spin_trylock(lock);
34 void rust_helper_spin_assert_is_held(spinlock_t *lock)
36 lockdep_assert_held(lock);