Lines Matching refs:STp
238 struct scsi_tape *STp = NULL; in scsi_tape_get() local
244 STp = scsi_tapes[dev]; in scsi_tape_get()
245 if (!STp) goto out; in scsi_tape_get()
247 kref_get(&STp->kref); in scsi_tape_get()
249 if (!STp->device) in scsi_tape_get()
252 if (scsi_device_get(STp->device)) in scsi_tape_get()
258 kref_put(&STp->kref, scsi_tape_release); in scsi_tape_get()
259 STp = NULL; in scsi_tape_get()
263 return STp; in scsi_tape_get()
266 static void scsi_tape_put(struct scsi_tape *STp) in scsi_tape_put() argument
268 struct scsi_device *sdev = STp->device; in scsi_tape_put()
271 kref_put(&STp->kref, scsi_tape_release); in scsi_tape_put()
346 static int st_chk_result(struct scsi_tape *STp, struct st_request * SRpnt) in st_chk_result() argument
351 char *name = tape_name(STp); in st_chk_result()
357 cmdstatp = &STp->buffer->cmdstat; in st_chk_result()
361 scode = STp->buffer->cmdstat.sense_hdr.sense_key; in st_chk_result()
394 STp->cln_mode >= EXTENDED_SENSE_START) { /* Only fixed format sense */ in st_chk_result()
395 if (STp->cln_sense_value) in st_chk_result()
396 STp->cleaning_req |= ((SRpnt->sense[STp->cln_mode] & in st_chk_result()
397 STp->cln_sense_mask) == STp->cln_sense_value); in st_chk_result()
399 STp->cleaning_req |= ((SRpnt->sense[STp->cln_mode] & in st_chk_result()
400 STp->cln_sense_mask) != 0); in st_chk_result()
404 STp->cleaning_req = 1; /* ASC and ASCQ => cleaning requested */ in st_chk_result()
406 STp->pos_unknown |= STp->device->was_reset; in st_chk_result()
415 STp->recover_count++; in st_chk_result()
416 STp->recover_reg++; in st_chk_result()
427 STp->recover_count); in st_chk_result()
463 struct scsi_tape *STp = SRpnt->stp; in st_scsi_execute_end() local
466 STp->buffer->cmdstat.midlevel_result = SRpnt->result = req->errors; in st_scsi_execute_end()
467 STp->buffer->cmdstat.residual = req->resid_len; in st_scsi_execute_end()
523 st_do_scsi(struct st_request * SRpnt, struct scsi_tape * STp, unsigned char *cmd, in st_do_scsi() argument
527 struct rq_map_data *mdata = &STp->buffer->map_data; in st_do_scsi()
531 if (!do_wait && ((STp->buffer)->last_SRpnt)) { in st_do_scsi()
533 tape_name(STp)); in st_do_scsi()
535 (STp->buffer)->syscall_result = (-EINTR); in st_do_scsi()
537 (STp->buffer)->syscall_result = (-EBUSY); in st_do_scsi()
542 SRpnt = st_allocate_request(STp); in st_do_scsi()
550 (STp->buffer)->last_SRpnt = SRpnt; in st_do_scsi()
552 waiting = &STp->wait; in st_do_scsi()
556 if (STp->buffer->do_dio) { in st_do_scsi()
558 mdata->nr_entries = STp->buffer->sg_segs; in st_do_scsi()
559 mdata->pages = STp->buffer->mapped_pages; in st_do_scsi()
561 mdata->page_order = STp->buffer->reserved_page_order; in st_do_scsi()
564 mdata->pages = STp->buffer->reserved_pages; in st_do_scsi()
569 STp->buffer->cmdstat.have_sense = 0; in st_do_scsi()
570 STp->buffer->syscall_result = 0; in st_do_scsi()
576 (STp->buffer)->syscall_result = (-EBUSY); in st_do_scsi()
577 (STp->buffer)->last_SRpnt = NULL; in st_do_scsi()
581 (STp->buffer)->syscall_result = st_chk_result(STp, SRpnt); in st_do_scsi()
592 static int write_behind_check(struct scsi_tape * STp) in write_behind_check() argument
600 STbuffer = STp->buffer; in write_behind_check()
605 if (STp->write_pending) in write_behind_check()
606 STp->nbr_waits++; in write_behind_check()
608 STp->nbr_finished++; in write_behind_check()
611 wait_for_completion(&(STp->wait)); in write_behind_check()
616 (STp->buffer)->syscall_result = st_chk_result(STp, SRpnt); in write_behind_check()
620 STps = &(STp->ps[STp->partition]); in write_behind_check()
622 if (STp->block_size == 0) in write_behind_check()
625 STps->drv_block += STbuffer->writing / STp->block_size; in write_behind_check()
647 tape_name(STp), STbuffer->cmdstat.midlevel_result, retval);) /* end DEB */ in write_behind_check()
655 static int cross_eof(struct scsi_tape * STp, int forward) in cross_eof() argument
670 tape_name(STp), forward ? "forward" : "backward")); in cross_eof()
672 SRpnt = st_do_scsi(NULL, STp, cmd, 0, DMA_NONE, in cross_eof()
673 STp->device->request_queue->rq_timeout, in cross_eof()
676 return (STp->buffer)->syscall_result; in cross_eof()
681 if ((STp->buffer)->cmdstat.midlevel_result != 0) in cross_eof()
683 tape_name(STp), forward ? "forward" : "backward"); in cross_eof()
685 return (STp->buffer)->syscall_result; in cross_eof()
690 static int st_flush_write_buffer(struct scsi_tape * STp) in st_flush_write_buffer() argument
698 result = write_behind_check(STp); in st_flush_write_buffer()
703 if (STp->dirty == 1) { in st_flush_write_buffer()
705 transfer = STp->buffer->buffer_bytes; in st_flush_write_buffer()
707 tape_name(STp), transfer)); in st_flush_write_buffer()
712 blks = transfer / STp->block_size; in st_flush_write_buffer()
717 SRpnt = st_do_scsi(NULL, STp, cmd, transfer, DMA_TO_DEVICE, in st_flush_write_buffer()
718 STp->device->request_queue->rq_timeout, in st_flush_write_buffer()
721 return (STp->buffer)->syscall_result; in st_flush_write_buffer()
723 STps = &(STp->ps[STp->partition]); in st_flush_write_buffer()
724 if ((STp->buffer)->syscall_result != 0) { in st_flush_write_buffer()
725 struct st_cmdstatus *cmdstatp = &STp->buffer->cmdstat; in st_flush_write_buffer()
733 STp->dirty = 0; in st_flush_write_buffer()
734 (STp->buffer)->buffer_bytes = 0; in st_flush_write_buffer()
740 tape_name(STp)); in st_flush_write_buffer()
747 STp->dirty = 0; in st_flush_write_buffer()
748 (STp->buffer)->buffer_bytes = 0; in st_flush_write_buffer()
759 static int flush_buffer(struct scsi_tape *STp, int seek_next) in flush_buffer() argument
765 STbuffer = STp->buffer; in flush_buffer()
771 if (STp->pos_unknown) in flush_buffer()
774 if (STp->ready != ST_READY) in flush_buffer()
776 STps = &(STp->ps[STp->partition]); in flush_buffer()
778 return st_flush_write_buffer(STp); in flush_buffer()
780 if (STp->block_size == 0) in flush_buffer()
783 backspace = ((STp->buffer)->buffer_bytes + in flush_buffer()
784 (STp->buffer)->read_pointer) / STp->block_size - in flush_buffer()
785 ((STp->buffer)->read_pointer + STp->block_size - 1) / in flush_buffer()
786 STp->block_size; in flush_buffer()
787 (STp->buffer)->buffer_bytes = 0; in flush_buffer()
788 (STp->buffer)->read_pointer = 0; in flush_buffer()
792 result = cross_eof(STp, 0); /* Back over the EOF hit */ in flush_buffer()
802 result = st_int_ioctl(STp, MTBSR, backspace); in flush_buffer()
814 static int set_mode_densblk(struct scsi_tape * STp, struct st_modedef * STm) in set_mode_densblk() argument
818 char *name = tape_name(STp); in set_mode_densblk()
820 if (!STp->density_changed && in set_mode_densblk()
822 STm->default_density != STp->density) { in set_mode_densblk()
826 arg = STp->density; in set_mode_densblk()
828 if (!STp->blksize_changed && in set_mode_densblk()
830 STm->default_blksize != STp->block_size) { in set_mode_densblk()
834 arg |= STp->block_size; in set_mode_densblk()
836 st_int_ioctl(STp, SET_DENS_AND_BLK, arg)) { in set_mode_densblk()
848 static int do_door_lock(struct scsi_tape * STp, int do_lock) in do_door_lock() argument
851 DEB(char *name = tape_name(STp);) in do_door_lock()
857 retval = scsi_ioctl(STp->device, cmd, NULL); in do_door_lock()
859 STp->door_locked = do_lock ? ST_LOCKED_EXPLICIT : ST_UNLOCKED; in do_door_lock()
862 STp->door_locked = ST_LOCK_FAILS; in do_door_lock()
869 static void reset_state(struct scsi_tape *STp) in reset_state() argument
874 STp->pos_unknown = 0; in reset_state()
876 STps = &(STp->ps[i]); in reset_state()
884 if (STp->can_partitions) { in reset_state()
885 STp->partition = find_partition(STp); in reset_state()
886 if (STp->partition < 0) in reset_state()
887 STp->partition = 0; in reset_state()
888 STp->new_partition = STp->partition; in reset_state()
901 static int test_ready(struct scsi_tape *STp, int do_wait) in test_ready() argument
907 struct st_cmdstatus *cmdstatp = &STp->buffer->cmdstat; in test_ready()
914 SRpnt = st_do_scsi(SRpnt, STp, cmd, 0, DMA_NONE, in test_ready()
915 STp->long_timeout, MAX_READY_RETRIES, 1); in test_ready()
918 retval = (STp->buffer)->syscall_result; in test_ready()
948 if ((STp->device)->scsi_level >= SCSI_2 && in test_ready()
958 retval = (STp->buffer)->syscall_result; in test_ready()
975 static int check_tape(struct scsi_tape *STp, struct file *filp) in check_tape() argument
983 char *name = tape_name(STp); in check_tape()
987 STp->ready = ST_READY; in check_tape()
989 if (mode != STp->current_mode) { in check_tape()
991 name, STp->current_mode, mode)); in check_tape()
993 STp->current_mode = mode; in check_tape()
995 STm = &(STp->modes[STp->current_mode]); in check_tape()
997 saved_cleaning = STp->cleaning_req; in check_tape()
998 STp->cleaning_req = 0; in check_tape()
1001 retval = test_ready(STp, do_wait); in check_tape()
1007 STp->pos_unknown = 0; in check_tape()
1008 STp->partition = STp->new_partition = 0; in check_tape()
1009 if (STp->can_partitions) in check_tape()
1010 STp->nbr_partitions = 1; /* This guess will be updated later in check_tape()
1013 STps = &(STp->ps[i]); in check_tape()
1024 STp->cleaning_req |= saved_cleaning; in check_tape()
1028 STp->ready = ST_NO_TAPE; in check_tape()
1030 STp->ready = ST_NOT_READY; in check_tape()
1032 STp->density = 0; /* Clear the erroneous "residue" */ in check_tape()
1033 STp->write_prot = 0; in check_tape()
1034 STp->block_size = 0; in check_tape()
1035 STp->ps[0].drv_file = STp->ps[0].drv_block = (-1); in check_tape()
1036 STp->partition = STp->new_partition = 0; in check_tape()
1037 STp->door_locked = ST_UNLOCKED; in check_tape()
1042 if (STp->omit_blklims) in check_tape()
1043 STp->min_block = STp->max_block = (-1); in check_tape()
1048 SRpnt = st_do_scsi(SRpnt, STp, cmd, 6, DMA_FROM_DEVICE, in check_tape()
1049 STp->device->request_queue->rq_timeout, in check_tape()
1052 retval = (STp->buffer)->syscall_result; in check_tape()
1056 if (!SRpnt->result && !STp->buffer->cmdstat.have_sense) { in check_tape()
1057 STp->max_block = ((STp->buffer)->b_data[1] << 16) | in check_tape()
1058 ((STp->buffer)->b_data[2] << 8) | (STp->buffer)->b_data[3]; in check_tape()
1059 STp->min_block = ((STp->buffer)->b_data[4] << 8) | in check_tape()
1060 (STp->buffer)->b_data[5]; in check_tape()
1061 if ( DEB( debugging || ) !STp->inited) in check_tape()
1064 STp->min_block, STp->max_block); in check_tape()
1066 STp->min_block = STp->max_block = (-1); in check_tape()
1076 SRpnt = st_do_scsi(SRpnt, STp, cmd, 12, DMA_FROM_DEVICE, in check_tape()
1077 STp->device->request_queue->rq_timeout, in check_tape()
1080 retval = (STp->buffer)->syscall_result; in check_tape()
1084 if ((STp->buffer)->syscall_result != 0) { in check_tape()
1086 STp->block_size = ST_DEFAULT_BLOCK; /* Educated guess (?) */ in check_tape()
1087 (STp->buffer)->syscall_result = 0; /* Prevent error propagation */ in check_tape()
1088 STp->drv_write_prot = 0; in check_tape()
1093 (STp->buffer)->b_data[0], (STp->buffer)->b_data[1], in check_tape()
1094 (STp->buffer)->b_data[2], (STp->buffer)->b_data[3])); in check_tape()
1096 if ((STp->buffer)->b_data[3] >= 8) { in check_tape()
1097 STp->drv_buffer = ((STp->buffer)->b_data[2] >> 4) & 7; in check_tape()
1098 STp->density = (STp->buffer)->b_data[4]; in check_tape()
1099 STp->block_size = (STp->buffer)->b_data[9] * 65536 + in check_tape()
1100 (STp->buffer)->b_data[10] * 256 + (STp->buffer)->b_data[11]; in check_tape()
1103 name, STp->density, (STp->buffer)->b_data[5] * 65536 + in check_tape()
1104 (STp->buffer)->b_data[6] * 256 + (STp->buffer)->b_data[7], in check_tape()
1105 STp->drv_buffer)); in check_tape()
1107 STp->drv_write_prot = ((STp->buffer)->b_data[2] & 0x80) != 0; in check_tape()
1108 if (!STp->drv_buffer && STp->immediate_filemark) { in check_tape()
1112 STp->immediate_filemark = 0; in check_tape()
1117 STp->inited = 1; in check_tape()
1119 if (STp->block_size > 0) in check_tape()
1120 (STp->buffer)->buffer_blocks = in check_tape()
1121 (STp->buffer)->buffer_size / STp->block_size; in check_tape()
1123 (STp->buffer)->buffer_blocks = 1; in check_tape()
1124 (STp->buffer)->buffer_bytes = (STp->buffer)->read_pointer = 0; in check_tape()
1128 STp->block_size, (STp->buffer)->buffer_size, in check_tape()
1129 (STp->buffer)->buffer_blocks)); in check_tape()
1131 if (STp->drv_write_prot) { in check_tape()
1132 STp->write_prot = 1; in check_tape()
1144 if (STp->can_partitions && STp->nbr_partitions < 1) { in check_tape()
1150 if ((STp->partition = find_partition(STp)) < 0) { in check_tape()
1151 retval = STp->partition; in check_tape()
1154 STp->new_partition = STp->partition; in check_tape()
1155 STp->nbr_partitions = 1; /* This guess will be updated when necessary */ in check_tape()
1159 STp->density_changed = STp->blksize_changed = 0; in check_tape()
1160 STp->compression_changed = 0; in check_tape()
1162 (retval = set_mode_densblk(STp, STm)) < 0) in check_tape()
1165 if (STp->default_drvbuffer != 0xff) { in check_tape()
1166 if (st_int_ioctl(STp, MTSETDRVBUFFER, STp->default_drvbuffer)) in check_tape()
1169 name, STp->default_drvbuffer); in check_tape()
1186 struct scsi_tape *STp; in st_open() local
1199 if (!(STp = scsi_tape_get(dev))) { in st_open()
1205 filp->private_data = STp; in st_open()
1206 name = tape_name(STp); in st_open()
1208 if (STp->in_use) { in st_open()
1210 scsi_tape_put(STp); in st_open()
1216 STp->in_use = 1; in st_open()
1218 STp->rew_at_close = STp->autorew_dev = (iminor(inode) & 0x80) == 0; in st_open()
1220 if (scsi_autopm_get_device(STp->device) < 0) { in st_open()
1225 if (!scsi_block_when_processing_errors(STp->device)) { in st_open()
1231 if (!enlarge_buffer(STp->buffer, PAGE_SIZE, STp->restr_dma)) { in st_open()
1238 (STp->buffer)->cleared = 0; in st_open()
1239 (STp->buffer)->writing = 0; in st_open()
1240 (STp->buffer)->syscall_result = 0; in st_open()
1242 STp->write_prot = ((filp->f_flags & O_ACCMODE) == O_RDONLY); in st_open()
1244 STp->dirty = 0; in st_open()
1246 STps = &(STp->ps[i]); in st_open()
1249 STp->try_dio_now = STp->try_dio; in st_open()
1250 STp->recover_count = 0; in st_open()
1251 DEB( STp->nbr_waits = STp->nbr_finished = 0; in st_open()
1252 STp->nbr_requests = STp->nbr_dio = STp->nbr_pages = 0; ) in st_open()
1254 retval = check_tape(STp, filp); in st_open()
1259 if (STp->ready == NO_TAPE) in st_open()
1269 normalize_buffer(STp->buffer); in st_open()
1270 STp->in_use = 0; in st_open()
1271 scsi_tape_put(STp); in st_open()
1273 scsi_autopm_put_device(STp->device); in st_open()
1286 struct scsi_tape *STp = filp->private_data; in st_flush() local
1287 struct st_modedef *STm = &(STp->modes[STp->current_mode]); in st_flush()
1288 struct st_partstat *STps = &(STp->ps[STp->partition]); in st_flush()
1289 char *name = tape_name(STp); in st_flush()
1294 if (STps->rw == ST_WRITING && !STp->pos_unknown) { in st_flush()
1295 result = st_flush_write_buffer(STp); in st_flush()
1300 if (STp->can_partitions && in st_flush()
1301 (result2 = switch_partition(STp)) < 0) { in st_flush()
1309 DEBC( if (STp->nbr_requests) in st_flush()
1311 name, STp->nbr_requests, STp->nbr_dio, STp->nbr_pages)); in st_flush()
1313 if (STps->rw == ST_WRITING && !STp->pos_unknown) { in st_flush()
1314 struct st_cmdstatus *cmdstatp = &STp->buffer->cmdstat; in st_flush()
1317 name, STp->nbr_waits, STp->nbr_finished); in st_flush()
1322 if (STp->immediate_filemark) in st_flush()
1324 cmd[4] = 1 + STp->two_fm; in st_flush()
1326 SRpnt = st_do_scsi(NULL, STp, cmd, 0, DMA_NONE, in st_flush()
1327 STp->device->request_queue->rq_timeout, in st_flush()
1330 result = (STp->buffer)->syscall_result; in st_flush()
1334 if (STp->buffer->syscall_result == 0 || in st_flush()
1346 if (STp->two_fm) in st_flush()
1347 cross_eof(STp, 0); in st_flush()
1360 } else if (!STp->rew_at_close) { in st_flush()
1361 STps = &(STp->ps[STp->partition]); in st_flush()
1363 if (STp->can_bsr) in st_flush()
1364 result = flush_buffer(STp, 0); in st_flush()
1366 result = cross_eof(STp, 0); in st_flush()
1376 !(result = cross_eof(STp, 1))) || in st_flush()
1386 if (STp->rew_at_close) { in st_flush()
1387 result2 = st_int_ioctl(STp, MTREW, 1); in st_flush()
1400 struct scsi_tape *STp = filp->private_data; in st_release() local
1402 if (STp->door_locked == ST_LOCKED_AUTO) in st_release()
1403 do_door_lock(STp, 0); in st_release()
1405 normalize_buffer(STp->buffer); in st_release()
1407 STp->in_use = 0; in st_release()
1409 scsi_autopm_put_device(STp->device); in st_release()
1410 scsi_tape_put(STp); in st_release()
1416 static ssize_t rw_checks(struct scsi_tape *STp, struct file *filp, size_t count) in rw_checks() argument
1426 if (!scsi_block_when_processing_errors(STp->device)) { in rw_checks()
1431 if (STp->ready != ST_READY) { in rw_checks()
1432 if (STp->ready == ST_NO_TAPE) in rw_checks()
1439 if (! STp->modes[STp->current_mode].defined) { in rw_checks()
1449 if (STp->pos_unknown) { in rw_checks()
1458 if (!STp->in_use) { in rw_checks()
1459 printk(ST_DEB_MSG "%s: Incorrect device.\n", tape_name(STp)); in rw_checks()
1464 if (STp->can_partitions && in rw_checks()
1465 (retval = switch_partition(STp)) < 0) in rw_checks()
1468 if (STp->block_size == 0 && STp->max_block > 0 && in rw_checks()
1469 (count < STp->min_block || count > STp->max_block)) { in rw_checks()
1474 if (STp->do_auto_lock && STp->door_locked == ST_UNLOCKED && in rw_checks()
1475 !do_door_lock(STp, 1)) in rw_checks()
1476 STp->door_locked = ST_LOCKED_AUTO; in rw_checks()
1483 static int setup_buffering(struct scsi_tape *STp, const char __user *buf, in setup_buffering() argument
1487 struct st_buffer *STbp = STp->buffer; in setup_buffering()
1490 i = STp->try_dio_now && try_rdio; in setup_buffering()
1492 i = STp->try_dio_now && try_wdio; in setup_buffering()
1495 STp->device->request_queue)) == 0) { in setup_buffering()
1507 STp->nbr_dio++; in setup_buffering()
1508 STp->nbr_pages += STbp->do_dio; in setup_buffering()
1513 DEB( STp->nbr_requests++; ) in setup_buffering()
1516 if (STp->block_size) in setup_buffering()
1517 bufsize = STp->block_size > st_fixed_buffer_size ? in setup_buffering()
1518 STp->block_size : st_fixed_buffer_size; in setup_buffering()
1523 if (is_read && STp->sili && !STbp->cleared) in setup_buffering()
1528 !enlarge_buffer(STbp, bufsize, STp->restr_dma)) { in setup_buffering()
1530 tape_name(STp), bufsize); in setup_buffering()
1534 if (STp->block_size) in setup_buffering()
1535 STbp->buffer_blocks = bufsize / STp->block_size; in setup_buffering()
1544 static void release_buffering(struct scsi_tape *STp, int is_read) in release_buffering() argument
1548 STbp = STp->buffer; in release_buffering()
1569 struct scsi_tape *STp = filp->private_data; in st_write() local
1573 char *name = tape_name(STp); in st_write()
1575 if (mutex_lock_interruptible(&STp->lock)) in st_write()
1578 retval = rw_checks(STp, filp, count); in st_write()
1583 if (STp->block_size != 0 && (count % STp->block_size) != 0) { in st_write()
1590 STm = &(STp->modes[STp->current_mode]); in st_write()
1591 STps = &(STp->ps[STp->partition]); in st_write()
1593 if (STp->write_prot) { in st_write()
1600 retval = flush_buffer(STp, 0); in st_write()
1606 if ((retval = set_mode_densblk(STp, STm)) < 0) in st_write()
1609 !(STp->compression_changed)) { in st_write()
1610 if (st_compression(STp, (STm->default_compression == ST_YES))) { in st_write()
1621 STbp = STp->buffer; in st_write()
1622 i = write_behind_check(STp); in st_write()
1642 if (STp->block_size != 0 && in st_write()
1650 retval = setup_buffering(STp, buf, count, 0); in st_write()
1658 cmd[1] = (STp->block_size != 0); in st_write()
1669 if (STp->block_size == 0) in st_write()
1672 do_count = STbp->buffer_blocks * STp->block_size - in st_write()
1687 async_write = STp->block_size == 0 && !STbp->do_dio && in st_write()
1690 if (STp->block_size != 0 && STm->do_buffer_writes && in st_write()
1691 !(STp->try_dio_now && try_wdio) && STps->eof < ST_EOM_OK && in st_write()
1693 STp->dirty = 1; in st_write()
1700 if (STp->block_size == 0) in st_write()
1707 blks /= STp->block_size; in st_write()
1708 transfer = blks * STp->block_size; in st_write()
1714 SRpnt = st_do_scsi(SRpnt, STp, cmd, transfer, DMA_TO_DEVICE, in st_write()
1715 STp->device->request_queue->rq_timeout, in st_write()
1723 STp->dirty = !(STbp->writing == in st_write()
1726 DEB( STp->write_pending = 1; ) in st_write()
1731 struct st_cmdstatus *cmdstatp = &STp->buffer->cmdstat; in st_write()
1738 else if (STp->block_size == 0 && in st_write()
1743 if (STp->block_size != 0) in st_write()
1744 undone *= STp->block_size; in st_write()
1750 if (STp->block_size) in st_write()
1751 blks = (transfer - undone) / STp->block_size; in st_write()
1757 if (STp->block_size == 0 || in st_write()
1768 move_buffer_data(STp->buffer, transfer - undone); in st_write()
1772 STp->block_size; in st_write()
1777 name, STp->buffer->buffer_bytes)); in st_write()
1802 if (STp->block_size == 0) in st_write()
1809 STp->dirty = 0; in st_write()
1827 release_buffering(STp, 0); in st_write()
1828 mutex_unlock(&STp->lock); in st_write()
1839 static long read_tape(struct scsi_tape *STp, long count, in read_tape() argument
1849 char *name = tape_name(STp); in read_tape()
1854 STm = &(STp->modes[STp->current_mode]); in read_tape()
1855 STps = &(STp->ps[STp->partition]); in read_tape()
1858 STbp = STp->buffer; in read_tape()
1860 if (STp->block_size == 0) in read_tape()
1863 if (!(STp->try_dio_now && try_rdio) && STm->do_read_ahead) { in read_tape()
1864 blks = (STp->buffer)->buffer_blocks; in read_tape()
1865 bytes = blks * STp->block_size; in read_tape()
1868 if (!STbp->do_dio && bytes > (STp->buffer)->buffer_size) in read_tape()
1869 bytes = (STp->buffer)->buffer_size; in read_tape()
1870 blks = bytes / STp->block_size; in read_tape()
1871 bytes = blks * STp->block_size; in read_tape()
1877 cmd[1] = (STp->block_size != 0); in read_tape()
1878 if (!cmd[1] && STp->sili) in read_tape()
1885 SRpnt = st_do_scsi(SRpnt, STp, cmd, bytes, DMA_FROM_DEVICE, in read_tape()
1886 STp->device->request_queue->rq_timeout, in read_tape()
1888 release_buffering(STp, 1); in read_tape()
1898 struct st_cmdstatus *cmdstatp = &STp->buffer->cmdstat; in read_tape()
1918 if (STp->block_size == 0 && in read_tape()
1923 if (STp->block_size == 0) { in read_tape()
1942 st_int_ioctl(STp, MTBSR, 1); in read_tape()
1947 STp->block_size; in read_tape()
1953 if (st_int_ioctl(STp, MTBSR, 1)) in read_tape()
1961 if (STp->block_size == 0) in read_tape()
1965 bytes - transfer * STp->block_size; in read_tape()
1974 if (STp->block_size == 0) in read_tape()
1978 bytes - transfer * STp->block_size; in read_tape()
2011 if (STp->sili) /* In fixed block mode residual is always zero here */ in read_tape()
2012 STbp->buffer_bytes -= STp->buffer->cmdstat.residual; in read_tape()
2016 if (STp->block_size == 0) in read_tape()
2019 STps->drv_block += STbp->buffer_bytes / STp->block_size; in read_tape()
2034 struct scsi_tape *STp = filp->private_data; in st_read() local
2037 struct st_buffer *STbp = STp->buffer; in st_read()
2038 DEB( char *name = tape_name(STp); ) in st_read()
2040 if (mutex_lock_interruptible(&STp->lock)) in st_read()
2043 retval = rw_checks(STp, filp, count); in st_read()
2047 STm = &(STp->modes[STp->current_mode]); in st_read()
2048 if (STp->block_size != 0 && (count % STp->block_size) != 0) { in st_read()
2053 STp->try_dio_now = 0; /* Direct i/o can't handle split blocks */ in st_read()
2056 STps = &(STp->ps[STp->partition]); in st_read()
2058 retval = flush_buffer(STp, 0); in st_read()
2069 retval = setup_buffering(STp, buf, count, 1); in st_read()
2105 special = read_tape(STp, count - total, &SRpnt); in st_read()
2134 if (STp->block_size == 0) in st_read()
2164 release_buffering(STp, 1); in st_read()
2167 mutex_unlock(&STp->lock); in st_read()
2176 static void st_log_options(struct scsi_tape * STp, struct st_modedef * STm, char *name) in DEB() argument
2181 name, STp->current_mode, STm->do_buffer_writes, STm->do_async_writes, in DEB()
2185 name, STp->can_bsr, STp->two_fm, STp->fast_mteom, STp->do_auto_lock); in DEB()
2188 name, STm->defaults_for_writes, STp->omit_blklims, STp->can_partitions, in DEB()
2189 STp->scsi2_logical); in DEB()
2192 name, STm->sysv, STp->immediate, STp->sili, in DEB()
2193 STp->immediate_filemark); in DEB()
2201 static int st_set_options(struct scsi_tape *STp, long options)
2206 char *name = tape_name(STp);
2209 STm = &(STp->modes[STp->current_mode]);
2212 memcpy(STm, &(STp->modes[0]), sizeof(struct st_modedef));
2217 name, STp->current_mode));
2226 STp->two_fm = (options & MT_ST_TWO_FM) != 0;
2227 STp->fast_mteom = (options & MT_ST_FAST_MTEOM) != 0;
2228 STp->do_auto_lock = (options & MT_ST_AUTO_LOCK) != 0;
2229 STp->can_bsr = (options & MT_ST_CAN_BSR) != 0;
2230 STp->omit_blklims = (options & MT_ST_NO_BLKLIMS) != 0;
2231 if ((STp->device)->scsi_level >= SCSI_2)
2232 STp->can_partitions = (options & MT_ST_CAN_PARTITIONS) != 0;
2233 STp->scsi2_logical = (options & MT_ST_SCSI2LOGICAL) != 0;
2234 STp->immediate = (options & MT_ST_NOWAIT) != 0;
2235 STp->immediate_filemark = (options & MT_ST_NOWAIT_EOF) != 0;
2237 STp->sili = (options & MT_ST_SILI) != 0;
2239 st_log_options(STp, STm, name); )
2251 STp->two_fm = value;
2253 STp->fast_mteom = value;
2255 STp->do_auto_lock = value;
2257 STp->can_bsr = value;
2259 STp->omit_blklims = value;
2260 if ((STp->device)->scsi_level >= SCSI_2 &&
2262 STp->can_partitions = value;
2264 STp->scsi2_logical = value;
2266 STp->immediate = value;
2268 STp->immediate_filemark = value;
2272 STp->sili = value;
2276 st_log_options(STp, STm, name); )
2288 if (STp->ready == ST_READY) {
2289 STp->blksize_changed = 0;
2290 set_mode_densblk(STp, STm);
2296 STp->long_timeout = (value & ~MT_ST_SET_LONG_TIMEOUT) * HZ;
2300 blk_queue_rq_timeout(STp->device->request_queue,
2311 STp->cln_mode = value;
2312 STp->cln_sense_mask = (options >> 8) & 0xff;
2313 STp->cln_sense_value = (options >> 16) & 0xff;
2316 name, value, STp->cln_sense_mask, STp->cln_sense_value);
2329 if (STp->ready == ST_READY) {
2330 STp->density_changed = 0;
2331 set_mode_densblk(STp, STm);
2336 STp->default_drvbuffer = 0xff;
2340 STp->default_drvbuffer = value & 7;
2343 name, STp->default_drvbuffer));
2344 if (STp->ready == ST_READY)
2345 st_int_ioctl(STp, MTSETDRVBUFFER, STp->default_drvbuffer);
2354 STp->c_algo = (value & 0xff00) >> 8;
2356 name, STp->c_algo));
2362 if (STp->ready == ST_READY) {
2363 STp->compression_changed = 0;
2364 st_compression(STp, (STm->default_compression == ST_YES));
2397 static int read_mode_page(struct scsi_tape *STp, int page, int omit_block_descs) in read_mode_page() argument
2409 SRpnt = st_do_scsi(NULL, STp, cmd, cmd[4], DMA_FROM_DEVICE, in read_mode_page()
2410 STp->device->request_queue->rq_timeout, 0, 1); in read_mode_page()
2412 return (STp->buffer)->syscall_result; in read_mode_page()
2416 return STp->buffer->syscall_result; in read_mode_page()
2422 static int write_mode_page(struct scsi_tape *STp, int page, int slow) in write_mode_page() argument
2432 pgo = MODE_HEADER_LENGTH + (STp->buffer)->b_data[MH_OFF_BDESCS_LENGTH]; in write_mode_page()
2433 cmd[4] = pgo + (STp->buffer)->b_data[pgo + MP_OFF_PAGE_LENGTH] + 2; in write_mode_page()
2436 (STp->buffer)->b_data[MH_OFF_DATA_LENGTH] = 0; in write_mode_page()
2437 (STp->buffer)->b_data[MH_OFF_MEDIUM_TYPE] = 0; in write_mode_page()
2438 (STp->buffer)->b_data[MH_OFF_DEV_SPECIFIC] &= ~MH_BIT_WP; in write_mode_page()
2439 (STp->buffer)->b_data[pgo + MP_OFF_PAGE_NBR] &= MP_MSK_PAGE_NBR; in write_mode_page()
2442 STp->long_timeout : STp->device->request_queue->rq_timeout; in write_mode_page()
2443 SRpnt = st_do_scsi(NULL, STp, cmd, cmd[4], DMA_TO_DEVICE, in write_mode_page()
2446 return (STp->buffer)->syscall_result; in write_mode_page()
2450 return STp->buffer->syscall_result; in write_mode_page()
2471 static int st_compression(struct scsi_tape * STp, int state) in st_compression() argument
2475 unsigned char *b_data = (STp->buffer)->b_data; in st_compression()
2476 DEB( char *name = tape_name(STp); ) in st_compression()
2478 if (STp->ready != ST_READY) in st_compression()
2482 retval = read_mode_page(STp, COMPRESSION_PAGE, 0); in st_compression()
2502 if (STp->c_algo != 0) in st_compression()
2503 b_data[mpoffs + CP_OFF_C_ALGO] = STp->c_algo; in st_compression()
2507 if (STp->c_algo != 0) in st_compression()
2511 retval = write_mode_page(STp, COMPRESSION_PAGE, 0); in st_compression()
2519 STp->compression_changed = 1; in st_compression()
2525 static int do_load_unload(struct scsi_tape *STp, struct file *filp, int load_code) in do_load_unload() argument
2528 DEB( char *name = tape_name(STp); ) in do_load_unload()
2533 if (STp->ready != ST_READY && !load_code) { in do_load_unload()
2534 if (STp->ready == ST_NO_TAPE) in do_load_unload()
2554 if (STp->immediate) { in do_load_unload()
2556 timeout = STp->device->request_queue->rq_timeout; in do_load_unload()
2559 timeout = STp->long_timeout; in do_load_unload()
2568 SRpnt = st_do_scsi(NULL, STp, cmd, 0, DMA_NONE, in do_load_unload()
2571 return (STp->buffer)->syscall_result; in do_load_unload()
2573 retval = (STp->buffer)->syscall_result; in do_load_unload()
2579 STp->rew_at_close = 0; in do_load_unload()
2580 STp->ready = ST_NO_TAPE; in do_load_unload()
2583 STp->rew_at_close = STp->autorew_dev; in do_load_unload()
2584 retval = check_tape(STp, filp); in do_load_unload()
2590 STps = &(STp->ps[STp->partition]); in do_load_unload()
2615 static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned long arg) in st_int_ioctl() argument
2626 char *name = tape_name(STp); in st_int_ioctl()
2628 WARN_ON(STp->buffer->do_dio != 0); in st_int_ioctl()
2629 if (STp->ready != ST_READY) { in st_int_ioctl()
2630 if (STp->ready == ST_NO_TAPE) in st_int_ioctl()
2635 timeout = STp->long_timeout; in st_int_ioctl()
2636 STps = &(STp->ps[STp->partition]); in st_int_ioctl()
2723 if (STp->write_prot) in st_int_ioctl()
2729 (cmd_in == MTWEOF && STp->immediate_filemark)) in st_int_ioctl()
2734 timeout = STp->device->request_queue->rq_timeout; in st_int_ioctl()
2750 if (STp->immediate) { in st_int_ioctl()
2752 timeout = STp->device->request_queue->rq_timeout; in st_int_ioctl()
2763 if (STp->immediate) { in st_int_ioctl()
2765 timeout = STp->device->request_queue->rq_timeout; in st_int_ioctl()
2772 if (!STp->fast_mteom) { in st_int_ioctl()
2774 ioctl_result = st_int_ioctl(STp, MTFSF, 0x7fffff); in st_int_ioctl()
2792 if (STp->write_prot) in st_int_ioctl()
2796 if (STp->immediate) { in st_int_ioctl()
2798 timeout = STp->device->request_queue->rq_timeout; in st_int_ioctl()
2801 timeout = STp->long_timeout * 8; in st_int_ioctl()
2811 if (STp->dirty || (STp->buffer)->buffer_bytes != 0) in st_int_ioctl()
2815 STp->max_block > 0 && in st_int_ioctl()
2816 ((arg & MT_ST_BLKSIZE_MASK) < STp->min_block || in st_int_ioctl()
2817 (arg & MT_ST_BLKSIZE_MASK) > STp->max_block)) { in st_int_ioctl()
2822 if ((STp->use_pf & USE_PF)) in st_int_ioctl()
2827 memset((STp->buffer)->b_data, 0, 12); in st_int_ioctl()
2829 (STp->buffer)->b_data[2] = (arg & 7) << 4; in st_int_ioctl()
2831 (STp->buffer)->b_data[2] = in st_int_ioctl()
2832 STp->drv_buffer << 4; in st_int_ioctl()
2833 (STp->buffer)->b_data[3] = 8; /* block descriptor length */ in st_int_ioctl()
2835 (STp->buffer)->b_data[4] = arg; in st_int_ioctl()
2836 STp->density_changed = 1; /* At least we tried ;-) */ in st_int_ioctl()
2838 (STp->buffer)->b_data[4] = arg >> 24; in st_int_ioctl()
2840 (STp->buffer)->b_data[4] = STp->density; in st_int_ioctl()
2844 STp->blksize_changed = 1; /* At least we tried ;-) */ in st_int_ioctl()
2846 ltmp = STp->block_size; in st_int_ioctl()
2847 (STp->buffer)->b_data[9] = (ltmp >> 16); in st_int_ioctl()
2848 (STp->buffer)->b_data[10] = (ltmp >> 8); in st_int_ioctl()
2849 (STp->buffer)->b_data[11] = ltmp; in st_int_ioctl()
2850 timeout = STp->device->request_queue->rq_timeout; in st_int_ioctl()
2855 (STp->buffer)->b_data[9] * 65536 + in st_int_ioctl()
2856 (STp->buffer)->b_data[10] * 256 + in st_int_ioctl()
2857 (STp->buffer)->b_data[11]); in st_int_ioctl()
2861 (STp->buffer)->b_data[4]); in st_int_ioctl()
2865 ((STp->buffer)->b_data[2] >> 4) & 7); in st_int_ioctl()
2872 SRpnt = st_do_scsi(NULL, STp, cmd, datalen, direction, in st_int_ioctl()
2875 return (STp->buffer)->syscall_result; in st_int_ioctl()
2877 ioctl_result = (STp->buffer)->syscall_result; in st_int_ioctl()
2887 ioctl_result = st_int_ioctl(STp, MTFSF, 1); in st_int_ioctl()
2889 ioctl_result = st_int_ioctl(STp, MTBSF, 1); in st_int_ioctl()
2892 STp->block_size = arg & MT_ST_BLKSIZE_MASK; in st_int_ioctl()
2893 if (STp->block_size != 0) { in st_int_ioctl()
2894 (STp->buffer)->buffer_blocks = in st_int_ioctl()
2895 (STp->buffer)->buffer_size / STp->block_size; in st_int_ioctl()
2897 (STp->buffer)->buffer_bytes = (STp->buffer)->read_pointer = 0; in st_int_ioctl()
2899 STp->density = arg >> MT_ST_DENSITY_SHIFT; in st_int_ioctl()
2901 STp->drv_buffer = (arg & 7); in st_int_ioctl()
2903 STp->density = arg; in st_int_ioctl()
2916 struct st_cmdstatus *cmdstatp = &STp->buffer->cmdstat; in st_int_ioctl()
2991 !(STp->use_pf & PF_TESTED)) { in st_int_ioctl()
2994 STp->use_pf = (STp->use_pf ^ USE_PF) | PF_TESTED; in st_int_ioctl()
2997 return st_int_ioctl(STp, cmd_in, arg); in st_int_ioctl()
3016 static int get_location(struct scsi_tape *STp, unsigned int *block, int *partition, in get_location() argument
3022 DEB( char *name = tape_name(STp); ) in get_location()
3024 if (STp->ready != ST_READY) in get_location()
3028 if ((STp->device)->scsi_level < SCSI_2) { in get_location()
3033 if (!logical && !STp->scsi2_logical) in get_location()
3036 SRpnt = st_do_scsi(NULL, STp, scmd, 20, DMA_FROM_DEVICE, in get_location()
3037 STp->device->request_queue->rq_timeout, in get_location()
3040 return (STp->buffer)->syscall_result; in get_location()
3042 if ((STp->buffer)->syscall_result != 0 || in get_location()
3043 (STp->device->scsi_level >= SCSI_2 && in get_location()
3044 ((STp->buffer)->b_data[0] & 4) != 0)) { in get_location()
3050 if ((STp->device)->scsi_level < SCSI_2) { in get_location()
3051 *block = ((STp->buffer)->b_data[0] << 16) in get_location()
3052 + ((STp->buffer)->b_data[1] << 8) in get_location()
3053 + (STp->buffer)->b_data[2]; in get_location()
3056 *block = ((STp->buffer)->b_data[4] << 24) in get_location()
3057 + ((STp->buffer)->b_data[5] << 16) in get_location()
3058 + ((STp->buffer)->b_data[6] << 8) in get_location()
3059 + (STp->buffer)->b_data[7]; in get_location()
3060 *partition = (STp->buffer)->b_data[1]; in get_location()
3061 if (((STp->buffer)->b_data[0] & 0x80) && in get_location()
3062 (STp->buffer)->b_data[1] == 0) /* BOP of partition 0 */ in get_location()
3063 STp->ps[0].drv_block = STp->ps[0].drv_file = 0; in get_location()
3077 static int set_location(struct scsi_tape *STp, unsigned int block, int partition, in set_location() argument
3086 DEB( char *name = tape_name(STp); ) in set_location()
3088 if (STp->ready != ST_READY) in set_location()
3090 timeout = STp->long_timeout; in set_location()
3091 STps = &(STp->ps[STp->partition]); in set_location()
3099 if ((!STp->can_partitions && partition != 0) || in set_location()
3102 if (partition != STp->partition) { in set_location()
3103 if (get_location(STp, &blk, &p, 1)) in set_location()
3110 name, blk, STp->partition)); in set_location()
3115 if ((STp->device)->scsi_level < SCSI_2) { in set_location()
3127 if (!logical && !STp->scsi2_logical) in set_location()
3129 if (STp->partition != partition) { in set_location()
3134 name, STp->partition, partition)); in set_location()
3137 if (STp->immediate) { in set_location()
3139 timeout = STp->device->request_queue->rq_timeout; in set_location()
3142 SRpnt = st_do_scsi(NULL, STp, scmd, 0, DMA_NONE, in set_location()
3145 return (STp->buffer)->syscall_result; in set_location()
3149 if ((STp->buffer)->syscall_result != 0) { in set_location()
3151 if (STp->can_partitions && in set_location()
3152 (STp->device)->scsi_level >= SCSI_2 && in set_location()
3153 (p = find_partition(STp)) >= 0) in set_location()
3154 STp->partition = p; in set_location()
3156 if (STp->can_partitions) { in set_location()
3157 STp->partition = partition; in set_location()
3158 STps = &(STp->ps[partition]); in set_location()
3180 static int find_partition(struct scsi_tape *STp) in find_partition() argument
3185 if ((i = get_location(STp, &block, &partition, 1)) < 0) in find_partition()
3194 static int switch_partition(struct scsi_tape *STp) in switch_partition() argument
3198 if (STp->partition == STp->new_partition) in switch_partition()
3200 STps = &(STp->ps[STp->new_partition]); in switch_partition()
3203 return set_location(STp, STps->last_block_visited, STp->new_partition, 1); in switch_partition()
3222 static int nbr_partitions(struct scsi_tape *STp) in nbr_partitions() argument
3225 DEB( char *name = tape_name(STp); ) in nbr_partitions()
3227 if (STp->ready != ST_READY) in nbr_partitions()
3230 result = read_mode_page(STp, PART_PAGE, 1); in nbr_partitions()
3237 result = (STp->buffer)->b_data[MODE_HEADER_LENGTH + in nbr_partitions()
3265 static int partition_tape(struct scsi_tape *STp, int size) in partition_tape() argument
3267 char *name = tape_name(STp); in partition_tape()
3272 result = read_mode_page(STp, PART_PAGE, 0); in partition_tape()
3278 bp = (STp->buffer)->b_data; in partition_tape()
3315 result = write_mode_page(STp, PART_PAGE, 1); in partition_tape()
3332 struct scsi_tape *STp = file->private_data; in st_ioctl() local
3335 char *name = tape_name(STp); in st_ioctl()
3338 if (mutex_lock_interruptible(&STp->lock)) in st_ioctl()
3342 if (debugging && !STp->in_use) { in st_ioctl()
3348 STm = &(STp->modes[STp->current_mode]); in st_ioctl()
3349 STps = &(STp->ps[STp->partition]); in st_ioctl()
3357 retval = scsi_nonblockable_ioctl(STp->device, cmd_in, p, in st_ioctl()
3359 if (!scsi_block_when_processing_errors(STp->device) || retval != -ENODEV) in st_ioctl()
3393 if (!STp->pos_unknown) { in st_ioctl()
3411 i = !STp->can_partitions || in st_ioctl()
3412 (STp->new_partition != STp->partition); in st_ioctl()
3421 i = flush_buffer(STp, i); in st_ioctl()
3430 i = st_int_ioctl(STp, MTWEOF, 1); in st_ioctl()
3455 reset_state(STp); in st_ioctl()
3457 STp->device->was_reset = 0; in st_ioctl()
3465 if (mtc.mt_op == MTOFFL && STp->door_locked != ST_UNLOCKED) in st_ioctl()
3466 do_door_lock(STp, 0); /* Ignore result! */ in st_ioctl()
3470 retval = st_set_options(STp, mtc.mt_count); in st_ioctl()
3475 if (!STp->can_partitions || in st_ioctl()
3480 if (mtc.mt_count >= STp->nbr_partitions && in st_ioctl()
3481 (STp->nbr_partitions = nbr_partitions(STp)) < 0) { in st_ioctl()
3485 if (mtc.mt_count >= STp->nbr_partitions) { in st_ioctl()
3489 STp->new_partition = mtc.mt_count; in st_ioctl()
3495 if (!STp->can_partitions) { in st_ioctl()
3499 if ((i = st_int_ioctl(STp, MTREW, 0)) < 0 || in st_ioctl()
3500 (i = partition_tape(STp, mtc.mt_count)) < 0) { in st_ioctl()
3505 STp->ps[i].rw = ST_IDLE; in st_ioctl()
3506 STp->ps[i].at_sm = 0; in st_ioctl()
3507 STp->ps[i].last_block_valid = 0; in st_ioctl()
3509 STp->partition = STp->new_partition = 0; in st_ioctl()
3510 STp->nbr_partitions = 1; /* Bad guess ?-) */ in st_ioctl()
3517 i = set_location(STp, mtc.mt_count, STp->new_partition, 0); in st_ioctl()
3518 if (!STp->can_partitions) in st_ioctl()
3519 STp->ps[0].rw = ST_IDLE; in st_ioctl()
3525 retval = do_load_unload(STp, file, 0); in st_ioctl()
3530 retval = do_load_unload(STp, file, max(1, mtc.mt_count)); in st_ioctl()
3535 retval = do_door_lock(STp, (mtc.mt_op == MTLOCK)); in st_ioctl()
3539 if (STp->can_partitions && STp->ready == ST_READY && in st_ioctl()
3540 (i = switch_partition(STp)) < 0) { in st_ioctl()
3546 retval = st_compression(STp, (mtc.mt_count & 1)); in st_ioctl()
3548 retval = st_int_ioctl(STp, mtc.mt_op, mtc.mt_count); in st_ioctl()
3556 if ((i = flush_buffer(STp, 0)) < 0) { in st_ioctl()
3560 if (STp->can_partitions && in st_ioctl()
3561 (i = switch_partition(STp)) < 0) { in st_ioctl()
3574 mt_status.mt_type = STp->tape_type; in st_ioctl()
3576 ((STp->block_size << MT_ST_BLKSIZE_SHIFT) & MT_ST_BLKSIZE_MASK) | in st_ioctl()
3577 ((STp->density << MT_ST_DENSITY_SHIFT) & MT_ST_DENSITY_MASK); in st_ioctl()
3580 if (STp->block_size != 0) { in st_ioctl()
3583 (STp->buffer)->buffer_bytes / STp->block_size; in st_ioctl()
3586 ((STp->buffer)->buffer_bytes + in st_ioctl()
3587 STp->block_size - 1) / STp->block_size; in st_ioctl()
3591 if (STp->drv_write_prot) in st_ioctl()
3599 mt_status.mt_erreg = (STp->recover_reg << MT_ST_SOFTERR_SHIFT); in st_ioctl()
3600 mt_status.mt_resid = STp->partition; in st_ioctl()
3605 if (STp->density == 1) in st_ioctl()
3607 else if (STp->density == 2) in st_ioctl()
3609 else if (STp->density == 3) in st_ioctl()
3611 if (STp->ready == ST_READY) in st_ioctl()
3613 if (STp->ready == ST_NO_TAPE) in st_ioctl()
3618 (STm->do_buffer_writes && STp->block_size != 0) || in st_ioctl()
3619 STp->drv_buffer != 0) in st_ioctl()
3621 if (STp->cleaning_req) in st_ioctl()
3630 STp->recover_reg = 0; /* Clear after read */ in st_ioctl()
3640 if ((i = get_location(STp, &blk, &bt, 0)) < 0) { in st_ioctl()
3650 mutex_unlock(&STp->lock); in st_ioctl()
3662 i = scsi_cmd_ioctl(STp->disk->queue, STp->disk, in st_ioctl()
3668 retval = scsi_ioctl(STp->device, cmd_in, p); in st_ioctl()
3670 STp->rew_at_close = 0; in st_ioctl()
3671 STp->ready = ST_NO_TAPE; in st_ioctl()
3676 mutex_unlock(&STp->lock); in st_ioctl()
3683 struct scsi_tape *STp = file->private_data; in st_compat_ioctl() local
3684 struct scsi_device *sdev = STp->device; in st_compat_ioctl()
4465 struct scsi_tape *STp; in st_options_show() local
4479 STp = scsi_tapes[i]; in st_options_show()
4485 options |= STp->two_fm ? MT_ST_TWO_FM : 0; in st_options_show()
4486 options |= STp->fast_mteom ? MT_ST_FAST_MTEOM : 0; in st_options_show()
4488 options |= STp->can_bsr ? MT_ST_CAN_BSR : 0; in st_options_show()
4489 options |= STp->omit_blklims ? MT_ST_NO_BLKLIMS : 0; in st_options_show()
4490 options |= STp->can_partitions ? MT_ST_CAN_PARTITIONS : 0; in st_options_show()
4491 options |= STp->scsi2_logical ? MT_ST_SCSI2LOGICAL : 0; in st_options_show()
4493 options |= STp->immediate ? MT_ST_NOWAIT : 0; in st_options_show()
4494 options |= STp->immediate_filemark ? MT_ST_NOWAIT_EOF : 0; in st_options_show()
4495 options |= STp->sili ? MT_ST_SILI : 0; in st_options_show()
4503 static int do_create_class_files(struct scsi_tape *STp, int dev_num, int mode) in do_create_class_files() argument
4514 STp->disk->disk_name, st_formats[i]); in do_create_class_files()
4516 device_create(st_sysfs_class, &STp->device->sdev_gendev, in do_create_class_files()
4519 &STp->modes[mode], "%s", name); in do_create_class_files()
4544 error = sysfs_create_link(&STp->device->sdev_gendev.kobj, in do_create_class_files()