Skip to content

Commit 96f8052

Browse files
bvanasschegregkh
authored andcommitted
locking/mutex: Define mutex_init() once
With CONFIG_PREEMPT_RT disabled __mutex_init() is a function. With CONFIG_PREEMPT_RT enabled, __mutex_init() is a macro. I assume this is why mutex_init() is defined twice as exactly the same macro. Prepare for introducing a new macro for mutex initialization by combining the two identical mutex_init() definitions into a single definition. This patch does not change any functionality because the C preprocessor expands macros when it encounters the macro name and not when a macro definition is encountered. See also commit bb630f9 ("locking/rtmutex: Add mutex variant for RT"). Acked-by: Peter Zijlstra (Intel) <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Ingo Molnar <[email protected]> Signed-off-by: Bart Van Assche <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 2193ede commit 96f8052

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

include/linux/mutex.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ static inline void mutex_destroy(struct mutex *lock) {}
4949

5050
#endif
5151

52-
#ifndef CONFIG_PREEMPT_RT
5352
/**
5453
* mutex_init - initialize the mutex
5554
* @mutex: the mutex to be initialized
@@ -65,6 +64,7 @@ do { \
6564
__mutex_init((mutex), #mutex, &__key); \
6665
} while (0)
6766

67+
#ifndef CONFIG_PREEMPT_RT
6868
#define __MUTEX_INITIALIZER(lockname) \
6969
{ .owner = ATOMIC_LONG_INIT(0) \
7070
, .wait_lock = __RAW_SPIN_LOCK_UNLOCKED(lockname.wait_lock) \
@@ -111,12 +111,6 @@ do { \
111111
__mutex_rt_init((mutex), name, key); \
112112
} while (0)
113113

114-
#define mutex_init(mutex) \
115-
do { \
116-
static struct lock_class_key __key; \
117-
\
118-
__mutex_init((mutex), #mutex, &__key); \
119-
} while (0)
120114
#endif /* CONFIG_PREEMPT_RT */
121115

122116
#ifdef CONFIG_DEBUG_MUTEXES

0 commit comments

Comments
 (0)