Commit 4882720b267b7b1d1b0ce08334b205f0329d4615
1 parent
45f4d02435
Exists in
master
and in
7 other branches
semaphore: Remove mutex emulation
Semaphores used as mutexes have been deprecated for years. Now that all users are either converted to real semaphores or to mutexes remove the cruft. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Christoph Hellwig <hch@infradead.org> LKML-Reference: <20100907125057.562399240@linutronix.de>
Showing 2 changed files with 2 additions and 12 deletions Side-by-side Diff
include/linux/semaphore.h
... | ... | @@ -29,18 +29,12 @@ |
29 | 29 | #define DEFINE_SEMAPHORE(name) \ |
30 | 30 | struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) |
31 | 31 | |
32 | -#define DECLARE_MUTEX(name) \ | |
33 | - struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1) | |
34 | - | |
35 | 32 | static inline void sema_init(struct semaphore *sem, int val) |
36 | 33 | { |
37 | 34 | static struct lock_class_key __key; |
38 | 35 | *sem = (struct semaphore) __SEMAPHORE_INITIALIZER(*sem, val); |
39 | 36 | lockdep_init_map(&sem->lock.dep_map, "semaphore->lock", &__key, 0); |
40 | 37 | } |
41 | - | |
42 | -#define init_MUTEX(sem) sema_init(sem, 1) | |
43 | -#define init_MUTEX_LOCKED(sem) sema_init(sem, 0) | |
44 | 38 | |
45 | 39 | extern void down(struct semaphore *sem); |
46 | 40 | extern int __must_check down_interruptible(struct semaphore *sem); |
scripts/checkpatch.pl
... | ... | @@ -2794,12 +2794,8 @@ |
2794 | 2794 | WARN("__func__ should be used instead of gcc specific __FUNCTION__\n" . $herecurr); |
2795 | 2795 | } |
2796 | 2796 | |
2797 | -# check for semaphores used as mutexes | |
2798 | - if ($line =~ /^.\s*(DECLARE_MUTEX|init_MUTEX)\s*\(/) { | |
2799 | - WARN("mutexes are preferred for single holder semaphores\n" . $herecurr); | |
2800 | - } | |
2801 | -# check for semaphores used as mutexes | |
2802 | - if ($line =~ /^.\s*init_MUTEX_LOCKED\s*\(/) { | |
2797 | +# check for semaphores initialized locked | |
2798 | + if ($line =~ /^.\s*sema_init.+,\W?0\W?\)/) { | |
2803 | 2799 | WARN("consider using a completion\n" . $herecurr); |
2804 | 2800 | |
2805 | 2801 | } |