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