projects/linux·blob master · refs

53 lines · 1.2 KiB

1// SPDX-License-Identifier: GPL-2.0
2
3#include <linux/spinlock.h>
4
5__rust_helper void rust_helper___spin_lock_init(spinlock_t *lock,
6 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__rust_helper void rust_helper_spin_lock(spinlock_t *lock)
21{
22 spin_lock(lock);
23}
24
25__rust_helper void rust_helper_spin_unlock(spinlock_t *lock)
26{
27 spin_unlock(lock);
28}
29
30__rust_helper int rust_helper_spin_trylock(spinlock_t *lock)
31{
32 return spin_trylock(lock);
33}
34
35__rust_helper void rust_helper_spin_assert_is_held(spinlock_t *lock)
36{
37 lockdep_assert_held(lock);
38}
39
40__rust_helper void rust_helper_spin_lock_irq_disable(spinlock_t *lock)
41{
42 spin_lock_irq_disable(lock);
43}
44
45__rust_helper void rust_helper_spin_unlock_irq_enable(spinlock_t *lock)
46{
47 spin_unlock_irq_enable(lock);
48}
49
50__rust_helper int rust_helper_spin_trylock_irq_disable(spinlock_t *lock)
51{
52 return spin_trylock_irq_disable(lock);
53}