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/input/misc | |
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/input/misc')
-rw-r--r-- | drivers/input/misc/hp_sdc_rtc.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/input/misc/hp_sdc_rtc.c b/drivers/input/misc/hp_sdc_rtc.c index c19066479057..07337061b2eb 100644 --- a/drivers/input/misc/hp_sdc_rtc.c +++ b/drivers/input/misc/hp_sdc_rtc.c | |||
@@ -43,7 +43,7 @@ | |||
43 | #include <linux/proc_fs.h> | 43 | #include <linux/proc_fs.h> |
44 | #include <linux/poll.h> | 44 | #include <linux/poll.h> |
45 | #include <linux/rtc.h> | 45 | #include <linux/rtc.h> |
46 | #include <linux/smp_lock.h> | 46 | #include <linux/mutex.h> |
47 | #include <linux/semaphore.h> | 47 | #include <linux/semaphore.h> |
48 | 48 | ||
49 | MODULE_AUTHOR("Brian S. Julin <bri@calyx.com>"); | 49 | MODULE_AUTHOR("Brian S. Julin <bri@calyx.com>"); |
@@ -52,6 +52,7 @@ MODULE_LICENSE("Dual BSD/GPL"); | |||
52 | 52 | ||
53 | #define RTC_VERSION "1.10d" | 53 | #define RTC_VERSION "1.10d" |
54 | 54 | ||
55 | static DEFINE_MUTEX(hp_sdc_rtc_mutex); | ||
55 | static unsigned long epoch = 2000; | 56 | static unsigned long epoch = 2000; |
56 | 57 | ||
57 | static struct semaphore i8042tregs; | 58 | static struct semaphore i8042tregs; |
@@ -665,9 +666,9 @@ static long hp_sdc_rtc_unlocked_ioctl(struct file *file, | |||
665 | { | 666 | { |
666 | int ret; | 667 | int ret; |
667 | 668 | ||
668 | lock_kernel(); | 669 | mutex_lock(&hp_sdc_rtc_mutex); |
669 | ret = hp_sdc_rtc_ioctl(file, cmd, arg); | 670 | ret = hp_sdc_rtc_ioctl(file, cmd, arg); |
670 | unlock_kernel(); | 671 | mutex_unlock(&hp_sdc_rtc_mutex); |
671 | 672 | ||
672 | return ret; | 673 | return ret; |
673 | } | 674 | } |