diff options
author | Arnd Bergmann <arnd@arndb.de> | 2010-06-02 08:28:52 -0400 |
---|---|---|
committer | Arnd Bergmann <arnd@arndb.de> | 2010-10-05 09:01:04 -0400 |
commit | 613655fa39ff6957754fa8ceb8559980920eb8ee (patch) | |
tree | ad19600cb81207b24188683d7fc4ae88013339d1 /drivers/char/mmtimer.c | |
parent | 609146fdb319cebce93be550938ab852f7bade90 (diff) |
drivers: autoconvert trivial BKL users to private mutex
All these files use the big kernel lock in a trivial
way to serialize their private file operations,
typically resulting from an earlier semi-automatic
pushdown from VFS.
None of these drivers appears to want to lock against
other code, and they all use the BKL as the top-level
lock in their file operations, meaning that there
is no lock-order inversion problem.
Consequently, we can remove the BKL completely,
replacing it with a per-file mutex in every case.
Using a scripted approach means we can avoid
typos.
These drivers do not seem to be under active
maintainance from my brief investigation. Apologies
to those maintainers that I have missed.
file=$1
name=$2
if grep -q lock_kernel ${file} ; then
if grep -q 'include.*linux.mutex.h' ${file} ; then
sed -i '/include.*<linux\/smp_lock.h>/d' ${file}
else
sed -i 's/include.*<linux\/smp_lock.h>.*$/include <linux\/mutex.h>/g' ${file}
fi
sed -i ${file} \
-e "/^#include.*linux.mutex.h/,$ {
1,/^\(static\|int\|long\)/ {
/^\(static\|int\|long\)/istatic DEFINE_MUTEX(${name}_mutex);
} }" \
-e "s/\(un\)*lock_kernel\>[ ]*()/mutex_\1lock(\&${name}_mutex)/g" \
-e '/[ ]*cycle_kernel_lock();/d'
else
sed -i -e '/include.*\<smp_lock.h\>/d' ${file} \
-e '/cycle_kernel_lock()/d'
fi
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'drivers/char/mmtimer.c')
-rw-r--r-- | drivers/char/mmtimer.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c index ea7c99fa978f..fe4697844ec1 100644 --- a/drivers/char/mmtimer.c +++ b/drivers/char/mmtimer.c | |||
@@ -32,7 +32,7 @@ | |||
32 | #include <linux/interrupt.h> | 32 | #include <linux/interrupt.h> |
33 | #include <linux/time.h> | 33 | #include <linux/time.h> |
34 | #include <linux/math64.h> | 34 | #include <linux/math64.h> |
35 | #include <linux/smp_lock.h> | 35 | #include <linux/mutex.h> |
36 | #include <linux/slab.h> | 36 | #include <linux/slab.h> |
37 | 37 | ||
38 | #include <asm/uaccess.h> | 38 | #include <asm/uaccess.h> |
@@ -59,6 +59,7 @@ extern unsigned long sn_rtc_cycles_per_second; | |||
59 | 59 | ||
60 | #define rtc_time() (*RTC_COUNTER_ADDR) | 60 | #define rtc_time() (*RTC_COUNTER_ADDR) |
61 | 61 | ||
62 | static DEFINE_MUTEX(mmtimer_mutex); | ||
62 | static long mmtimer_ioctl(struct file *file, unsigned int cmd, | 63 | static long mmtimer_ioctl(struct file *file, unsigned int cmd, |
63 | unsigned long arg); | 64 | unsigned long arg); |
64 | static int mmtimer_mmap(struct file *file, struct vm_area_struct *vma); | 65 | static int mmtimer_mmap(struct file *file, struct vm_area_struct *vma); |
@@ -371,7 +372,7 @@ static long mmtimer_ioctl(struct file *file, unsigned int cmd, | |||
371 | { | 372 | { |
372 | int ret = 0; | 373 | int ret = 0; |
373 | 374 | ||
374 | lock_kernel(); | 375 | mutex_lock(&mmtimer_mutex); |
375 | 376 | ||
376 | switch (cmd) { | 377 | switch (cmd) { |
377 | case MMTIMER_GETOFFSET: /* offset of the counter */ | 378 | case MMTIMER_GETOFFSET: /* offset of the counter */ |
@@ -414,7 +415,7 @@ static long mmtimer_ioctl(struct file *file, unsigned int cmd, | |||
414 | ret = -ENOTTY; | 415 | ret = -ENOTTY; |
415 | break; | 416 | break; |
416 | } | 417 | } |
417 | unlock_kernel(); | 418 | mutex_unlock(&mmtimer_mutex); |
418 | return ret; | 419 | return ret; |
419 | } | 420 | } |
420 | 421 | ||