diff options
Diffstat (limited to 'drivers/ide/ide-tape.c')
| -rw-r--r-- | drivers/ide/ide-tape.c | 66 |
1 files changed, 48 insertions, 18 deletions
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 58fc920d5c3..1793aea4a7d 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c @@ -35,14 +35,12 @@ #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> #include <scsi/scsi.h> #include <asm/byteorder.h> -#include <linux/irq.h> #include <linux/uaccess.h> #include <linux/io.h> #include <asm/unaligned.h> @@ -219,8 +217,11 @@ 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); + static struct class *idetape_sysfs_class; static void ide_tape_release(struct device *); @@ -575,7 +576,8 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, rq->cmd[0], (unsigned long long)blk_rq_pos(rq), blk_rq_sectors(rq)); - BUG_ON(!(blk_special_request(rq) || blk_sense_request(rq))); + BUG_ON(!(rq->cmd_type == REQ_TYPE_SPECIAL || + rq->cmd_type == REQ_TYPE_SENSE)); /* Retry a failed packet command */ if (drive->failed_pc && drive->pc->c[0] == REQUEST_SENSE) { @@ -1363,7 +1365,7 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) * supported here, and not in the corresponding block interface. Our own * ide-tape ioctls are supported on both interfaces. */ -static int idetape_chrdev_ioctl(struct inode *inode, struct file *file, +static long do_idetape_chrdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { struct ide_tape_obj *tape = file->private_data; @@ -1418,6 +1420,16 @@ static int idetape_chrdev_ioctl(struct inode *inode, struct file *file, } } +static long idetape_chrdev_ioctl(struct file *file, + unsigned int cmd, unsigned long arg) +{ + long ret; + mutex_lock(&ide_tape_mutex); + ret = do_idetape_chrdev_ioctl(file, cmd, arg); + mutex_unlock(&ide_tape_mutex); + return ret; +} + /* * Do a mode sense page 0 with block descriptor and if it succeeds set the tape * block size with the reported value. @@ -1457,10 +1469,11 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp) if (i >= MAX_HWIFS * MAX_DRIVES) return -ENXIO; - lock_kernel(); + mutex_lock(&idetape_chrdev_mutex); + tape = ide_tape_get(NULL, true, i); if (!tape) { - unlock_kernel(); + mutex_unlock(&idetape_chrdev_mutex); return -ENXIO; } @@ -1519,12 +1532,15 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp) tape->door_locked = DOOR_LOCKED; } } - unlock_kernel(); + mutex_unlock(&idetape_chrdev_mutex); + return 0; out_put_tape: ide_tape_put(tape); - unlock_kernel(); + + mutex_unlock(&idetape_chrdev_mutex); + return retval; } @@ -1551,7 +1567,8 @@ static int idetape_chrdev_release(struct inode *inode, struct file *filp) ide_drive_t *drive = tape->drive; unsigned int minor = iminor(inode); - lock_kernel(); + mutex_lock(&idetape_chrdev_mutex); + tape = drive->driver_data; ide_debug_log(IDE_DBG_FUNC, "enter"); @@ -1575,7 +1592,9 @@ static int idetape_chrdev_release(struct inode *inode, struct file *filp) } clear_bit(ilog2(IDE_AFLAG_BUSY), &drive->atapi_flags); ide_tape_put(tape); - unlock_kernel(); + + mutex_unlock(&idetape_chrdev_mutex); + return 0; } @@ -1828,7 +1847,7 @@ static int idetape_name_proc_show(struct seq_file *m, void *v) static int idetape_name_proc_open(struct inode *inode, struct file *file) { - return single_open(file, idetape_name_proc_show, PDE(inode)->data); + return single_open(file, idetape_name_proc_show, PDE_DATA(inode)); } static const struct file_operations idetape_name_proc_fops = { @@ -1879,14 +1898,19 @@ static const struct file_operations idetape_fops = { .owner = THIS_MODULE, .read = idetape_chrdev_read, .write = idetape_chrdev_write, - .ioctl = idetape_chrdev_ioctl, + .unlocked_ioctl = idetape_chrdev_ioctl, .open = idetape_chrdev_open, .release = idetape_chrdev_release, + .llseek = noop_llseek, }; static int idetape_open(struct block_device *bdev, fmode_t mode) { - struct ide_tape_obj *tape = ide_tape_get(bdev->bd_disk, false, 0); + struct ide_tape_obj *tape; + + mutex_lock(&ide_tape_mutex); + tape = ide_tape_get(bdev->bd_disk, false, 0); + mutex_unlock(&ide_tape_mutex); if (!tape) return -ENXIO; @@ -1894,12 +1918,13 @@ static int idetape_open(struct block_device *bdev, fmode_t mode) return 0; } -static int idetape_release(struct gendisk *disk, fmode_t mode) +static void idetape_release(struct gendisk *disk, fmode_t mode) { struct ide_tape_obj *tape = ide_drv_g(disk, ide_tape_obj); + mutex_lock(&ide_tape_mutex); ide_tape_put(tape); - return 0; + mutex_unlock(&ide_tape_mutex); } static int idetape_ioctl(struct block_device *bdev, fmode_t mode, @@ -1907,9 +1932,14 @@ static int idetape_ioctl(struct block_device *bdev, fmode_t mode, { struct ide_tape_obj *tape = ide_drv_g(bdev->bd_disk, ide_tape_obj); ide_drive_t *drive = tape->drive; - int err = generic_ide_ioctl(drive, bdev, cmd, arg); + int err; + + mutex_lock(&ide_tape_mutex); + err = generic_ide_ioctl(drive, bdev, cmd, arg); if (err == -EINVAL) err = idetape_blkdev_ioctl(drive, cmd, arg); + mutex_unlock(&ide_tape_mutex); + return err; } @@ -1917,7 +1947,7 @@ static const struct block_device_operations idetape_block_ops = { .owner = THIS_MODULE, .open = idetape_open, .release = idetape_release, - .locked_ioctl = idetape_ioctl, + .ioctl = idetape_ioctl, }; static int ide_tape_probe(ide_drive_t *drive) @@ -1955,7 +1985,7 @@ static int ide_tape_probe(ide_drive_t *drive) tape->dev.parent = &drive->gendev; tape->dev.release = ide_tape_release; - dev_set_name(&tape->dev, dev_name(&drive->gendev)); + dev_set_name(&tape->dev, "%s", dev_name(&drive->gendev)); if (device_register(&tape->dev)) goto out_free_disk; |
