diff options
author | Arnd Bergmann <arnd@arndb.de> | 2010-07-21 02:36:39 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-07-21 02:36:39 -0400 |
commit | a3108ca2323dec0f6321c3f7706cdaed51f694ea (patch) | |
tree | ae3ef899219893cf3de5d543d4e3dc7027c00212 /drivers/sbus/char/openprom.c | |
parent | f8324e20f8289dffc646d64366332e05eaacab25 (diff) |
sbus: 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.
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/sbus/char/openprom.c')
-rw-r--r-- | drivers/sbus/char/openprom.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/sbus/char/openprom.c b/drivers/sbus/char/openprom.c index aacbe14e2e7a..8d6e508222b8 100644 --- a/drivers/sbus/char/openprom.c +++ b/drivers/sbus/char/openprom.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include <linux/kernel.h> | 33 | #include <linux/kernel.h> |
34 | #include <linux/errno.h> | 34 | #include <linux/errno.h> |
35 | #include <linux/slab.h> | 35 | #include <linux/slab.h> |
36 | #include <linux/smp_lock.h> | 36 | #include <linux/mutex.h> |
37 | #include <linux/string.h> | 37 | #include <linux/string.h> |
38 | #include <linux/miscdevice.h> | 38 | #include <linux/miscdevice.h> |
39 | #include <linux/init.h> | 39 | #include <linux/init.h> |
@@ -61,6 +61,7 @@ typedef struct openprom_private_data | |||
61 | } DATA; | 61 | } DATA; |
62 | 62 | ||
63 | /* ID of the PROM node containing all of the EEPROM options. */ | 63 | /* ID of the PROM node containing all of the EEPROM options. */ |
64 | static DEFINE_MUTEX(openprom_mutex); | ||
64 | static struct device_node *options_node; | 65 | static struct device_node *options_node; |
65 | 66 | ||
66 | /* | 67 | /* |
@@ -316,7 +317,7 @@ static long openprom_sunos_ioctl(struct file * file, | |||
316 | if (bufsize < 0) | 317 | if (bufsize < 0) |
317 | return bufsize; | 318 | return bufsize; |
318 | 319 | ||
319 | lock_kernel(); | 320 | mutex_lock(&openprom_mutex); |
320 | 321 | ||
321 | switch (cmd) { | 322 | switch (cmd) { |
322 | case OPROMGETOPT: | 323 | case OPROMGETOPT: |
@@ -367,7 +368,7 @@ static long openprom_sunos_ioctl(struct file * file, | |||
367 | } | 368 | } |
368 | 369 | ||
369 | kfree(opp); | 370 | kfree(opp); |
370 | unlock_kernel(); | 371 | mutex_unlock(&openprom_mutex); |
371 | 372 | ||
372 | return error; | 373 | return error; |
373 | } | 374 | } |
@@ -558,7 +559,7 @@ static int openprom_bsd_ioctl(struct file * file, | |||
558 | void __user *argp = (void __user *)arg; | 559 | void __user *argp = (void __user *)arg; |
559 | int err; | 560 | int err; |
560 | 561 | ||
561 | lock_kernel(); | 562 | mutex_lock(&openprom_mutex); |
562 | switch (cmd) { | 563 | switch (cmd) { |
563 | case OPIOCGET: | 564 | case OPIOCGET: |
564 | err = opiocget(argp, data); | 565 | err = opiocget(argp, data); |
@@ -589,7 +590,7 @@ static int openprom_bsd_ioctl(struct file * file, | |||
589 | err = -EINVAL; | 590 | err = -EINVAL; |
590 | break; | 591 | break; |
591 | }; | 592 | }; |
592 | unlock_kernel(); | 593 | mutex_unlock(&openprom_mutex); |
593 | 594 | ||
594 | return err; | 595 | return err; |
595 | } | 596 | } |
@@ -697,11 +698,11 @@ static int openprom_open(struct inode * inode, struct file * file) | |||
697 | if (!data) | 698 | if (!data) |
698 | return -ENOMEM; | 699 | return -ENOMEM; |
699 | 700 | ||
700 | lock_kernel(); | 701 | mutex_lock(&openprom_mutex); |
701 | data->current_node = of_find_node_by_path("/"); | 702 | data->current_node = of_find_node_by_path("/"); |
702 | data->lastnode = data->current_node; | 703 | data->lastnode = data->current_node; |
703 | file->private_data = (void *) data; | 704 | file->private_data = (void *) data; |
704 | unlock_kernel(); | 705 | mutex_unlock(&openprom_mutex); |
705 | 706 | ||
706 | return 0; | 707 | return 0; |
707 | } | 708 | } |