Skip to content

Commit 62a722f

Browse files
committed
locking/spinlock: introduce spin_lock_init_with_key
Rust cannot call C macros, so it has its own macro to create a new lock class when a spin lock is initialised. This new function allows Rust code to pass the lock class it generates to the C implementation. Cc: Peter Zijlstra <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Will Deacon <[email protected]> Cc: Waiman Long <[email protected]> Signed-off-by: Wedson Almeida Filho <[email protected]>
1 parent d857e42 commit 62a722f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

include/linux/spinlock.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,12 +327,17 @@ static __always_inline raw_spinlock_t *spinlock_check(spinlock_t *lock)
327327

328328
#ifdef CONFIG_DEBUG_SPINLOCK
329329

330+
static inline void spin_lock_init_with_key(spinlock_t *lock, const char *name,
331+
struct lock_class_key *key)
332+
{
333+
__raw_spin_lock_init(spinlock_check(lock), name, key, LD_WAIT_CONFIG);
334+
}
335+
330336
# define spin_lock_init(lock) \
331337
do { \
332338
static struct lock_class_key __key; \
333339
\
334-
__raw_spin_lock_init(spinlock_check(lock), \
335-
#lock, &__key, LD_WAIT_CONFIG); \
340+
spin_lock_init_with_key(lock, #lock, &__key); \
336341
} while (0)
337342

338343
#else

0 commit comments

Comments
 (0)