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:10 -0400 |
commit | 2a48fc0ab24241755dc93bfd4f01d68efab47f5a (patch) | |
tree | fa9ae10ce89b26b7d8ae9ce24bdfda5e3007b763 /drivers/block/aoe/aoechr.c | |
parent | 613655fa39ff6957754fa8ceb8559980920eb8ee (diff) |
block: autoconvert trivial BKL users to private mutex
The block device drivers have all gained new lock_kernel
calls from a recent pushdown, and some of the drivers
were already using the BKL before.
This turns the BKL into a set of per-driver mutexes.
Still need to check whether this is safe to do.
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/block/aoe/aoechr.c')
-rw-r--r-- | drivers/block/aoe/aoechr.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c index 4a1b9e7464aa..05d5ef172ca5 100644 --- a/drivers/block/aoe/aoechr.c +++ b/drivers/block/aoe/aoechr.c | |||
@@ -9,7 +9,7 @@ | |||
9 | #include <linux/completion.h> | 9 | #include <linux/completion.h> |
10 | #include <linux/delay.h> | 10 | #include <linux/delay.h> |
11 | #include <linux/slab.h> | 11 | #include <linux/slab.h> |
12 | #include <linux/smp_lock.h> | 12 | #include <linux/mutex.h> |
13 | #include <linux/skbuff.h> | 13 | #include <linux/skbuff.h> |
14 | #include "aoe.h" | 14 | #include "aoe.h" |
15 | 15 | ||
@@ -37,6 +37,7 @@ struct ErrMsg { | |||
37 | char *msg; | 37 | char *msg; |
38 | }; | 38 | }; |
39 | 39 | ||
40 | static DEFINE_MUTEX(aoechr_mutex); | ||
40 | static struct ErrMsg emsgs[NMSG]; | 41 | static struct ErrMsg emsgs[NMSG]; |
41 | static int emsgs_head_idx, emsgs_tail_idx; | 42 | static int emsgs_head_idx, emsgs_tail_idx; |
42 | static struct completion emsgs_comp; | 43 | static struct completion emsgs_comp; |
@@ -183,16 +184,16 @@ aoechr_open(struct inode *inode, struct file *filp) | |||
183 | { | 184 | { |
184 | int n, i; | 185 | int n, i; |
185 | 186 | ||
186 | lock_kernel(); | 187 | mutex_lock(&aoechr_mutex); |
187 | n = iminor(inode); | 188 | n = iminor(inode); |
188 | filp->private_data = (void *) (unsigned long) n; | 189 | filp->private_data = (void *) (unsigned long) n; |
189 | 190 | ||
190 | for (i = 0; i < ARRAY_SIZE(chardevs); ++i) | 191 | for (i = 0; i < ARRAY_SIZE(chardevs); ++i) |
191 | if (chardevs[i].minor == n) { | 192 | if (chardevs[i].minor == n) { |
192 | unlock_kernel(); | 193 | mutex_unlock(&aoechr_mutex); |
193 | return 0; | 194 | return 0; |
194 | } | 195 | } |
195 | unlock_kernel(); | 196 | mutex_unlock(&aoechr_mutex); |
196 | return -EINVAL; | 197 | return -EINVAL; |
197 | } | 198 | } |
198 | 199 | ||