Skip to content

Commit d4ad4de

Browse files
Darksonnfbq
authored andcommitted
rust: sync: Add __rust_helper to helpers
This is needed to inline these helpers into Rust code. Reviewed-by: Boqun Feng <boqun.feng@gmail.com> Reviewed-by: Gary Guo <gary@garyguo.net> Signed-off-by: Alice Ryhl <aliceryhl@google.com> Signed-off-by: Boqun Feng <boqun.feng@gmail.com> Link: https://patch.msgid.link/20260105-define-rust-helper-v2-20-51da5f454a67@google.com
1 parent 9ba1aaf commit d4ad4de

3 files changed

Lines changed: 16 additions & 14 deletions

File tree

rust/helpers/mutex.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,29 @@
22

33
#include <linux/mutex.h>
44

5-
void rust_helper_mutex_lock(struct mutex *lock)
5+
__rust_helper void rust_helper_mutex_lock(struct mutex *lock)
66
{
77
mutex_lock(lock);
88
}
99

10-
int rust_helper_mutex_trylock(struct mutex *lock)
10+
__rust_helper int rust_helper_mutex_trylock(struct mutex *lock)
1111
{
1212
return mutex_trylock(lock);
1313
}
1414

15-
void rust_helper___mutex_init(struct mutex *mutex, const char *name,
16-
struct lock_class_key *key)
15+
__rust_helper void rust_helper___mutex_init(struct mutex *mutex,
16+
const char *name,
17+
struct lock_class_key *key)
1718
{
1819
__mutex_init(mutex, name, key);
1920
}
2021

21-
void rust_helper_mutex_assert_is_held(struct mutex *mutex)
22+
__rust_helper void rust_helper_mutex_assert_is_held(struct mutex *mutex)
2223
{
2324
lockdep_assert_held(mutex);
2425
}
2526

26-
void rust_helper_mutex_destroy(struct mutex *lock)
27+
__rust_helper void rust_helper_mutex_destroy(struct mutex *lock)
2728
{
2829
mutex_destroy(lock);
2930
}

rust/helpers/spinlock.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
#include <linux/spinlock.h>
44

5-
void rust_helper___spin_lock_init(spinlock_t *lock, const char *name,
6-
struct lock_class_key *key)
5+
__rust_helper void rust_helper___spin_lock_init(spinlock_t *lock,
6+
const char *name,
7+
struct lock_class_key *key)
78
{
89
#ifdef CONFIG_DEBUG_SPINLOCK
910
# if defined(CONFIG_PREEMPT_RT)
@@ -16,22 +17,22 @@ void rust_helper___spin_lock_init(spinlock_t *lock, const char *name,
1617
#endif /* CONFIG_DEBUG_SPINLOCK */
1718
}
1819

19-
void rust_helper_spin_lock(spinlock_t *lock)
20+
__rust_helper void rust_helper_spin_lock(spinlock_t *lock)
2021
{
2122
spin_lock(lock);
2223
}
2324

24-
void rust_helper_spin_unlock(spinlock_t *lock)
25+
__rust_helper void rust_helper_spin_unlock(spinlock_t *lock)
2526
{
2627
spin_unlock(lock);
2728
}
2829

29-
int rust_helper_spin_trylock(spinlock_t *lock)
30+
__rust_helper int rust_helper_spin_trylock(spinlock_t *lock)
3031
{
3132
return spin_trylock(lock);
3233
}
3334

34-
void rust_helper_spin_assert_is_held(spinlock_t *lock)
35+
__rust_helper void rust_helper_spin_assert_is_held(spinlock_t *lock)
3536
{
3637
lockdep_assert_held(lock);
3738
}

rust/helpers/sync.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
#include <linux/lockdep.h>
44

5-
void rust_helper_lockdep_register_key(struct lock_class_key *k)
5+
__rust_helper void rust_helper_lockdep_register_key(struct lock_class_key *k)
66
{
77
lockdep_register_key(k);
88
}
99

10-
void rust_helper_lockdep_unregister_key(struct lock_class_key *k)
10+
__rust_helper void rust_helper_lockdep_unregister_key(struct lock_class_key *k)
1111
{
1212
lockdep_unregister_key(k);
1313
}

0 commit comments

Comments
 (0)