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/toshiba.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/toshiba.c')
-rw-r--r-- | drivers/char/toshiba.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/char/toshiba.c b/drivers/char/toshiba.c index f8bc79f6de34..f8f09ab0b170 100644 --- a/drivers/char/toshiba.c +++ b/drivers/char/toshiba.c | |||
@@ -68,7 +68,7 @@ | |||
68 | #include <linux/stat.h> | 68 | #include <linux/stat.h> |
69 | #include <linux/proc_fs.h> | 69 | #include <linux/proc_fs.h> |
70 | #include <linux/seq_file.h> | 70 | #include <linux/seq_file.h> |
71 | #include <linux/smp_lock.h> | 71 | #include <linux/mutex.h> |
72 | #include <linux/toshiba.h> | 72 | #include <linux/toshiba.h> |
73 | 73 | ||
74 | #define TOSH_MINOR_DEV 181 | 74 | #define TOSH_MINOR_DEV 181 |
@@ -78,6 +78,7 @@ MODULE_AUTHOR("Jonathan Buzzard <jonathan@buzzard.org.uk>"); | |||
78 | MODULE_DESCRIPTION("Toshiba laptop SMM driver"); | 78 | MODULE_DESCRIPTION("Toshiba laptop SMM driver"); |
79 | MODULE_SUPPORTED_DEVICE("toshiba"); | 79 | MODULE_SUPPORTED_DEVICE("toshiba"); |
80 | 80 | ||
81 | static DEFINE_MUTEX(tosh_mutex); | ||
81 | static int tosh_fn; | 82 | static int tosh_fn; |
82 | module_param_named(fn, tosh_fn, int, 0); | 83 | module_param_named(fn, tosh_fn, int, 0); |
83 | MODULE_PARM_DESC(fn, "User specified Fn key detection port"); | 84 | MODULE_PARM_DESC(fn, "User specified Fn key detection port"); |
@@ -274,16 +275,16 @@ static long tosh_ioctl(struct file *fp, unsigned int cmd, unsigned long arg) | |||
274 | return -EINVAL; | 275 | return -EINVAL; |
275 | 276 | ||
276 | /* do we need to emulate the fan ? */ | 277 | /* do we need to emulate the fan ? */ |
277 | lock_kernel(); | 278 | mutex_lock(&tosh_mutex); |
278 | if (tosh_fan==1) { | 279 | if (tosh_fan==1) { |
279 | if (((ax==0xf300) || (ax==0xf400)) && (bx==0x0004)) { | 280 | if (((ax==0xf300) || (ax==0xf400)) && (bx==0x0004)) { |
280 | err = tosh_emulate_fan(®s); | 281 | err = tosh_emulate_fan(®s); |
281 | unlock_kernel(); | 282 | mutex_unlock(&tosh_mutex); |
282 | break; | 283 | break; |
283 | } | 284 | } |
284 | } | 285 | } |
285 | err = tosh_smm(®s); | 286 | err = tosh_smm(®s); |
286 | unlock_kernel(); | 287 | mutex_unlock(&tosh_mutex); |
287 | break; | 288 | break; |
288 | default: | 289 | default: |
289 | return -EINVAL; | 290 | return -EINVAL; |