diff options
Diffstat (limited to 'drivers/scsi/st.c')
-rw-r--r-- | drivers/scsi/st.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 24211d0efa6d..5b7388f1c835 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c | |||
@@ -9,7 +9,7 @@ | |||
9 | Steve Hirsch, Andreas Koppenh"ofer, Michael Leodolter, Eyal Lebedinsky, | 9 | Steve Hirsch, Andreas Koppenh"ofer, Michael Leodolter, Eyal Lebedinsky, |
10 | Michael Schaefer, J"org Weule, and Eric Youngdale. | 10 | Michael Schaefer, J"org Weule, and Eric Youngdale. |
11 | 11 | ||
12 | Copyright 1992 - 2008 Kai Makisara | 12 | Copyright 1992 - 2010 Kai Makisara |
13 | email Kai.Makisara@kolumbus.fi | 13 | email Kai.Makisara@kolumbus.fi |
14 | 14 | ||
15 | Some small formal changes - aeb, 950809 | 15 | Some small formal changes - aeb, 950809 |
@@ -17,7 +17,7 @@ | |||
17 | Last modified: 18-JAN-1998 Richard Gooch <rgooch@atnf.csiro.au> Devfs support | 17 | Last modified: 18-JAN-1998 Richard Gooch <rgooch@atnf.csiro.au> Devfs support |
18 | */ | 18 | */ |
19 | 19 | ||
20 | static const char *verstr = "20081215"; | 20 | static const char *verstr = "20100829"; |
21 | 21 | ||
22 | #include <linux/module.h> | 22 | #include <linux/module.h> |
23 | 23 | ||
@@ -39,7 +39,6 @@ static const char *verstr = "20081215"; | |||
39 | #include <linux/cdev.h> | 39 | #include <linux/cdev.h> |
40 | #include <linux/delay.h> | 40 | #include <linux/delay.h> |
41 | #include <linux/mutex.h> | 41 | #include <linux/mutex.h> |
42 | #include <linux/smp_lock.h> | ||
43 | 42 | ||
44 | #include <asm/uaccess.h> | 43 | #include <asm/uaccess.h> |
45 | #include <asm/dma.h> | 44 | #include <asm/dma.h> |
@@ -76,6 +75,7 @@ static const char *verstr = "20081215"; | |||
76 | #include "st_options.h" | 75 | #include "st_options.h" |
77 | #include "st.h" | 76 | #include "st.h" |
78 | 77 | ||
78 | static DEFINE_MUTEX(st_mutex); | ||
79 | static int buffer_kbs; | 79 | static int buffer_kbs; |
80 | static int max_sg_segs; | 80 | static int max_sg_segs; |
81 | static int try_direct_io = TRY_DIRECT_IO; | 81 | static int try_direct_io = TRY_DIRECT_IO; |
@@ -1180,7 +1180,7 @@ static int st_open(struct inode *inode, struct file *filp) | |||
1180 | int dev = TAPE_NR(inode); | 1180 | int dev = TAPE_NR(inode); |
1181 | char *name; | 1181 | char *name; |
1182 | 1182 | ||
1183 | lock_kernel(); | 1183 | mutex_lock(&st_mutex); |
1184 | /* | 1184 | /* |
1185 | * We really want to do nonseekable_open(inode, filp); here, but some | 1185 | * We really want to do nonseekable_open(inode, filp); here, but some |
1186 | * versions of tar incorrectly call lseek on tapes and bail out if that | 1186 | * versions of tar incorrectly call lseek on tapes and bail out if that |
@@ -1189,7 +1189,7 @@ static int st_open(struct inode *inode, struct file *filp) | |||
1189 | filp->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE); | 1189 | filp->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE); |
1190 | 1190 | ||
1191 | if (!(STp = scsi_tape_get(dev))) { | 1191 | if (!(STp = scsi_tape_get(dev))) { |
1192 | unlock_kernel(); | 1192 | mutex_unlock(&st_mutex); |
1193 | return -ENXIO; | 1193 | return -ENXIO; |
1194 | } | 1194 | } |
1195 | 1195 | ||
@@ -1200,7 +1200,7 @@ static int st_open(struct inode *inode, struct file *filp) | |||
1200 | if (STp->in_use) { | 1200 | if (STp->in_use) { |
1201 | write_unlock(&st_dev_arr_lock); | 1201 | write_unlock(&st_dev_arr_lock); |
1202 | scsi_tape_put(STp); | 1202 | scsi_tape_put(STp); |
1203 | unlock_kernel(); | 1203 | mutex_unlock(&st_mutex); |
1204 | DEB( printk(ST_DEB_MSG "%s: Device already in use.\n", name); ) | 1204 | DEB( printk(ST_DEB_MSG "%s: Device already in use.\n", name); ) |
1205 | return (-EBUSY); | 1205 | return (-EBUSY); |
1206 | } | 1206 | } |
@@ -1249,14 +1249,14 @@ static int st_open(struct inode *inode, struct file *filp) | |||
1249 | retval = (-EIO); | 1249 | retval = (-EIO); |
1250 | goto err_out; | 1250 | goto err_out; |
1251 | } | 1251 | } |
1252 | unlock_kernel(); | 1252 | mutex_unlock(&st_mutex); |
1253 | return 0; | 1253 | return 0; |
1254 | 1254 | ||
1255 | err_out: | 1255 | err_out: |
1256 | normalize_buffer(STp->buffer); | 1256 | normalize_buffer(STp->buffer); |
1257 | STp->in_use = 0; | 1257 | STp->in_use = 0; |
1258 | scsi_tape_put(STp); | 1258 | scsi_tape_put(STp); |
1259 | unlock_kernel(); | 1259 | mutex_unlock(&st_mutex); |
1260 | return retval; | 1260 | return retval; |
1261 | 1261 | ||
1262 | } | 1262 | } |
@@ -2696,18 +2696,21 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon | |||
2696 | } | 2696 | } |
2697 | break; | 2697 | break; |
2698 | case MTWEOF: | 2698 | case MTWEOF: |
2699 | case MTWEOFI: | ||
2699 | case MTWSM: | 2700 | case MTWSM: |
2700 | if (STp->write_prot) | 2701 | if (STp->write_prot) |
2701 | return (-EACCES); | 2702 | return (-EACCES); |
2702 | cmd[0] = WRITE_FILEMARKS; | 2703 | cmd[0] = WRITE_FILEMARKS; |
2703 | if (cmd_in == MTWSM) | 2704 | if (cmd_in == MTWSM) |
2704 | cmd[1] = 2; | 2705 | cmd[1] = 2; |
2706 | if (cmd_in == MTWEOFI) | ||
2707 | cmd[1] |= 1; | ||
2705 | cmd[2] = (arg >> 16); | 2708 | cmd[2] = (arg >> 16); |
2706 | cmd[3] = (arg >> 8); | 2709 | cmd[3] = (arg >> 8); |
2707 | cmd[4] = arg; | 2710 | cmd[4] = arg; |
2708 | timeout = STp->device->request_queue->rq_timeout; | 2711 | timeout = STp->device->request_queue->rq_timeout; |
2709 | DEBC( | 2712 | DEBC( |
2710 | if (cmd_in == MTWEOF) | 2713 | if (cmd_in != MTWSM) |
2711 | printk(ST_DEB_MSG "%s: Writing %d filemarks.\n", name, | 2714 | printk(ST_DEB_MSG "%s: Writing %d filemarks.\n", name, |
2712 | cmd[2] * 65536 + cmd[3] * 256 + cmd[4]); | 2715 | cmd[2] * 65536 + cmd[3] * 256 + cmd[4]); |
2713 | else | 2716 | else |
@@ -2883,8 +2886,8 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon | |||
2883 | else if (chg_eof) | 2886 | else if (chg_eof) |
2884 | STps->eof = ST_NOEOF; | 2887 | STps->eof = ST_NOEOF; |
2885 | 2888 | ||
2886 | if (cmd_in == MTWEOF) | 2889 | if (cmd_in == MTWEOF || cmd_in == MTWEOFI) |
2887 | STps->rw = ST_IDLE; | 2890 | STps->rw = ST_IDLE; /* prevent automatic WEOF at close */ |
2888 | } else { /* SCSI command was not completely successful. Don't return | 2891 | } else { /* SCSI command was not completely successful. Don't return |
2889 | from this block without releasing the SCSI command block! */ | 2892 | from this block without releasing the SCSI command block! */ |
2890 | struct st_cmdstatus *cmdstatp = &STp->buffer->cmdstat; | 2893 | struct st_cmdstatus *cmdstatp = &STp->buffer->cmdstat; |
@@ -2901,7 +2904,7 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon | |||
2901 | else | 2904 | else |
2902 | undone = 0; | 2905 | undone = 0; |
2903 | 2906 | ||
2904 | if (cmd_in == MTWEOF && | 2907 | if ((cmd_in == MTWEOF || cmd_in == MTWEOFI) && |
2905 | cmdstatp->have_sense && | 2908 | cmdstatp->have_sense && |
2906 | (cmdstatp->flags & SENSE_EOM)) { | 2909 | (cmdstatp->flags & SENSE_EOM)) { |
2907 | if (cmdstatp->sense_hdr.sense_key == NO_SENSE || | 2910 | if (cmdstatp->sense_hdr.sense_key == NO_SENSE || |