diff options
author | Arnd Bergmann <arnd@arndb.de> | 2010-06-02 14:28:52 +0200 |
---|---|---|
committer | Arnd Bergmann <arnd@arndb.de> | 2010-10-05 15:01:10 +0200 |
commit | 2a48fc0ab24241755dc93bfd4f01d68efab47f5a (patch) | |
tree | fa9ae10ce89b26b7d8ae9ce24bdfda5e3007b763 /drivers/ide/ide-tape.c | |
parent | drivers: autoconvert trivial BKL users to private mutex (diff) | |
download | linux-2a48fc0ab24241755dc93bfd4f01d68efab47f5a.tar.xz linux-2a48fc0ab24241755dc93bfd4f01d68efab47f5a.zip |
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/ide/ide-tape.c')
-rw-r--r-- | drivers/ide/ide-tape.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 6d622cb5ac81..65f0bcfb42ca 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c @@ -32,11 +32,9 @@ #include <linux/errno.h> #include <linux/genhd.h> #include <linux/seq_file.h> -#include <linux/smp_lock.h> #include <linux/slab.h> #include <linux/pci.h> #include <linux/ide.h> -#include <linux/smp_lock.h> #include <linux/completion.h> #include <linux/bitops.h> #include <linux/mutex.h> @@ -220,6 +218,7 @@ typedef struct ide_tape_obj { char write_prot; } idetape_tape_t; +static DEFINE_MUTEX(ide_tape_mutex); static DEFINE_MUTEX(idetape_ref_mutex); static DEFINE_MUTEX(idetape_chrdev_mutex); @@ -1426,9 +1425,9 @@ static long idetape_chrdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { long ret; - lock_kernel(); + mutex_lock(&ide_tape_mutex); ret = do_idetape_chrdev_ioctl(file, cmd, arg); - unlock_kernel(); + mutex_unlock(&ide_tape_mutex); return ret; } @@ -1909,9 +1908,9 @@ static int idetape_open(struct block_device *bdev, fmode_t mode) { struct ide_tape_obj *tape; - lock_kernel(); + mutex_lock(&ide_tape_mutex); tape = ide_tape_get(bdev->bd_disk, false, 0); - unlock_kernel(); + mutex_unlock(&ide_tape_mutex); if (!tape) return -ENXIO; @@ -1923,9 +1922,9 @@ static int idetape_release(struct gendisk *disk, fmode_t mode) { struct ide_tape_obj *tape = ide_drv_g(disk, ide_tape_obj); - lock_kernel(); + mutex_lock(&ide_tape_mutex); ide_tape_put(tape); - unlock_kernel(); + mutex_unlock(&ide_tape_mutex); return 0; } @@ -1937,11 +1936,11 @@ static int idetape_ioctl(struct block_device *bdev, fmode_t mode, ide_drive_t *drive = tape->drive; int err; - lock_kernel(); + mutex_lock(&ide_tape_mutex); err = generic_ide_ioctl(drive, bdev, cmd, arg); if (err == -EINVAL) err = idetape_blkdev_ioctl(drive, cmd, arg); - unlock_kernel(); + mutex_unlock(&ide_tape_mutex); return err; } |