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