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/paride/pcd.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/paride/pcd.c')
-rw-r--r-- | drivers/block/paride/pcd.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c index 76f8565e1e8d..62cec6afd7ad 100644 --- a/drivers/block/paride/pcd.c +++ b/drivers/block/paride/pcd.c | |||
@@ -138,9 +138,10 @@ enum {D_PRT, D_PRO, D_UNI, D_MOD, D_SLV, D_DLY}; | |||
138 | #include <linux/cdrom.h> | 138 | #include <linux/cdrom.h> |
139 | #include <linux/spinlock.h> | 139 | #include <linux/spinlock.h> |
140 | #include <linux/blkdev.h> | 140 | #include <linux/blkdev.h> |
141 | #include <linux/smp_lock.h> | 141 | #include <linux/mutex.h> |
142 | #include <asm/uaccess.h> | 142 | #include <asm/uaccess.h> |
143 | 143 | ||
144 | static DEFINE_MUTEX(pcd_mutex); | ||
144 | static DEFINE_SPINLOCK(pcd_lock); | 145 | static DEFINE_SPINLOCK(pcd_lock); |
145 | 146 | ||
146 | module_param(verbose, bool, 0644); | 147 | module_param(verbose, bool, 0644); |
@@ -227,9 +228,9 @@ static int pcd_block_open(struct block_device *bdev, fmode_t mode) | |||
227 | struct pcd_unit *cd = bdev->bd_disk->private_data; | 228 | struct pcd_unit *cd = bdev->bd_disk->private_data; |
228 | int ret; | 229 | int ret; |
229 | 230 | ||
230 | lock_kernel(); | 231 | mutex_lock(&pcd_mutex); |
231 | ret = cdrom_open(&cd->info, bdev, mode); | 232 | ret = cdrom_open(&cd->info, bdev, mode); |
232 | unlock_kernel(); | 233 | mutex_unlock(&pcd_mutex); |
233 | 234 | ||
234 | return ret; | 235 | return ret; |
235 | } | 236 | } |
@@ -237,9 +238,9 @@ static int pcd_block_open(struct block_device *bdev, fmode_t mode) | |||
237 | static int pcd_block_release(struct gendisk *disk, fmode_t mode) | 238 | static int pcd_block_release(struct gendisk *disk, fmode_t mode) |
238 | { | 239 | { |
239 | struct pcd_unit *cd = disk->private_data; | 240 | struct pcd_unit *cd = disk->private_data; |
240 | lock_kernel(); | 241 | mutex_lock(&pcd_mutex); |
241 | cdrom_release(&cd->info, mode); | 242 | cdrom_release(&cd->info, mode); |
242 | unlock_kernel(); | 243 | mutex_unlock(&pcd_mutex); |
243 | return 0; | 244 | return 0; |
244 | } | 245 | } |
245 | 246 | ||
@@ -249,9 +250,9 @@ static int pcd_block_ioctl(struct block_device *bdev, fmode_t mode, | |||
249 | struct pcd_unit *cd = bdev->bd_disk->private_data; | 250 | struct pcd_unit *cd = bdev->bd_disk->private_data; |
250 | int ret; | 251 | int ret; |
251 | 252 | ||
252 | lock_kernel(); | 253 | mutex_lock(&pcd_mutex); |
253 | ret = cdrom_ioctl(&cd->info, bdev, mode, cmd, arg); | 254 | ret = cdrom_ioctl(&cd->info, bdev, mode, cmd, arg); |
254 | unlock_kernel(); | 255 | mutex_unlock(&pcd_mutex); |
255 | 256 | ||
256 | return ret; | 257 | return ret; |
257 | } | 258 | } |