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/rtc | |
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/rtc')
-rw-r--r-- | drivers/rtc/rtc-m41t80.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c index d60557cae8ef..512dca16a42c 100644 --- a/drivers/rtc/rtc-m41t80.c +++ b/drivers/rtc/rtc-m41t80.c | |||
@@ -20,7 +20,7 @@ | |||
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | #include <linux/rtc.h> | 21 | #include <linux/rtc.h> |
22 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
23 | #include <linux/smp_lock.h> | 23 | #include <linux/mutex.h> |
24 | #include <linux/string.h> | 24 | #include <linux/string.h> |
25 | #ifdef CONFIG_RTC_DRV_M41T80_WDT | 25 | #ifdef CONFIG_RTC_DRV_M41T80_WDT |
26 | #include <linux/fs.h> | 26 | #include <linux/fs.h> |
@@ -68,6 +68,7 @@ | |||
68 | 68 | ||
69 | #define DRV_VERSION "0.05" | 69 | #define DRV_VERSION "0.05" |
70 | 70 | ||
71 | static DEFINE_MUTEX(m41t80_rtc_mutex); | ||
71 | static const struct i2c_device_id m41t80_id[] = { | 72 | static const struct i2c_device_id m41t80_id[] = { |
72 | { "m41t62", M41T80_FEATURE_SQ | M41T80_FEATURE_SQ_ALT }, | 73 | { "m41t62", M41T80_FEATURE_SQ | M41T80_FEATURE_SQ_ALT }, |
73 | { "m41t65", M41T80_FEATURE_HT | M41T80_FEATURE_WD }, | 74 | { "m41t65", M41T80_FEATURE_HT | M41T80_FEATURE_WD }, |
@@ -677,9 +678,9 @@ static long wdt_unlocked_ioctl(struct file *file, unsigned int cmd, | |||
677 | { | 678 | { |
678 | int ret; | 679 | int ret; |
679 | 680 | ||
680 | lock_kernel(); | 681 | mutex_lock(&m41t80_rtc_mutex); |
681 | ret = wdt_ioctl(file, cmd, arg); | 682 | ret = wdt_ioctl(file, cmd, arg); |
682 | unlock_kernel(); | 683 | mutex_unlock(&m41t80_rtc_mutex); |
683 | 684 | ||
684 | return ret; | 685 | return ret; |
685 | } | 686 | } |
@@ -693,16 +694,16 @@ static long wdt_unlocked_ioctl(struct file *file, unsigned int cmd, | |||
693 | static int wdt_open(struct inode *inode, struct file *file) | 694 | static int wdt_open(struct inode *inode, struct file *file) |
694 | { | 695 | { |
695 | if (MINOR(inode->i_rdev) == WATCHDOG_MINOR) { | 696 | if (MINOR(inode->i_rdev) == WATCHDOG_MINOR) { |
696 | lock_kernel(); | 697 | mutex_lock(&m41t80_rtc_mutex); |
697 | if (test_and_set_bit(0, &wdt_is_open)) { | 698 | if (test_and_set_bit(0, &wdt_is_open)) { |
698 | unlock_kernel(); | 699 | mutex_unlock(&m41t80_rtc_mutex); |
699 | return -EBUSY; | 700 | return -EBUSY; |
700 | } | 701 | } |
701 | /* | 702 | /* |
702 | * Activate | 703 | * Activate |
703 | */ | 704 | */ |
704 | wdt_is_open = 1; | 705 | wdt_is_open = 1; |
705 | unlock_kernel(); | 706 | mutex_unlock(&m41t80_rtc_mutex); |
706 | return nonseekable_open(inode, file); | 707 | return nonseekable_open(inode, file); |
707 | } | 708 | } |
708 | return -ENODEV; | 709 | return -ENODEV; |