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/memstick | |
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/memstick')
-rw-r--r-- | drivers/memstick/core/mspro_block.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/memstick/core/mspro_block.c b/drivers/memstick/core/mspro_block.c index d3f1a087eced..02362eccc588 100644 --- a/drivers/memstick/core/mspro_block.c +++ b/drivers/memstick/core/mspro_block.c | |||
@@ -18,11 +18,12 @@ | |||
18 | #include <linux/kthread.h> | 18 | #include <linux/kthread.h> |
19 | #include <linux/delay.h> | 19 | #include <linux/delay.h> |
20 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
21 | #include <linux/smp_lock.h> | 21 | #include <linux/mutex.h> |
22 | #include <linux/memstick.h> | 22 | #include <linux/memstick.h> |
23 | 23 | ||
24 | #define DRIVER_NAME "mspro_block" | 24 | #define DRIVER_NAME "mspro_block" |
25 | 25 | ||
26 | static DEFINE_MUTEX(mspro_block_mutex); | ||
26 | static int major; | 27 | static int major; |
27 | module_param(major, int, 0644); | 28 | module_param(major, int, 0644); |
28 | 29 | ||
@@ -180,7 +181,7 @@ static int mspro_block_bd_open(struct block_device *bdev, fmode_t mode) | |||
180 | struct mspro_block_data *msb = disk->private_data; | 181 | struct mspro_block_data *msb = disk->private_data; |
181 | int rc = -ENXIO; | 182 | int rc = -ENXIO; |
182 | 183 | ||
183 | lock_kernel(); | 184 | mutex_lock(&mspro_block_mutex); |
184 | mutex_lock(&mspro_block_disk_lock); | 185 | mutex_lock(&mspro_block_disk_lock); |
185 | 186 | ||
186 | if (msb && msb->card) { | 187 | if (msb && msb->card) { |
@@ -192,7 +193,7 @@ static int mspro_block_bd_open(struct block_device *bdev, fmode_t mode) | |||
192 | } | 193 | } |
193 | 194 | ||
194 | mutex_unlock(&mspro_block_disk_lock); | 195 | mutex_unlock(&mspro_block_disk_lock); |
195 | unlock_kernel(); | 196 | mutex_unlock(&mspro_block_mutex); |
196 | 197 | ||
197 | return rc; | 198 | return rc; |
198 | } | 199 | } |
@@ -225,9 +226,9 @@ static int mspro_block_disk_release(struct gendisk *disk) | |||
225 | static int mspro_block_bd_release(struct gendisk *disk, fmode_t mode) | 226 | static int mspro_block_bd_release(struct gendisk *disk, fmode_t mode) |
226 | { | 227 | { |
227 | int ret; | 228 | int ret; |
228 | lock_kernel(); | 229 | mutex_lock(&mspro_block_mutex); |
229 | ret = mspro_block_disk_release(disk); | 230 | ret = mspro_block_disk_release(disk); |
230 | unlock_kernel(); | 231 | mutex_unlock(&mspro_block_mutex); |
231 | return ret; | 232 | return ret; |
232 | } | 233 | } |
233 | 234 | ||