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/ub.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/ub.c')
-rw-r--r-- | drivers/block/ub.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/block/ub.c b/drivers/block/ub.c index c48e14878582..b5690a045a01 100644 --- a/drivers/block/ub.c +++ b/drivers/block/ub.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #include <linux/timer.h> | 28 | #include <linux/timer.h> |
29 | #include <linux/scatterlist.h> | 29 | #include <linux/scatterlist.h> |
30 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
31 | #include <linux/smp_lock.h> | 31 | #include <linux/mutex.h> |
32 | #include <scsi/scsi.h> | 32 | #include <scsi/scsi.h> |
33 | 33 | ||
34 | #define DRV_NAME "ub" | 34 | #define DRV_NAME "ub" |
@@ -248,6 +248,7 @@ struct ub_completion { | |||
248 | spinlock_t lock; | 248 | spinlock_t lock; |
249 | }; | 249 | }; |
250 | 250 | ||
251 | static DEFINE_MUTEX(ub_mutex); | ||
251 | static inline void ub_init_completion(struct ub_completion *x) | 252 | static inline void ub_init_completion(struct ub_completion *x) |
252 | { | 253 | { |
253 | x->done = 0; | 254 | x->done = 0; |
@@ -1715,9 +1716,9 @@ static int ub_bd_unlocked_open(struct block_device *bdev, fmode_t mode) | |||
1715 | { | 1716 | { |
1716 | int ret; | 1717 | int ret; |
1717 | 1718 | ||
1718 | lock_kernel(); | 1719 | mutex_lock(&ub_mutex); |
1719 | ret = ub_bd_open(bdev, mode); | 1720 | ret = ub_bd_open(bdev, mode); |
1720 | unlock_kernel(); | 1721 | mutex_unlock(&ub_mutex); |
1721 | 1722 | ||
1722 | return ret; | 1723 | return ret; |
1723 | } | 1724 | } |
@@ -1730,9 +1731,9 @@ static int ub_bd_release(struct gendisk *disk, fmode_t mode) | |||
1730 | struct ub_lun *lun = disk->private_data; | 1731 | struct ub_lun *lun = disk->private_data; |
1731 | struct ub_dev *sc = lun->udev; | 1732 | struct ub_dev *sc = lun->udev; |
1732 | 1733 | ||
1733 | lock_kernel(); | 1734 | mutex_lock(&ub_mutex); |
1734 | ub_put(sc); | 1735 | ub_put(sc); |
1735 | unlock_kernel(); | 1736 | mutex_unlock(&ub_mutex); |
1736 | 1737 | ||
1737 | return 0; | 1738 | return 0; |
1738 | } | 1739 | } |
@@ -1747,9 +1748,9 @@ static int ub_bd_ioctl(struct block_device *bdev, fmode_t mode, | |||
1747 | void __user *usermem = (void __user *) arg; | 1748 | void __user *usermem = (void __user *) arg; |
1748 | int ret; | 1749 | int ret; |
1749 | 1750 | ||
1750 | lock_kernel(); | 1751 | mutex_lock(&ub_mutex); |
1751 | ret = scsi_cmd_ioctl(disk->queue, disk, mode, cmd, usermem); | 1752 | ret = scsi_cmd_ioctl(disk->queue, disk, mode, cmd, usermem); |
1752 | unlock_kernel(); | 1753 | mutex_unlock(&ub_mutex); |
1753 | 1754 | ||
1754 | return ret; | 1755 | return ret; |
1755 | } | 1756 | } |