aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/st.c
diff options
context:
space:
mode:
authorHannes Reinecke <hare@suse.de>2014-06-25 10:39:57 -0400
committerChristoph Hellwig <hch@lst.de>2014-07-17 16:07:41 -0400
commitb30d8bca5b525ba557e2fd0dcad5e6e5a2cc58a7 (patch)
tree565a5894aa1be792195de536c2f1d99e12148bf8 /drivers/scsi/st.c
parent28c31729c890ca28feb8e279828203d0579df4ba (diff)
scsi: Implement st_printk()
Update the st driver to use dev_printk() variants instead of plain printk(); this will prefix logging messages with the appropriate device. Signed-off-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'drivers/scsi/st.c')
-rw-r--r--drivers/scsi/st.c605
1 files changed, 311 insertions, 294 deletions
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 14eb4b256a03..aff9689de0f7 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -58,11 +58,11 @@ static const char *verstr = "20101219";
58 is defined and non-zero. */ 58 is defined and non-zero. */
59#define DEBUG 0 59#define DEBUG 0
60 60
61#define ST_DEB_MSG KERN_NOTICE
61#if DEBUG 62#if DEBUG
62/* The message level for the debug messages is currently set to KERN_NOTICE 63/* The message level for the debug messages is currently set to KERN_NOTICE
63 so that people can easily see the messages. Later when the debugging messages 64 so that people can easily see the messages. Later when the debugging messages
64 in the drivers are more widely classified, this may be changed to KERN_DEBUG. */ 65 in the drivers are more widely classified, this may be changed to KERN_DEBUG. */
65#define ST_DEB_MSG KERN_NOTICE
66#define DEB(a) a 66#define DEB(a) a
67#define DEBC(a) if (debugging) { a ; } 67#define DEBC(a) if (debugging) { a ; }
68#else 68#else
@@ -305,6 +305,15 @@ static inline char *tape_name(struct scsi_tape *tape)
305 return tape->disk->disk_name; 305 return tape->disk->disk_name;
306} 306}
307 307
308#define st_printk(prefix, t, fmt, a...) \
309 sdev_printk(prefix, (t)->device, "%s: " fmt, \
310 tape_name(t), ##a)
311#ifdef DEBUG
312#define DEBC_printk(t, fmt, a...) \
313 if (debugging) { st_printk(ST_DEB_MSG, t, fmt, ##a ); }
314#else
315#define DEBC_printk(t, fmt, a...)
316#endif
308 317
309static void st_analyze_sense(struct st_request *SRpnt, struct st_cmdstatus *s) 318static void st_analyze_sense(struct st_request *SRpnt, struct st_cmdstatus *s)
310{ 319{
@@ -358,21 +367,20 @@ static int st_chk_result(struct scsi_tape *STp, struct st_request * SRpnt)
358 else 367 else
359 scode = 0; 368 scode = 0;
360 369
361 DEB( 370 DEB(
362 if (debugging) { 371 if (debugging) {
363 printk(ST_DEB_MSG "%s: Error: %x, cmd: %x %x %x %x %x %x\n", 372 st_printk(ST_DEB_MSG, STp,
364 name, result, 373 "Error: %x, cmd: %x %x %x %x %x %x\n", result,
365 SRpnt->cmd[0], SRpnt->cmd[1], SRpnt->cmd[2], 374 SRpnt->cmd[0], SRpnt->cmd[1], SRpnt->cmd[2],
366 SRpnt->cmd[3], SRpnt->cmd[4], SRpnt->cmd[5]); 375 SRpnt->cmd[3], SRpnt->cmd[4], SRpnt->cmd[5]);
367 if (cmdstatp->have_sense) 376 if (cmdstatp->have_sense)
368 __scsi_print_sense(name, SRpnt->sense, SCSI_SENSE_BUFFERSIZE); 377 __scsi_print_sense(name, SRpnt->sense, SCSI_SENSE_BUFFERSIZE);
369 } ) /* end DEB */ 378 } ) /* end DEB */
370 if (!debugging) { /* Abnormal conditions for tape */ 379 if (!debugging) { /* Abnormal conditions for tape */
371 if (!cmdstatp->have_sense) 380 if (!cmdstatp->have_sense)
372 printk(KERN_WARNING 381 st_printk(KERN_WARNING, STp,
373 "%s: Error %x (driver bt 0x%x, host bt 0x%x).\n", 382 "Error %x (driver bt 0x%x, host bt 0x%x).\n",
374 name, result, driver_byte(result), 383 result, driver_byte(result), host_byte(result));
375 host_byte(result));
376 else if (cmdstatp->have_sense && 384 else if (cmdstatp->have_sense &&
377 scode != NO_SENSE && 385 scode != NO_SENSE &&
378 scode != RECOVERED_ERROR && 386 scode != RECOVERED_ERROR &&
@@ -411,7 +419,7 @@ static int st_chk_result(struct scsi_tape *STp, struct st_request * SRpnt)
411 STp->recover_count++; 419 STp->recover_count++;
412 STp->recover_reg++; 420 STp->recover_reg++;
413 421
414 DEB( 422 DEB(
415 if (debugging) { 423 if (debugging) {
416 if (SRpnt->cmd[0] == READ_6) 424 if (SRpnt->cmd[0] == READ_6)
417 stp = "read"; 425 stp = "read";
@@ -419,8 +427,9 @@ static int st_chk_result(struct scsi_tape *STp, struct st_request * SRpnt)
419 stp = "write"; 427 stp = "write";
420 else 428 else
421 stp = "ioctl"; 429 stp = "ioctl";
422 printk(ST_DEB_MSG "%s: Recovered %s error (%d).\n", name, stp, 430 st_printk(ST_DEB_MSG, STp,
423 STp->recover_count); 431 "Recovered %s error (%d).\n",
432 stp, STp->recover_count);
424 } ) /* end DEB */ 433 } ) /* end DEB */
425 434
426 if (cmdstatp->flags == 0) 435 if (cmdstatp->flags == 0)
@@ -437,8 +446,8 @@ static struct st_request *st_allocate_request(struct scsi_tape *stp)
437 if (streq) 446 if (streq)
438 streq->stp = stp; 447 streq->stp = stp;
439 else { 448 else {
440 DEBC(printk(KERN_ERR "%s: Can't get SCSI request.\n", 449 st_printk(KERN_ERR, stp,
441 tape_name(stp));); 450 "Can't get SCSI request.\n");
442 if (signal_pending(current)) 451 if (signal_pending(current))
443 stp->buffer->syscall_result = -EINTR; 452 stp->buffer->syscall_result = -EINTR;
444 else 453 else
@@ -525,8 +534,8 @@ st_do_scsi(struct st_request * SRpnt, struct scsi_tape * STp, unsigned char *cmd
525 534
526 /* if async, make sure there's no command outstanding */ 535 /* if async, make sure there's no command outstanding */
527 if (!do_wait && ((STp->buffer)->last_SRpnt)) { 536 if (!do_wait && ((STp->buffer)->last_SRpnt)) {
528 printk(KERN_ERR "%s: Async command already active.\n", 537 st_printk(KERN_ERR, STp,
529 tape_name(STp)); 538 "Async command already active.\n");
530 if (signal_pending(current)) 539 if (signal_pending(current))
531 (STp->buffer)->syscall_result = (-EINTR); 540 (STp->buffer)->syscall_result = (-EINTR);
532 else 541 else
@@ -597,12 +606,12 @@ static int write_behind_check(struct scsi_tape * STp)
597 if (!STbuffer->writing) 606 if (!STbuffer->writing)
598 return 0; 607 return 0;
599 608
600 DEB( 609 DEB(
601 if (STp->write_pending) 610 if (STp->write_pending)
602 STp->nbr_waits++; 611 STp->nbr_waits++;
603 else 612 else
604 STp->nbr_finished++; 613 STp->nbr_finished++;
605 ) /* end DEB */ 614 ) /* end DEB */
606 615
607 wait_for_completion(&(STp->wait)); 616 wait_for_completion(&(STp->wait));
608 SRpnt = STbuffer->last_SRpnt; 617 SRpnt = STbuffer->last_SRpnt;
@@ -639,8 +648,9 @@ static int write_behind_check(struct scsi_tape * STp)
639 STbuffer->writing = 0; 648 STbuffer->writing = 0;
640 649
641 DEB(if (debugging && retval) 650 DEB(if (debugging && retval)
642 printk(ST_DEB_MSG "%s: Async write error %x, return value %d.\n", 651 st_printk(ST_DEB_MSG, STp,
643 tape_name(STp), STbuffer->cmdstat.midlevel_result, retval);) /* end DEB */ 652 "Async write error %x, return value %d.\n",
653 STbuffer->cmdstat.midlevel_result, retval);) /* end DEB */
644 654
645 return retval; 655 return retval;
646} 656}
@@ -662,8 +672,8 @@ static int cross_eof(struct scsi_tape * STp, int forward)
662 cmd[2] = cmd[3] = cmd[4] = 0xff; /* -1 filemarks */ 672 cmd[2] = cmd[3] = cmd[4] = 0xff; /* -1 filemarks */
663 cmd[5] = 0; 673 cmd[5] = 0;
664 674
665 DEBC(printk(ST_DEB_MSG "%s: Stepping over filemark %s.\n", 675 DEBC_printk(STp, "Stepping over filemark %s.\n",
666 tape_name(STp), forward ? "forward" : "backward")); 676 forward ? "forward" : "backward");
667 677
668 SRpnt = st_do_scsi(NULL, STp, cmd, 0, DMA_NONE, 678 SRpnt = st_do_scsi(NULL, STp, cmd, 0, DMA_NONE,
669 STp->device->request_queue->rq_timeout, 679 STp->device->request_queue->rq_timeout,
@@ -675,8 +685,9 @@ static int cross_eof(struct scsi_tape * STp, int forward)
675 SRpnt = NULL; 685 SRpnt = NULL;
676 686
677 if ((STp->buffer)->cmdstat.midlevel_result != 0) 687 if ((STp->buffer)->cmdstat.midlevel_result != 0)
678 printk(KERN_ERR "%s: Stepping over filemark %s failed.\n", 688 st_printk(KERN_ERR, STp,
679 tape_name(STp), forward ? "forward" : "backward"); 689 "Stepping over filemark %s failed.\n",
690 forward ? "forward" : "backward");
680 691
681 return (STp->buffer)->syscall_result; 692 return (STp->buffer)->syscall_result;
682} 693}
@@ -699,8 +710,7 @@ static int st_flush_write_buffer(struct scsi_tape * STp)
699 if (STp->dirty == 1) { 710 if (STp->dirty == 1) {
700 711
701 transfer = STp->buffer->buffer_bytes; 712 transfer = STp->buffer->buffer_bytes;
702 DEBC(printk(ST_DEB_MSG "%s: Flushing %d bytes.\n", 713 DEBC_printk(STp, "Flushing %d bytes.\n", transfer);
703 tape_name(STp), transfer));
704 714
705 memset(cmd, 0, MAX_COMMAND_SIZE); 715 memset(cmd, 0, MAX_COMMAND_SIZE);
706 cmd[0] = WRITE_6; 716 cmd[0] = WRITE_6;
@@ -732,8 +742,7 @@ static int st_flush_write_buffer(struct scsi_tape * STp)
732 STps->drv_block += blks; 742 STps->drv_block += blks;
733 result = (-ENOSPC); 743 result = (-ENOSPC);
734 } else { 744 } else {
735 printk(KERN_ERR "%s: Error on flush.\n", 745 st_printk(KERN_ERR, STp, "Error on flush.\n");
736 tape_name(STp));
737 STps->drv_block = (-1); 746 STps->drv_block = (-1);
738 result = (-EIO); 747 result = (-EIO);
739 } 748 }
@@ -811,7 +820,6 @@ static int set_mode_densblk(struct scsi_tape * STp, struct st_modedef * STm)
811{ 820{
812 int set_it = 0; 821 int set_it = 0;
813 unsigned long arg; 822 unsigned long arg;
814 char *name = tape_name(STp);
815 823
816 if (!STp->density_changed && 824 if (!STp->density_changed &&
817 STm->default_density >= 0 && 825 STm->default_density >= 0 &&
@@ -830,9 +838,10 @@ static int set_mode_densblk(struct scsi_tape * STp, struct st_modedef * STm)
830 arg |= STp->block_size; 838 arg |= STp->block_size;
831 if (set_it && 839 if (set_it &&
832 st_int_ioctl(STp, SET_DENS_AND_BLK, arg)) { 840 st_int_ioctl(STp, SET_DENS_AND_BLK, arg)) {
833 printk(KERN_WARNING 841 st_printk(KERN_WARNING, STp,
834 "%s: Can't set default block size to %d bytes and density %x.\n", 842 "Can't set default block size to %d bytes "
835 name, STm->default_blksize, STm->default_density); 843 "and density %x.\n",
844 STm->default_blksize, STm->default_density);
836 if (modes_defined) 845 if (modes_defined)
837 return (-EINVAL); 846 return (-EINVAL);
838 } 847 }
@@ -844,12 +853,9 @@ static int set_mode_densblk(struct scsi_tape * STp, struct st_modedef * STm)
844static int do_door_lock(struct scsi_tape * STp, int do_lock) 853static int do_door_lock(struct scsi_tape * STp, int do_lock)
845{ 854{
846 int retval, cmd; 855 int retval, cmd;
847 DEB(char *name = tape_name(STp);)
848
849 856
850 cmd = do_lock ? SCSI_IOCTL_DOORLOCK : SCSI_IOCTL_DOORUNLOCK; 857 cmd = do_lock ? SCSI_IOCTL_DOORLOCK : SCSI_IOCTL_DOORUNLOCK;
851 DEBC(printk(ST_DEB_MSG "%s: %socking drive door.\n", name, 858 DEBC_printk(STp, "%socking drive door.\n", do_lock ? "L" : "Unl");
852 do_lock ? "L" : "Unl"));
853 retval = scsi_ioctl(STp->device, cmd, NULL); 859 retval = scsi_ioctl(STp->device, cmd, NULL);
854 if (!retval) { 860 if (!retval) {
855 STp->door_locked = do_lock ? ST_LOCKED_EXPLICIT : ST_UNLOCKED; 861 STp->door_locked = do_lock ? ST_LOCKED_EXPLICIT : ST_UNLOCKED;
@@ -976,15 +982,14 @@ static int check_tape(struct scsi_tape *STp, struct file *filp)
976 struct st_request *SRpnt = NULL; 982 struct st_request *SRpnt = NULL;
977 struct st_modedef *STm; 983 struct st_modedef *STm;
978 struct st_partstat *STps; 984 struct st_partstat *STps;
979 char *name = tape_name(STp);
980 struct inode *inode = file_inode(filp); 985 struct inode *inode = file_inode(filp);
981 int mode = TAPE_MODE(inode); 986 int mode = TAPE_MODE(inode);
982 987
983 STp->ready = ST_READY; 988 STp->ready = ST_READY;
984 989
985 if (mode != STp->current_mode) { 990 if (mode != STp->current_mode) {
986 DEBC(printk(ST_DEB_MSG "%s: Mode change from %d to %d.\n", 991 DEBC_printk(STp, "Mode change from %d to %d.\n",
987 name, STp->current_mode, mode)); 992 STp->current_mode, mode);
988 new_session = 1; 993 new_session = 1;
989 STp->current_mode = mode; 994 STp->current_mode = mode;
990 } 995 }
@@ -1055,13 +1060,12 @@ static int check_tape(struct scsi_tape *STp, struct file *filp)
1055 STp->min_block = ((STp->buffer)->b_data[4] << 8) | 1060 STp->min_block = ((STp->buffer)->b_data[4] << 8) |
1056 (STp->buffer)->b_data[5]; 1061 (STp->buffer)->b_data[5];
1057 if ( DEB( debugging || ) !STp->inited) 1062 if ( DEB( debugging || ) !STp->inited)
1058 printk(KERN_INFO 1063 st_printk(KERN_INFO, STp,
1059 "%s: Block limits %d - %d bytes.\n", name, 1064 "Block limits %d - %d bytes.\n",
1060 STp->min_block, STp->max_block); 1065 STp->min_block, STp->max_block);
1061 } else { 1066 } else {
1062 STp->min_block = STp->max_block = (-1); 1067 STp->min_block = STp->max_block = (-1);
1063 DEBC(printk(ST_DEB_MSG "%s: Can't read block limits.\n", 1068 DEBC_printk(STp, "Can't read block limits.\n");
1064 name));
1065 } 1069 }
1066 } 1070 }
1067 1071
@@ -1078,56 +1082,58 @@ static int check_tape(struct scsi_tape *STp, struct file *filp)
1078 } 1082 }
1079 1083
1080 if ((STp->buffer)->syscall_result != 0) { 1084 if ((STp->buffer)->syscall_result != 0) {
1081 DEBC(printk(ST_DEB_MSG "%s: No Mode Sense.\n", name)); 1085 DEBC_printk(STp, "No Mode Sense.\n");
1082 STp->block_size = ST_DEFAULT_BLOCK; /* Educated guess (?) */ 1086 STp->block_size = ST_DEFAULT_BLOCK; /* Educated guess (?) */
1083 (STp->buffer)->syscall_result = 0; /* Prevent error propagation */ 1087 (STp->buffer)->syscall_result = 0; /* Prevent error propagation */
1084 STp->drv_write_prot = 0; 1088 STp->drv_write_prot = 0;
1085 } else { 1089 } else {
1086 DEBC(printk(ST_DEB_MSG 1090 DEBC_printk(STp,"Mode sense. Length %d, "
1087 "%s: Mode sense. Length %d, medium %x, WBS %x, BLL %d\n", 1091 "medium %x, WBS %x, BLL %d\n",
1088 name, 1092 (STp->buffer)->b_data[0],
1089 (STp->buffer)->b_data[0], (STp->buffer)->b_data[1], 1093 (STp->buffer)->b_data[1],
1090 (STp->buffer)->b_data[2], (STp->buffer)->b_data[3])); 1094 (STp->buffer)->b_data[2],
1095 (STp->buffer)->b_data[3]);
1091 1096
1092 if ((STp->buffer)->b_data[3] >= 8) { 1097 if ((STp->buffer)->b_data[3] >= 8) {
1093 STp->drv_buffer = ((STp->buffer)->b_data[2] >> 4) & 7; 1098 STp->drv_buffer = ((STp->buffer)->b_data[2] >> 4) & 7;
1094 STp->density = (STp->buffer)->b_data[4]; 1099 STp->density = (STp->buffer)->b_data[4];
1095 STp->block_size = (STp->buffer)->b_data[9] * 65536 + 1100 STp->block_size = (STp->buffer)->b_data[9] * 65536 +
1096 (STp->buffer)->b_data[10] * 256 + (STp->buffer)->b_data[11]; 1101 (STp->buffer)->b_data[10] * 256 + (STp->buffer)->b_data[11];
1097 DEBC(printk(ST_DEB_MSG 1102 DEBC_printk(STp, "Density %x, tape length: %x, "
1098 "%s: Density %x, tape length: %x, drv buffer: %d\n", 1103 "drv buffer: %d\n",
1099 name, STp->density, (STp->buffer)->b_data[5] * 65536 + 1104 STp->density,
1100 (STp->buffer)->b_data[6] * 256 + (STp->buffer)->b_data[7], 1105 (STp->buffer)->b_data[5] * 65536 +
1101 STp->drv_buffer)); 1106 (STp->buffer)->b_data[6] * 256 +
1107 (STp->buffer)->b_data[7],
1108 STp->drv_buffer);
1102 } 1109 }
1103 STp->drv_write_prot = ((STp->buffer)->b_data[2] & 0x80) != 0; 1110 STp->drv_write_prot = ((STp->buffer)->b_data[2] & 0x80) != 0;
1104 if (!STp->drv_buffer && STp->immediate_filemark) { 1111 if (!STp->drv_buffer && STp->immediate_filemark) {
1105 printk(KERN_WARNING 1112 st_printk(KERN_WARNING, STp,
1106 "%s: non-buffered tape: disabling writing immediate filemarks\n", 1113 "non-buffered tape: disabling "
1107 name); 1114 "writing immediate filemarks\n");
1108 STp->immediate_filemark = 0; 1115 STp->immediate_filemark = 0;
1109 } 1116 }
1110 } 1117 }
1111 st_release_request(SRpnt); 1118 st_release_request(SRpnt);
1112 SRpnt = NULL; 1119 SRpnt = NULL;
1113 STp->inited = 1; 1120 STp->inited = 1;
1114 1121
1115 if (STp->block_size > 0) 1122 if (STp->block_size > 0)
1116 (STp->buffer)->buffer_blocks = 1123 (STp->buffer)->buffer_blocks =
1117 (STp->buffer)->buffer_size / STp->block_size; 1124 (STp->buffer)->buffer_size / STp->block_size;
1118 else 1125 else
1119 (STp->buffer)->buffer_blocks = 1; 1126 (STp->buffer)->buffer_blocks = 1;
1120 (STp->buffer)->buffer_bytes = (STp->buffer)->read_pointer = 0; 1127 (STp->buffer)->buffer_bytes = (STp->buffer)->read_pointer = 0;
1121 1128
1122 DEBC(printk(ST_DEB_MSG 1129 DEBC_printk(STp, "Block size: %d, buffer size: %d (%d blocks).\n",
1123 "%s: Block size: %d, buffer size: %d (%d blocks).\n", name, 1130 STp->block_size, (STp->buffer)->buffer_size,
1124 STp->block_size, (STp->buffer)->buffer_size, 1131 (STp->buffer)->buffer_blocks);
1125 (STp->buffer)->buffer_blocks));
1126 1132
1127 if (STp->drv_write_prot) { 1133 if (STp->drv_write_prot) {
1128 STp->write_prot = 1; 1134 STp->write_prot = 1;
1129 1135
1130 DEBC(printk(ST_DEB_MSG "%s: Write protected\n", name)); 1136 DEBC_printk(STp, "Write protected\n");
1131 1137
1132 if (do_wait && 1138 if (do_wait &&
1133 ((st_flags & O_ACCMODE) == O_WRONLY || 1139 ((st_flags & O_ACCMODE) == O_WRONLY ||
@@ -1141,8 +1147,7 @@ static int check_tape(struct scsi_tape *STp, struct file *filp)
1141 /* This code is reached when the device is opened for the first time 1147 /* This code is reached when the device is opened for the first time
1142 after the driver has been initialized with tape in the drive and the 1148 after the driver has been initialized with tape in the drive and the
1143 partition support has been enabled. */ 1149 partition support has been enabled. */
1144 DEBC(printk(ST_DEB_MSG 1150 DEBC_printk(STp, "Updating partition number in status.\n");
1145 "%s: Updating partition number in status.\n", name));
1146 if ((STp->partition = find_partition(STp)) < 0) { 1151 if ((STp->partition = find_partition(STp)) < 0) {
1147 retval = STp->partition; 1152 retval = STp->partition;
1148 goto err_out; 1153 goto err_out;
@@ -1160,9 +1165,10 @@ static int check_tape(struct scsi_tape *STp, struct file *filp)
1160 1165
1161 if (STp->default_drvbuffer != 0xff) { 1166 if (STp->default_drvbuffer != 0xff) {
1162 if (st_int_ioctl(STp, MTSETDRVBUFFER, STp->default_drvbuffer)) 1167 if (st_int_ioctl(STp, MTSETDRVBUFFER, STp->default_drvbuffer))
1163 printk(KERN_WARNING 1168 st_printk(KERN_WARNING, STp,
1164 "%s: Can't set default drive buffering to %d.\n", 1169 "Can't set default drive "
1165 name, STp->default_drvbuffer); 1170 "buffering to %d.\n",
1171 STp->default_drvbuffer);
1166 } 1172 }
1167 } 1173 }
1168 1174
@@ -1182,7 +1188,6 @@ static int st_open(struct inode *inode, struct file *filp)
1182 struct scsi_tape *STp; 1188 struct scsi_tape *STp;
1183 struct st_partstat *STps; 1189 struct st_partstat *STps;
1184 int dev = TAPE_NR(inode); 1190 int dev = TAPE_NR(inode);
1185 char *name;
1186 1191
1187 /* 1192 /*
1188 * We really want to do nonseekable_open(inode, filp); here, but some 1193 * We really want to do nonseekable_open(inode, filp); here, but some
@@ -1196,13 +1201,12 @@ static int st_open(struct inode *inode, struct file *filp)
1196 } 1201 }
1197 1202
1198 filp->private_data = STp; 1203 filp->private_data = STp;
1199 name = tape_name(STp);
1200 1204
1201 spin_lock(&st_use_lock); 1205 spin_lock(&st_use_lock);
1202 if (STp->in_use) { 1206 if (STp->in_use) {
1203 spin_unlock(&st_use_lock); 1207 spin_unlock(&st_use_lock);
1204 scsi_tape_put(STp); 1208 scsi_tape_put(STp);
1205 DEB( printk(ST_DEB_MSG "%s: Device already in use.\n", name); ) 1209 DEBC_printk(STp, "Device already in use.\n");
1206 return (-EBUSY); 1210 return (-EBUSY);
1207 } 1211 }
1208 1212
@@ -1222,8 +1226,8 @@ static int st_open(struct inode *inode, struct file *filp)
1222 1226
1223 /* See that we have at least a one page buffer available */ 1227 /* See that we have at least a one page buffer available */
1224 if (!enlarge_buffer(STp->buffer, PAGE_SIZE, STp->restr_dma)) { 1228 if (!enlarge_buffer(STp->buffer, PAGE_SIZE, STp->restr_dma)) {
1225 printk(KERN_WARNING "%s: Can't allocate one page tape buffer.\n", 1229 st_printk(KERN_WARNING, STp,
1226 name); 1230 "Can't allocate one page tape buffer.\n");
1227 retval = (-EOVERFLOW); 1231 retval = (-EOVERFLOW);
1228 goto err_out; 1232 goto err_out;
1229 } 1233 }
@@ -1279,7 +1283,6 @@ static int st_flush(struct file *filp, fl_owner_t id)
1279 struct scsi_tape *STp = filp->private_data; 1283 struct scsi_tape *STp = filp->private_data;
1280 struct st_modedef *STm = &(STp->modes[STp->current_mode]); 1284 struct st_modedef *STm = &(STp->modes[STp->current_mode]);
1281 struct st_partstat *STps = &(STp->ps[STp->partition]); 1285 struct st_partstat *STps = &(STp->ps[STp->partition]);
1282 char *name = tape_name(STp);
1283 1286
1284 if (file_count(filp) > 1) 1287 if (file_count(filp) > 1)
1285 return 0; 1288 return 0;
@@ -1292,24 +1295,25 @@ static int st_flush(struct file *filp, fl_owner_t id)
1292 1295
1293 if (STp->can_partitions && 1296 if (STp->can_partitions &&
1294 (result2 = switch_partition(STp)) < 0) { 1297 (result2 = switch_partition(STp)) < 0) {
1295 DEBC(printk(ST_DEB_MSG 1298 DEBC_printk(STp, "switch_partition at close failed.\n");
1296 "%s: switch_partition at close failed.\n", name));
1297 if (result == 0) 1299 if (result == 0)
1298 result = result2; 1300 result = result2;
1299 goto out; 1301 goto out;
1300 } 1302 }
1301 1303
1302 DEBC( if (STp->nbr_requests) 1304 DEBC( if (STp->nbr_requests)
1303 printk(KERN_DEBUG "%s: Number of r/w requests %d, dio used in %d, pages %d.\n", 1305 st_printk(KERN_DEBUG, STp,
1304 name, STp->nbr_requests, STp->nbr_dio, STp->nbr_pages)); 1306 "Number of r/w requests %d, dio used in %d, "
1307 "pages %d.\n", STp->nbr_requests, STp->nbr_dio,
1308 STp->nbr_pages));
1305 1309
1306 if (STps->rw == ST_WRITING && !STp->pos_unknown) { 1310 if (STps->rw == ST_WRITING && !STp->pos_unknown) {
1307 struct st_cmdstatus *cmdstatp = &STp->buffer->cmdstat; 1311 struct st_cmdstatus *cmdstatp = &STp->buffer->cmdstat;
1308 1312
1309 DEBC(printk(ST_DEB_MSG "%s: Async write waits %d, finished %d.\n", 1313#if DEBUG
1310 name, STp->nbr_waits, STp->nbr_finished); 1314 DEBC_printk(STp, "Async write waits %d, finished %d.\n",
1311 ) 1315 STp->nbr_waits, STp->nbr_finished);
1312 1316#endif
1313 memset(cmd, 0, MAX_COMMAND_SIZE); 1317 memset(cmd, 0, MAX_COMMAND_SIZE);
1314 cmd[0] = WRITE_FILEMARKS; 1318 cmd[0] = WRITE_FILEMARKS;
1315 if (STp->immediate_filemark) 1319 if (STp->immediate_filemark)
@@ -1343,13 +1347,13 @@ static int st_flush(struct file *filp, fl_owner_t id)
1343 else { /* Write error */ 1347 else { /* Write error */
1344 st_release_request(SRpnt); 1348 st_release_request(SRpnt);
1345 SRpnt = NULL; 1349 SRpnt = NULL;
1346 printk(KERN_ERR "%s: Error on write filemark.\n", name); 1350 st_printk(KERN_ERR, STp,
1351 "Error on write filemark.\n");
1347 if (result == 0) 1352 if (result == 0)
1348 result = (-EIO); 1353 result = (-EIO);
1349 } 1354 }
1350 1355
1351 DEBC(printk(ST_DEB_MSG "%s: Buffer flushed, %d EOF(s) written\n", 1356 DEBC_printk(STp, "Buffer flushed, %d EOF(s) written\n", cmd[4]);
1352 name, cmd[4]));
1353 } else if (!STp->rew_at_close) { 1357 } else if (!STp->rew_at_close) {
1354 STps = &(STp->ps[STp->partition]); 1358 STps = &(STp->ps[STp->partition]);
1355 if (!STm->sysv || STps->rw != ST_READING) { 1359 if (!STm->sysv || STps->rw != ST_READING) {
@@ -1447,9 +1451,10 @@ static ssize_t rw_checks(struct scsi_tape *STp, struct file *filp, size_t count)
1447 if (count == 0) 1451 if (count == 0)
1448 goto out; 1452 goto out;
1449 1453
1450 DEB( 1454 DEB(
1451 if (!STp->in_use) { 1455 if (!STp->in_use) {
1452 printk(ST_DEB_MSG "%s: Incorrect device.\n", tape_name(STp)); 1456 st_printk(ST_DEB_MSG, STp,
1457 "Incorrect device.\n");
1453 retval = (-EIO); 1458 retval = (-EIO);
1454 goto out; 1459 goto out;
1455 } ) /* end DEB */ 1460 } ) /* end DEB */
@@ -1519,8 +1524,9 @@ static int setup_buffering(struct scsi_tape *STp, const char __user *buf,
1519 1524
1520 if (bufsize > STbp->buffer_size && 1525 if (bufsize > STbp->buffer_size &&
1521 !enlarge_buffer(STbp, bufsize, STp->restr_dma)) { 1526 !enlarge_buffer(STbp, bufsize, STp->restr_dma)) {
1522 printk(KERN_WARNING "%s: Can't allocate %d byte tape buffer.\n", 1527 st_printk(KERN_WARNING, STp,
1523 tape_name(STp), bufsize); 1528 "Can't allocate %d byte tape buffer.\n",
1529 bufsize);
1524 retval = (-EOVERFLOW); 1530 retval = (-EOVERFLOW);
1525 goto out; 1531 goto out;
1526 } 1532 }
@@ -1563,7 +1569,6 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
1563 struct st_modedef *STm; 1569 struct st_modedef *STm;
1564 struct st_partstat *STps; 1570 struct st_partstat *STps;
1565 struct st_buffer *STbp; 1571 struct st_buffer *STbp;
1566 char *name = tape_name(STp);
1567 1572
1568 if (mutex_lock_interruptible(&STp->lock)) 1573 if (mutex_lock_interruptible(&STp->lock))
1569 return -ERESTARTSYS; 1574 return -ERESTARTSYS;
@@ -1574,8 +1579,8 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
1574 1579
1575 /* Write must be integral number of blocks */ 1580 /* Write must be integral number of blocks */
1576 if (STp->block_size != 0 && (count % STp->block_size) != 0) { 1581 if (STp->block_size != 0 && (count % STp->block_size) != 0) {
1577 printk(KERN_WARNING "%s: Write not multiple of tape block size.\n", 1582 st_printk(KERN_WARNING, STp,
1578 name); 1583 "Write not multiple of tape block size.\n");
1579 retval = (-EINVAL); 1584 retval = (-EINVAL);
1580 goto out; 1585 goto out;
1581 } 1586 }
@@ -1601,8 +1606,8 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
1601 if (STm->default_compression != ST_DONT_TOUCH && 1606 if (STm->default_compression != ST_DONT_TOUCH &&
1602 !(STp->compression_changed)) { 1607 !(STp->compression_changed)) {
1603 if (st_compression(STp, (STm->default_compression == ST_YES))) { 1608 if (st_compression(STp, (STm->default_compression == ST_YES))) {
1604 printk(KERN_WARNING "%s: Can't set default compression.\n", 1609 st_printk(KERN_WARNING, STp,
1605 name); 1610 "Can't set default compression.\n");
1606 if (modes_defined) { 1611 if (modes_defined) {
1607 retval = (-EINVAL); 1612 retval = (-EINVAL);
1608 goto out; 1613 goto out;
@@ -1723,7 +1728,7 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
1723 if (STbp->syscall_result != 0) { 1728 if (STbp->syscall_result != 0) {
1724 struct st_cmdstatus *cmdstatp = &STp->buffer->cmdstat; 1729 struct st_cmdstatus *cmdstatp = &STp->buffer->cmdstat;
1725 1730
1726 DEBC(printk(ST_DEB_MSG "%s: Error on write:\n", name)); 1731 DEBC_printk(STp, "Error on write:\n");
1727 if (cmdstatp->have_sense && (cmdstatp->flags & SENSE_EOM)) { 1732 if (cmdstatp->have_sense && (cmdstatp->flags & SENSE_EOM)) {
1728 scode = cmdstatp->sense_hdr.sense_key; 1733 scode = cmdstatp->sense_hdr.sense_key;
1729 if (cmdstatp->remainder_valid) 1734 if (cmdstatp->remainder_valid)
@@ -1750,9 +1755,9 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
1750 if (STp->block_size == 0 || 1755 if (STp->block_size == 0 ||
1751 undone > 0 || count == 0) 1756 undone > 0 || count == 0)
1752 retval = (-ENOSPC); /* EOM within current request */ 1757 retval = (-ENOSPC); /* EOM within current request */
1753 DEBC(printk(ST_DEB_MSG 1758 DEBC_printk(STp, "EOM with %d "
1754 "%s: EOM with %d bytes unwritten.\n", 1759 "bytes unwritten.\n",
1755 name, (int)count)); 1760 (int)count);
1756 } else { 1761 } else {
1757 /* EOT within data buffered earlier (possible only 1762 /* EOT within data buffered earlier (possible only
1758 in fixed block mode without direct i/o) */ 1763 in fixed block mode without direct i/o) */
@@ -1765,9 +1770,10 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
1765 STp->block_size; 1770 STp->block_size;
1766 } 1771 }
1767 STps->eof = ST_EOM_OK; 1772 STps->eof = ST_EOM_OK;
1768 DEBC(printk(ST_DEB_MSG 1773 DEBC_printk(STp, "Retry "
1769 "%s: Retry write of %d bytes at EOM.\n", 1774 "write of %d "
1770 name, STp->buffer->buffer_bytes)); 1775 "bytes at EOM.\n",
1776 STp->buffer->buffer_bytes);
1771 goto retry_write; 1777 goto retry_write;
1772 } 1778 }
1773 else { 1779 else {
@@ -1778,9 +1784,8 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
1778 STps->eof = ST_EOM_ERROR; 1784 STps->eof = ST_EOM_ERROR;
1779 STps->drv_block = (-1); /* Too cautious? */ 1785 STps->drv_block = (-1); /* Too cautious? */
1780 retval = (-EIO); /* EOM for old data */ 1786 retval = (-EIO); /* EOM for old data */
1781 DEBC(printk(ST_DEB_MSG 1787 DEBC_printk(STp, "EOM with "
1782 "%s: EOM with lost data.\n", 1788 "lost data.\n");
1783 name));
1784 } 1789 }
1785 } 1790 }
1786 } else { 1791 } else {
@@ -1839,7 +1844,6 @@ static long read_tape(struct scsi_tape *STp, long count,
1839 struct st_partstat *STps; 1844 struct st_partstat *STps;
1840 struct st_buffer *STbp; 1845 struct st_buffer *STbp;
1841 int retval = 0; 1846 int retval = 0;
1842 char *name = tape_name(STp);
1843 1847
1844 if (count == 0) 1848 if (count == 0)
1845 return 0; 1849 return 0;
@@ -1891,12 +1895,12 @@ static long read_tape(struct scsi_tape *STp, long count,
1891 struct st_cmdstatus *cmdstatp = &STp->buffer->cmdstat; 1895 struct st_cmdstatus *cmdstatp = &STp->buffer->cmdstat;
1892 1896
1893 retval = 1; 1897 retval = 1;
1894 DEBC(printk(ST_DEB_MSG "%s: Sense: %2x %2x %2x %2x %2x %2x %2x %2x\n", 1898 DEBC_printk(STp,
1895 name, 1899 "Sense: %2x %2x %2x %2x %2x %2x %2x %2x\n",
1896 SRpnt->sense[0], SRpnt->sense[1], 1900 SRpnt->sense[0], SRpnt->sense[1],
1897 SRpnt->sense[2], SRpnt->sense[3], 1901 SRpnt->sense[2], SRpnt->sense[3],
1898 SRpnt->sense[4], SRpnt->sense[5], 1902 SRpnt->sense[4], SRpnt->sense[5],
1899 SRpnt->sense[6], SRpnt->sense[7])); 1903 SRpnt->sense[6], SRpnt->sense[7]);
1900 if (cmdstatp->have_sense) { 1904 if (cmdstatp->have_sense) {
1901 1905
1902 if (cmdstatp->sense_hdr.sense_key == BLANK_CHECK) 1906 if (cmdstatp->sense_hdr.sense_key == BLANK_CHECK)
@@ -1913,23 +1917,27 @@ static long read_tape(struct scsi_tape *STp, long count,
1913 transfer = bytes; 1917 transfer = bytes;
1914 1918
1915 if (cmdstatp->flags & SENSE_ILI) { /* ILI */ 1919 if (cmdstatp->flags & SENSE_ILI) { /* ILI */
1916 if (STp->block_size == 0) { 1920 if (STp->block_size == 0 &&
1917 if (transfer <= 0) { 1921 transfer < 0) {
1918 if (transfer < 0) 1922 st_printk(KERN_NOTICE, STp,
1919 printk(KERN_NOTICE 1923 "Failed to read %d "
1920 "%s: Failed to read %d byte block with %d byte transfer.\n", 1924 "byte block with %d "
1921 name, bytes - transfer, bytes); 1925 "byte transfer.\n",
1922 if (STps->drv_block >= 0) 1926 bytes - transfer,
1923 STps->drv_block += 1; 1927 bytes);
1924 STbp->buffer_bytes = 0; 1928 if (STps->drv_block >= 0)
1925 return (-ENOMEM); 1929 STps->drv_block += 1;
1926 } 1930 STbp->buffer_bytes = 0;
1931 return (-ENOMEM);
1932 } else if (STp->block_size == 0) {
1927 STbp->buffer_bytes = bytes - transfer; 1933 STbp->buffer_bytes = bytes - transfer;
1928 } else { 1934 } else {
1929 st_release_request(SRpnt); 1935 st_release_request(SRpnt);
1930 SRpnt = *aSRpnt = NULL; 1936 SRpnt = *aSRpnt = NULL;
1931 if (transfer == blks) { /* We did not get anything, error */ 1937 if (transfer == blks) { /* We did not get anything, error */
1932 printk(KERN_NOTICE "%s: Incorrect block size.\n", name); 1938 st_printk(KERN_NOTICE, STp,
1939 "Incorrect "
1940 "block size.\n");
1933 if (STps->drv_block >= 0) 1941 if (STps->drv_block >= 0)
1934 STps->drv_block += blks - transfer + 1; 1942 STps->drv_block += blks - transfer + 1;
1935 st_int_ioctl(STp, MTBSR, 1); 1943 st_int_ioctl(STp, MTBSR, 1);
@@ -1938,9 +1946,11 @@ static long read_tape(struct scsi_tape *STp, long count,
1938 /* We have some data, deliver it */ 1946 /* We have some data, deliver it */
1939 STbp->buffer_bytes = (blks - transfer) * 1947 STbp->buffer_bytes = (blks - transfer) *
1940 STp->block_size; 1948 STp->block_size;
1941 DEBC(printk(ST_DEB_MSG 1949 DEBC_printk(STp, "ILI but "
1942 "%s: ILI but enough data received %ld %d.\n", 1950 "enough data "
1943 name, count, STbp->buffer_bytes)); 1951 "received %ld "
1952 "%d.\n", count,
1953 STbp->buffer_bytes);
1944 if (STps->drv_block >= 0) 1954 if (STps->drv_block >= 0)
1945 STps->drv_block += 1; 1955 STps->drv_block += 1;
1946 if (st_int_ioctl(STp, MTBSR, 1)) 1956 if (st_int_ioctl(STp, MTBSR, 1))
@@ -1956,9 +1966,9 @@ static long read_tape(struct scsi_tape *STp, long count,
1956 else 1966 else
1957 STbp->buffer_bytes = 1967 STbp->buffer_bytes =
1958 bytes - transfer * STp->block_size; 1968 bytes - transfer * STp->block_size;
1959 DEBC(printk(ST_DEB_MSG 1969 DEBC_printk(STp, "EOF detected (%d "
1960 "%s: EOF detected (%d bytes read).\n", 1970 "bytes read).\n",
1961 name, STbp->buffer_bytes)); 1971 STbp->buffer_bytes);
1962 } else if (cmdstatp->flags & SENSE_EOM) { 1972 } else if (cmdstatp->flags & SENSE_EOM) {
1963 if (STps->eof == ST_FM) 1973 if (STps->eof == ST_FM)
1964 STps->eof = ST_EOD_1; 1974 STps->eof = ST_EOD_1;
@@ -1970,20 +1980,20 @@ static long read_tape(struct scsi_tape *STp, long count,
1970 STbp->buffer_bytes = 1980 STbp->buffer_bytes =
1971 bytes - transfer * STp->block_size; 1981 bytes - transfer * STp->block_size;
1972 1982
1973 DEBC(printk(ST_DEB_MSG "%s: EOM detected (%d bytes read).\n", 1983 DEBC_printk(STp, "EOM detected (%d "
1974 name, STbp->buffer_bytes)); 1984 "bytes read).\n",
1985 STbp->buffer_bytes);
1975 } 1986 }
1976 } 1987 }
1977 /* end of EOF, EOM, ILI test */ 1988 /* end of EOF, EOM, ILI test */
1978 else { /* nonzero sense key */ 1989 else { /* nonzero sense key */
1979 DEBC(printk(ST_DEB_MSG 1990 DEBC_printk(STp, "Tape error while reading.\n");
1980 "%s: Tape error while reading.\n", name));
1981 STps->drv_block = (-1); 1991 STps->drv_block = (-1);
1982 if (STps->eof == ST_FM && 1992 if (STps->eof == ST_FM &&
1983 cmdstatp->sense_hdr.sense_key == BLANK_CHECK) { 1993 cmdstatp->sense_hdr.sense_key == BLANK_CHECK) {
1984 DEBC(printk(ST_DEB_MSG 1994 DEBC_printk(STp, "Zero returned for "
1985 "%s: Zero returned for first BLANK CHECK after EOF.\n", 1995 "first BLANK CHECK "
1986 name)); 1996 "after EOF.\n");
1987 STps->eof = ST_EOD_2; /* First BLANK_CHECK after FM */ 1997 STps->eof = ST_EOD_2; /* First BLANK_CHECK after FM */
1988 } else /* Some other extended sense code */ 1998 } else /* Some other extended sense code */
1989 retval = (-EIO); 1999 retval = (-EIO);
@@ -1992,13 +2002,13 @@ static long read_tape(struct scsi_tape *STp, long count,
1992 if (STbp->buffer_bytes < 0) /* Caused by bogus sense data */ 2002 if (STbp->buffer_bytes < 0) /* Caused by bogus sense data */
1993 STbp->buffer_bytes = 0; 2003 STbp->buffer_bytes = 0;
1994 } 2004 }
1995 /* End of extended sense test */ 2005 /* End of extended sense test */
1996 else { /* Non-extended sense */ 2006 else { /* Non-extended sense */
1997 retval = STbp->syscall_result; 2007 retval = STbp->syscall_result;
1998 } 2008 }
1999 2009
2000 } 2010 }
2001 /* End of error handling */ 2011 /* End of error handling */
2002 else { /* Read successful */ 2012 else { /* Read successful */
2003 STbp->buffer_bytes = bytes; 2013 STbp->buffer_bytes = bytes;
2004 if (STp->sili) /* In fixed block mode residual is always zero here */ 2014 if (STp->sili) /* In fixed block mode residual is always zero here */
@@ -2028,7 +2038,6 @@ st_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos)
2028 struct st_modedef *STm; 2038 struct st_modedef *STm;
2029 struct st_partstat *STps; 2039 struct st_partstat *STps;
2030 struct st_buffer *STbp = STp->buffer; 2040 struct st_buffer *STbp = STp->buffer;
2031 DEB( char *name = tape_name(STp); )
2032 2041
2033 if (mutex_lock_interruptible(&STp->lock)) 2042 if (mutex_lock_interruptible(&STp->lock))
2034 return -ERESTARTSYS; 2043 return -ERESTARTSYS;
@@ -2053,11 +2062,12 @@ st_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos)
2053 goto out; 2062 goto out;
2054 STps->rw = ST_READING; 2063 STps->rw = ST_READING;
2055 } 2064 }
2056 DEB( 2065 DEB(
2057 if (debugging && STps->eof != ST_NOEOF) 2066 if (debugging && STps->eof != ST_NOEOF)
2058 printk(ST_DEB_MSG "%s: EOF/EOM flag up (%d). Bytes %d\n", name, 2067 st_printk(ST_DEB_MSG, STp,
2059 STps->eof, STbp->buffer_bytes); 2068 "EOF/EOM flag up (%d). Bytes %d\n",
2060 ) /* end DEB */ 2069 STps->eof, STbp->buffer_bytes);
2070 ) /* end DEB */
2061 2071
2062 retval = setup_buffering(STp, buf, count, 1); 2072 retval = setup_buffering(STp, buf, count, 1);
2063 if (retval) 2073 if (retval)
@@ -2104,13 +2114,13 @@ st_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos)
2104 2114
2105 /* Move the data from driver buffer to user buffer */ 2115 /* Move the data from driver buffer to user buffer */
2106 if (STbp->buffer_bytes > 0) { 2116 if (STbp->buffer_bytes > 0) {
2107 DEB( 2117 DEB(
2108 if (debugging && STps->eof != ST_NOEOF) 2118 if (debugging && STps->eof != ST_NOEOF)
2109 printk(ST_DEB_MSG 2119 st_printk(ST_DEB_MSG, STp,
2110 "%s: EOF up (%d). Left %d, needed %d.\n", name, 2120 "EOF up (%d). Left %d, needed %d.\n",
2111 STps->eof, STbp->buffer_bytes, 2121 STps->eof, STbp->buffer_bytes,
2112 (int)(count - total)); 2122 (int)(count - total));
2113 ) /* end DEB */ 2123 ) /* end DEB */
2114 transfer = STbp->buffer_bytes < count - total ? 2124 transfer = STbp->buffer_bytes < count - total ?
2115 STbp->buffer_bytes : count - total; 2125 STbp->buffer_bytes : count - total;
2116 if (!do_dio) { 2126 if (!do_dio) {
@@ -2166,26 +2176,30 @@ st_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos)
2166 2176
2167DEB( 2177DEB(
2168/* Set the driver options */ 2178/* Set the driver options */
2169static void st_log_options(struct scsi_tape * STp, struct st_modedef * STm, char *name) 2179static void st_log_options(struct scsi_tape * STp, struct st_modedef * STm)
2170{ 2180{
2171 if (debugging) { 2181 if (debugging) {
2172 printk(KERN_INFO 2182 st_printk(KERN_INFO, STp,
2173 "%s: Mode %d options: buffer writes: %d, async writes: %d, read ahead: %d\n", 2183 "Mode %d options: buffer writes: %d, "
2174 name, STp->current_mode, STm->do_buffer_writes, STm->do_async_writes, 2184 "async writes: %d, read ahead: %d\n",
2175 STm->do_read_ahead); 2185 STp->current_mode, STm->do_buffer_writes,
2176 printk(KERN_INFO 2186 STm->do_async_writes, STm->do_read_ahead);
2177 "%s: can bsr: %d, two FMs: %d, fast mteom: %d, auto lock: %d,\n", 2187 st_printk(KERN_INFO, STp,
2178 name, STp->can_bsr, STp->two_fm, STp->fast_mteom, STp->do_auto_lock); 2188 " can bsr: %d, two FMs: %d, "
2179 printk(KERN_INFO 2189 "fast mteom: %d, auto lock: %d,\n",
2180 "%s: defs for wr: %d, no block limits: %d, partitions: %d, s2 log: %d\n", 2190 STp->can_bsr, STp->two_fm, STp->fast_mteom,
2181 name, STm->defaults_for_writes, STp->omit_blklims, STp->can_partitions, 2191 STp->do_auto_lock);
2182 STp->scsi2_logical); 2192 st_printk(KERN_INFO, STp,
2183 printk(KERN_INFO 2193 " defs for wr: %d, no block limits: %d, "
2184 "%s: sysv: %d nowait: %d sili: %d nowait_filemark: %d\n", 2194 "partitions: %d, s2 log: %d\n",
2185 name, STm->sysv, STp->immediate, STp->sili, 2195 STm->defaults_for_writes, STp->omit_blklims,
2186 STp->immediate_filemark); 2196 STp->can_partitions, STp->scsi2_logical);
2187 printk(KERN_INFO "%s: debugging: %d\n", 2197 st_printk(KERN_INFO, STp,
2188 name, debugging); 2198 " sysv: %d nowait: %d sili: %d "
2199 "nowait_filemark: %d\n",
2200 STm->sysv, STp->immediate, STp->sili,
2201 STp->immediate_filemark);
2202 st_printk(KERN_INFO, STp, " debugging: %d\n", debugging);
2189 } 2203 }
2190} 2204}
2191 ) 2205 )
@@ -2196,7 +2210,6 @@ static int st_set_options(struct scsi_tape *STp, long options)
2196 int value; 2210 int value;
2197 long code; 2211 long code;
2198 struct st_modedef *STm; 2212 struct st_modedef *STm;
2199 char *name = tape_name(STp);
2200 struct cdev *cd0, *cd1; 2213 struct cdev *cd0, *cd1;
2201 struct device *d0, *d1; 2214 struct device *d0, *d1;
2202 2215
@@ -2212,9 +2225,8 @@ static int st_set_options(struct scsi_tape *STp, long options)
2212 STm->devs[0] = d0; 2225 STm->devs[0] = d0;
2213 STm->devs[1] = d1; 2226 STm->devs[1] = d1;
2214 modes_defined = 1; 2227 modes_defined = 1;
2215 DEBC(printk(ST_DEB_MSG 2228 DEBC_printk(STp, "Initialized mode %d definition from mode 0\n",
2216 "%s: Initialized mode %d definition from mode 0\n", 2229 STp->current_mode);
2217 name, STp->current_mode));
2218 } 2230 }
2219 2231
2220 code = options & MT_ST_OPTIONS; 2232 code = options & MT_ST_OPTIONS;
@@ -2236,7 +2248,7 @@ static int st_set_options(struct scsi_tape *STp, long options)
2236 STm->sysv = (options & MT_ST_SYSV) != 0; 2248 STm->sysv = (options & MT_ST_SYSV) != 0;
2237 STp->sili = (options & MT_ST_SILI) != 0; 2249 STp->sili = (options & MT_ST_SILI) != 0;
2238 DEB( debugging = (options & MT_ST_DEBUGGING) != 0; 2250 DEB( debugging = (options & MT_ST_DEBUGGING) != 0;
2239 st_log_options(STp, STm, name); ) 2251 st_log_options(STp, STm); )
2240 } else if (code == MT_ST_SETBOOLEANS || code == MT_ST_CLEARBOOLEANS) { 2252 } else if (code == MT_ST_SETBOOLEANS || code == MT_ST_CLEARBOOLEANS) {
2241 value = (code == MT_ST_SETBOOLEANS); 2253 value = (code == MT_ST_SETBOOLEANS);
2242 if ((options & MT_ST_BUFFER_WRITES) != 0) 2254 if ((options & MT_ST_BUFFER_WRITES) != 0)
@@ -2270,21 +2282,21 @@ static int st_set_options(struct scsi_tape *STp, long options)
2270 STm->sysv = value; 2282 STm->sysv = value;
2271 if ((options & MT_ST_SILI) != 0) 2283 if ((options & MT_ST_SILI) != 0)
2272 STp->sili = value; 2284 STp->sili = value;
2273 DEB( 2285 DEB(
2274 if ((options & MT_ST_DEBUGGING) != 0) 2286 if ((options & MT_ST_DEBUGGING) != 0)
2275 debugging = value; 2287 debugging = value;
2276 st_log_options(STp, STm, name); ) 2288 st_log_options(STp, STm); )
2277 } else if (code == MT_ST_WRITE_THRESHOLD) { 2289 } else if (code == MT_ST_WRITE_THRESHOLD) {
2278 /* Retained for compatibility */ 2290 /* Retained for compatibility */
2279 } else if (code == MT_ST_DEF_BLKSIZE) { 2291 } else if (code == MT_ST_DEF_BLKSIZE) {
2280 value = (options & ~MT_ST_OPTIONS); 2292 value = (options & ~MT_ST_OPTIONS);
2281 if (value == ~MT_ST_OPTIONS) { 2293 if (value == ~MT_ST_OPTIONS) {
2282 STm->default_blksize = (-1); 2294 STm->default_blksize = (-1);
2283 DEBC( printk(KERN_INFO "%s: Default block size disabled.\n", name)); 2295 DEBC_printk(STp, "Default block size disabled.\n");
2284 } else { 2296 } else {
2285 STm->default_blksize = value; 2297 STm->default_blksize = value;
2286 DEBC( printk(KERN_INFO "%s: Default block size set to %d bytes.\n", 2298 DEBC_printk(STp,"Default block size set to "
2287 name, STm->default_blksize)); 2299 "%d bytes.\n", STm->default_blksize);
2288 if (STp->ready == ST_READY) { 2300 if (STp->ready == ST_READY) {
2289 STp->blksize_changed = 0; 2301 STp->blksize_changed = 0;
2290 set_mode_densblk(STp, STm); 2302 set_mode_densblk(STp, STm);
@@ -2294,13 +2306,13 @@ static int st_set_options(struct scsi_tape *STp, long options)
2294 value = (options & ~MT_ST_OPTIONS); 2306 value = (options & ~MT_ST_OPTIONS);
2295 if ((value & MT_ST_SET_LONG_TIMEOUT) != 0) { 2307 if ((value & MT_ST_SET_LONG_TIMEOUT) != 0) {
2296 STp->long_timeout = (value & ~MT_ST_SET_LONG_TIMEOUT) * HZ; 2308 STp->long_timeout = (value & ~MT_ST_SET_LONG_TIMEOUT) * HZ;
2297 DEBC( printk(KERN_INFO "%s: Long timeout set to %d seconds.\n", name, 2309 DEBC_printk(STp, "Long timeout set to %d seconds.\n",
2298 (value & ~MT_ST_SET_LONG_TIMEOUT))); 2310 (value & ~MT_ST_SET_LONG_TIMEOUT));
2299 } else { 2311 } else {
2300 blk_queue_rq_timeout(STp->device->request_queue, 2312 blk_queue_rq_timeout(STp->device->request_queue,
2301 value * HZ); 2313 value * HZ);
2302 DEBC( printk(KERN_INFO "%s: Normal timeout set to %d seconds.\n", 2314 DEBC_printk(STp, "Normal timeout set to %d seconds.\n",
2303 name, value) ); 2315 value);
2304 } 2316 }
2305 } else if (code == MT_ST_SET_CLN) { 2317 } else if (code == MT_ST_SET_CLN) {
2306 value = (options & ~MT_ST_OPTIONS) & 0xff; 2318 value = (options & ~MT_ST_OPTIONS) & 0xff;
@@ -2311,21 +2323,21 @@ static int st_set_options(struct scsi_tape *STp, long options)
2311 STp->cln_mode = value; 2323 STp->cln_mode = value;
2312 STp->cln_sense_mask = (options >> 8) & 0xff; 2324 STp->cln_sense_mask = (options >> 8) & 0xff;
2313 STp->cln_sense_value = (options >> 16) & 0xff; 2325 STp->cln_sense_value = (options >> 16) & 0xff;
2314 printk(KERN_INFO 2326 st_printk(KERN_INFO, STp,
2315 "%s: Cleaning request mode %d, mask %02x, value %02x\n", 2327 "Cleaning request mode %d, mask %02x, value %02x\n",
2316 name, value, STp->cln_sense_mask, STp->cln_sense_value); 2328 value, STp->cln_sense_mask, STp->cln_sense_value);
2317 } else if (code == MT_ST_DEF_OPTIONS) { 2329 } else if (code == MT_ST_DEF_OPTIONS) {
2318 code = (options & ~MT_ST_CLEAR_DEFAULT); 2330 code = (options & ~MT_ST_CLEAR_DEFAULT);
2319 value = (options & MT_ST_CLEAR_DEFAULT); 2331 value = (options & MT_ST_CLEAR_DEFAULT);
2320 if (code == MT_ST_DEF_DENSITY) { 2332 if (code == MT_ST_DEF_DENSITY) {
2321 if (value == MT_ST_CLEAR_DEFAULT) { 2333 if (value == MT_ST_CLEAR_DEFAULT) {
2322 STm->default_density = (-1); 2334 STm->default_density = (-1);
2323 DEBC( printk(KERN_INFO "%s: Density default disabled.\n", 2335 DEBC_printk(STp,
2324 name)); 2336 "Density default disabled.\n");
2325 } else { 2337 } else {
2326 STm->default_density = value & 0xff; 2338 STm->default_density = value & 0xff;
2327 DEBC( printk(KERN_INFO "%s: Density default set to %x\n", 2339 DEBC_printk(STp, "Density default set to %x\n",
2328 name, STm->default_density)); 2340 STm->default_density);
2329 if (STp->ready == ST_READY) { 2341 if (STp->ready == ST_READY) {
2330 STp->density_changed = 0; 2342 STp->density_changed = 0;
2331 set_mode_densblk(STp, STm); 2343 set_mode_densblk(STp, STm);
@@ -2334,31 +2346,33 @@ static int st_set_options(struct scsi_tape *STp, long options)
2334 } else if (code == MT_ST_DEF_DRVBUFFER) { 2346 } else if (code == MT_ST_DEF_DRVBUFFER) {
2335 if (value == MT_ST_CLEAR_DEFAULT) { 2347 if (value == MT_ST_CLEAR_DEFAULT) {
2336 STp->default_drvbuffer = 0xff; 2348 STp->default_drvbuffer = 0xff;
2337 DEBC( printk(KERN_INFO 2349 DEBC_printk(STp,
2338 "%s: Drive buffer default disabled.\n", name)); 2350 "Drive buffer default disabled.\n");
2339 } else { 2351 } else {
2340 STp->default_drvbuffer = value & 7; 2352 STp->default_drvbuffer = value & 7;
2341 DEBC( printk(KERN_INFO 2353 DEBC_printk(STp,
2342 "%s: Drive buffer default set to %x\n", 2354 "Drive buffer default set to %x\n",
2343 name, STp->default_drvbuffer)); 2355 STp->default_drvbuffer);
2344 if (STp->ready == ST_READY) 2356 if (STp->ready == ST_READY)
2345 st_int_ioctl(STp, MTSETDRVBUFFER, STp->default_drvbuffer); 2357 st_int_ioctl(STp, MTSETDRVBUFFER, STp->default_drvbuffer);
2346 } 2358 }
2347 } else if (code == MT_ST_DEF_COMPRESSION) { 2359 } else if (code == MT_ST_DEF_COMPRESSION) {
2348 if (value == MT_ST_CLEAR_DEFAULT) { 2360 if (value == MT_ST_CLEAR_DEFAULT) {
2349 STm->default_compression = ST_DONT_TOUCH; 2361 STm->default_compression = ST_DONT_TOUCH;
2350 DEBC( printk(KERN_INFO 2362 DEBC_printk(STp,
2351 "%s: Compression default disabled.\n", name)); 2363 "Compression default disabled.\n");
2352 } else { 2364 } else {
2353 if ((value & 0xff00) != 0) { 2365 if ((value & 0xff00) != 0) {
2354 STp->c_algo = (value & 0xff00) >> 8; 2366 STp->c_algo = (value & 0xff00) >> 8;
2355 DEBC( printk(KERN_INFO "%s: Compression algorithm set to 0x%x.\n", 2367 DEBC_printk(STp, "Compression "
2356 name, STp->c_algo)); 2368 "algorithm set to 0x%x.\n",
2369 STp->c_algo);
2357 } 2370 }
2358 if ((value & 0xff) != 0xff) { 2371 if ((value & 0xff) != 0xff) {
2359 STm->default_compression = (value & 1 ? ST_YES : ST_NO); 2372 STm->default_compression = (value & 1 ? ST_YES : ST_NO);
2360 DEBC( printk(KERN_INFO "%s: Compression default set to %x\n", 2373 DEBC_printk(STp, "Compression default "
2361 name, (value & 1))); 2374 "set to %x\n",
2375 (value & 1));
2362 if (STp->ready == ST_READY) { 2376 if (STp->ready == ST_READY) {
2363 STp->compression_changed = 0; 2377 STp->compression_changed = 0;
2364 st_compression(STp, (STm->default_compression == ST_YES)); 2378 st_compression(STp, (STm->default_compression == ST_YES));
@@ -2473,7 +2487,6 @@ static int st_compression(struct scsi_tape * STp, int state)
2473 int retval; 2487 int retval;
2474 int mpoffs; /* Offset to mode page start */ 2488 int mpoffs; /* Offset to mode page start */
2475 unsigned char *b_data = (STp->buffer)->b_data; 2489 unsigned char *b_data = (STp->buffer)->b_data;
2476 DEB( char *name = tape_name(STp); )
2477 2490
2478 if (STp->ready != ST_READY) 2491 if (STp->ready != ST_READY)
2479 return (-EIO); 2492 return (-EIO);
@@ -2481,18 +2494,17 @@ static int st_compression(struct scsi_tape * STp, int state)
2481 /* Read the current page contents */ 2494 /* Read the current page contents */
2482 retval = read_mode_page(STp, COMPRESSION_PAGE, 0); 2495 retval = read_mode_page(STp, COMPRESSION_PAGE, 0);
2483 if (retval) { 2496 if (retval) {
2484 DEBC(printk(ST_DEB_MSG "%s: Compression mode page not supported.\n", 2497 DEBC_printk(STp, "Compression mode page not supported.\n");
2485 name));
2486 return (-EIO); 2498 return (-EIO);
2487 } 2499 }
2488 2500
2489 mpoffs = MODE_HEADER_LENGTH + b_data[MH_OFF_BDESCS_LENGTH]; 2501 mpoffs = MODE_HEADER_LENGTH + b_data[MH_OFF_BDESCS_LENGTH];
2490 DEBC(printk(ST_DEB_MSG "%s: Compression state is %d.\n", name, 2502 DEBC_printk(STp, "Compression state is %d.\n",
2491 (b_data[mpoffs + CP_OFF_DCE_DCC] & DCE_MASK ? 1 : 0))); 2503 (b_data[mpoffs + CP_OFF_DCE_DCC] & DCE_MASK ? 1 : 0));
2492 2504
2493 /* Check if compression can be changed */ 2505 /* Check if compression can be changed */
2494 if ((b_data[mpoffs + CP_OFF_DCE_DCC] & DCC_MASK) == 0) { 2506 if ((b_data[mpoffs + CP_OFF_DCE_DCC] & DCC_MASK) == 0) {
2495 DEBC(printk(ST_DEB_MSG "%s: Compression not supported.\n", name)); 2507 DEBC_printk(STp, "Compression not supported.\n");
2496 return (-EIO); 2508 return (-EIO);
2497 } 2509 }
2498 2510
@@ -2510,11 +2522,10 @@ static int st_compression(struct scsi_tape * STp, int state)
2510 2522
2511 retval = write_mode_page(STp, COMPRESSION_PAGE, 0); 2523 retval = write_mode_page(STp, COMPRESSION_PAGE, 0);
2512 if (retval) { 2524 if (retval) {
2513 DEBC(printk(ST_DEB_MSG "%s: Compression change failed.\n", name)); 2525 DEBC_printk(STp, "Compression change failed.\n");
2514 return (-EIO); 2526 return (-EIO);
2515 } 2527 }
2516 DEBC(printk(ST_DEB_MSG "%s: Compression state changed to %d.\n", 2528 DEBC_printk(STp, "Compression state changed to %d.\n", state);
2517 name, state));
2518 2529
2519 STp->compression_changed = 1; 2530 STp->compression_changed = 1;
2520 return 0; 2531 return 0;
@@ -2525,7 +2536,6 @@ static int st_compression(struct scsi_tape * STp, int state)
2525static int do_load_unload(struct scsi_tape *STp, struct file *filp, int load_code) 2536static int do_load_unload(struct scsi_tape *STp, struct file *filp, int load_code)
2526{ 2537{
2527 int retval = (-EIO), timeout; 2538 int retval = (-EIO), timeout;
2528 DEB( char *name = tape_name(STp); )
2529 unsigned char cmd[MAX_COMMAND_SIZE]; 2539 unsigned char cmd[MAX_COMMAND_SIZE];
2530 struct st_partstat *STps; 2540 struct st_partstat *STps;
2531 struct st_request *SRpnt; 2541 struct st_request *SRpnt;
@@ -2546,9 +2556,9 @@ static int do_load_unload(struct scsi_tape *STp, struct file *filp, int load_cod
2546 */ 2556 */
2547 if (load_code >= 1 + MT_ST_HPLOADER_OFFSET 2557 if (load_code >= 1 + MT_ST_HPLOADER_OFFSET
2548 && load_code <= 6 + MT_ST_HPLOADER_OFFSET) { 2558 && load_code <= 6 + MT_ST_HPLOADER_OFFSET) {
2549 DEBC(printk(ST_DEB_MSG "%s: Enhanced %sload slot %2d.\n", 2559 DEBC_printk(STp, " Enhanced %sload slot %2d.\n",
2550 name, (cmd[4]) ? "" : "un", 2560 (cmd[4]) ? "" : "un",
2551 load_code - MT_ST_HPLOADER_OFFSET)); 2561 load_code - MT_ST_HPLOADER_OFFSET);
2552 cmd[3] = load_code - MT_ST_HPLOADER_OFFSET; /* MediaID field of C1553A */ 2562 cmd[3] = load_code - MT_ST_HPLOADER_OFFSET; /* MediaID field of C1553A */
2553 } 2563 }
2554 if (STp->immediate) { 2564 if (STp->immediate) {
@@ -2560,9 +2570,9 @@ static int do_load_unload(struct scsi_tape *STp, struct file *filp, int load_cod
2560 2570
2561 DEBC( 2571 DEBC(
2562 if (!load_code) 2572 if (!load_code)
2563 printk(ST_DEB_MSG "%s: Unloading tape.\n", name); 2573 st_printk(ST_DEB_MSG, STp, "Unloading tape.\n");
2564 else 2574 else
2565 printk(ST_DEB_MSG "%s: Loading tape.\n", name); 2575 st_printk(ST_DEB_MSG, STp, "Loading tape.\n");
2566 ); 2576 );
2567 2577
2568 SRpnt = st_do_scsi(NULL, STp, cmd, 0, DMA_NONE, 2578 SRpnt = st_do_scsi(NULL, STp, cmd, 0, DMA_NONE,
@@ -2597,17 +2607,24 @@ static int do_load_unload(struct scsi_tape *STp, struct file *filp, int load_cod
2597#if DEBUG 2607#if DEBUG
2598#define ST_DEB_FORWARD 0 2608#define ST_DEB_FORWARD 0
2599#define ST_DEB_BACKWARD 1 2609#define ST_DEB_BACKWARD 1
2600static void deb_space_print(char *name, int direction, char *units, unsigned char *cmd) 2610static void deb_space_print(struct scsi_tape *STp, int direction, char *units, unsigned char *cmd)
2601{ 2611{
2602 s32 sc; 2612 s32 sc;
2603 2613
2614 if (!debugging)
2615 return;
2616
2604 sc = cmd[2] & 0x80 ? 0xff000000 : 0; 2617 sc = cmd[2] & 0x80 ? 0xff000000 : 0;
2605 sc |= (cmd[2] << 16) | (cmd[3] << 8) | cmd[4]; 2618 sc |= (cmd[2] << 16) | (cmd[3] << 8) | cmd[4];
2606 if (direction) 2619 if (direction)
2607 sc = -sc; 2620 sc = -sc;
2608 printk(ST_DEB_MSG "%s: Spacing tape %s over %d %s.\n", name, 2621 st_printk(ST_DEB_MSG, STp, "Spacing tape %s over %d %s.\n",
2609 direction ? "backward" : "forward", sc, units); 2622 direction ? "backward" : "forward", sc, units);
2610} 2623}
2624#else
2625#define ST_DEB_FORWARD 0
2626#define ST_DEB_BACKWARD 1
2627static void deb_space_print(struct scsi_tape *STp, int direction, char *units, unsigned char *cmd) {}
2611#endif 2628#endif
2612 2629
2613 2630
@@ -2623,7 +2640,6 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
2623 struct st_partstat *STps; 2640 struct st_partstat *STps;
2624 int fileno, blkno, at_sm, undone; 2641 int fileno, blkno, at_sm, undone;
2625 int datalen = 0, direction = DMA_NONE; 2642 int datalen = 0, direction = DMA_NONE;
2626 char *name = tape_name(STp);
2627 2643
2628 WARN_ON(STp->buffer->do_dio != 0); 2644 WARN_ON(STp->buffer->do_dio != 0);
2629 if (STp->ready != ST_READY) { 2645 if (STp->ready != ST_READY) {
@@ -2648,7 +2664,7 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
2648 cmd[2] = (arg >> 16); 2664 cmd[2] = (arg >> 16);
2649 cmd[3] = (arg >> 8); 2665 cmd[3] = (arg >> 8);
2650 cmd[4] = arg; 2666 cmd[4] = arg;
2651 DEBC(deb_space_print(name, ST_DEB_FORWARD, "filemarks", cmd);) 2667 deb_space_print(STp, ST_DEB_FORWARD, "filemarks", cmd);
2652 if (fileno >= 0) 2668 if (fileno >= 0)
2653 fileno += arg; 2669 fileno += arg;
2654 blkno = 0; 2670 blkno = 0;
@@ -2663,7 +2679,7 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
2663 cmd[2] = (ltmp >> 16); 2679 cmd[2] = (ltmp >> 16);
2664 cmd[3] = (ltmp >> 8); 2680 cmd[3] = (ltmp >> 8);
2665 cmd[4] = ltmp; 2681 cmd[4] = ltmp;
2666 DEBC(deb_space_print(name, ST_DEB_BACKWARD, "filemarks", cmd);) 2682 deb_space_print(STp, ST_DEB_BACKWARD, "filemarks", cmd);
2667 if (fileno >= 0) 2683 if (fileno >= 0)
2668 fileno -= arg; 2684 fileno -= arg;
2669 blkno = (-1); /* We can't know the block number */ 2685 blkno = (-1); /* We can't know the block number */
@@ -2675,7 +2691,7 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
2675 cmd[2] = (arg >> 16); 2691 cmd[2] = (arg >> 16);
2676 cmd[3] = (arg >> 8); 2692 cmd[3] = (arg >> 8);
2677 cmd[4] = arg; 2693 cmd[4] = arg;
2678 DEBC(deb_space_print(name, ST_DEB_FORWARD, "blocks", cmd);) 2694 deb_space_print(STp, ST_DEB_FORWARD, "blocks", cmd);
2679 if (blkno >= 0) 2695 if (blkno >= 0)
2680 blkno += arg; 2696 blkno += arg;
2681 at_sm &= (arg == 0); 2697 at_sm &= (arg == 0);
@@ -2687,7 +2703,7 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
2687 cmd[2] = (ltmp >> 16); 2703 cmd[2] = (ltmp >> 16);
2688 cmd[3] = (ltmp >> 8); 2704 cmd[3] = (ltmp >> 8);
2689 cmd[4] = ltmp; 2705 cmd[4] = ltmp;
2690 DEBC(deb_space_print(name, ST_DEB_BACKWARD, "blocks", cmd);) 2706 deb_space_print(STp, ST_DEB_BACKWARD, "blocks", cmd);
2691 if (blkno >= 0) 2707 if (blkno >= 0)
2692 blkno -= arg; 2708 blkno -= arg;
2693 at_sm &= (arg == 0); 2709 at_sm &= (arg == 0);
@@ -2698,7 +2714,7 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
2698 cmd[2] = (arg >> 16); 2714 cmd[2] = (arg >> 16);
2699 cmd[3] = (arg >> 8); 2715 cmd[3] = (arg >> 8);
2700 cmd[4] = arg; 2716 cmd[4] = arg;
2701 DEBC(deb_space_print(name, ST_DEB_FORWARD, "setmarks", cmd);) 2717 deb_space_print(STp, ST_DEB_FORWARD, "setmarks", cmd);
2702 if (arg != 0) { 2718 if (arg != 0) {
2703 blkno = fileno = (-1); 2719 blkno = fileno = (-1);
2704 at_sm = 1; 2720 at_sm = 1;
@@ -2711,7 +2727,7 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
2711 cmd[2] = (ltmp >> 16); 2727 cmd[2] = (ltmp >> 16);
2712 cmd[3] = (ltmp >> 8); 2728 cmd[3] = (ltmp >> 8);
2713 cmd[4] = ltmp; 2729 cmd[4] = ltmp;
2714 DEBC(deb_space_print(name, ST_DEB_BACKWARD, "setmarks", cmd);) 2730 deb_space_print(STp, ST_DEB_BACKWARD, "setmarks", cmd);
2715 if (arg != 0) { 2731 if (arg != 0) {
2716 blkno = fileno = (-1); 2732 blkno = fileno = (-1);
2717 at_sm = 1; 2733 at_sm = 1;
@@ -2732,13 +2748,19 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
2732 cmd[3] = (arg >> 8); 2748 cmd[3] = (arg >> 8);
2733 cmd[4] = arg; 2749 cmd[4] = arg;
2734 timeout = STp->device->request_queue->rq_timeout; 2750 timeout = STp->device->request_queue->rq_timeout;
2735 DEBC( 2751 DEBC(
2736 if (cmd_in != MTWSM) 2752 if (cmd_in != MTWSM)
2737 printk(ST_DEB_MSG "%s: Writing %d filemarks.\n", name, 2753 st_printk(ST_DEB_MSG, STp,
2738 cmd[2] * 65536 + cmd[3] * 256 + cmd[4]); 2754 "Writing %d filemarks.\n",
2739 else 2755 cmd[2] * 65536 +
2740 printk(ST_DEB_MSG "%s: Writing %d setmarks.\n", name, 2756 cmd[3] * 256 +
2741 cmd[2] * 65536 + cmd[3] * 256 + cmd[4]); 2757 cmd[4]);
2758 else
2759 st_printk(ST_DEB_MSG, STp,
2760 "Writing %d setmarks.\n",
2761 cmd[2] * 65536 +
2762 cmd[3] * 256 +
2763 cmd[4]);
2742 ) 2764 )
2743 if (fileno >= 0) 2765 if (fileno >= 0)
2744 fileno += arg; 2766 fileno += arg;
@@ -2751,11 +2773,11 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
2751 cmd[1] = 1; /* Don't wait for completion */ 2773 cmd[1] = 1; /* Don't wait for completion */
2752 timeout = STp->device->request_queue->rq_timeout; 2774 timeout = STp->device->request_queue->rq_timeout;
2753 } 2775 }
2754 DEBC(printk(ST_DEB_MSG "%s: Rewinding tape.\n", name)); 2776 DEBC_printk(STp, "Rewinding tape.\n");
2755 fileno = blkno = at_sm = 0; 2777 fileno = blkno = at_sm = 0;
2756 break; 2778 break;
2757 case MTNOP: 2779 case MTNOP:
2758 DEBC(printk(ST_DEB_MSG "%s: No op on tape.\n", name)); 2780 DEBC_printk(STp, "No op on tape.\n");
2759 return 0; /* Should do something ? */ 2781 return 0; /* Should do something ? */
2760 break; 2782 break;
2761 case MTRETEN: 2783 case MTRETEN:
@@ -2765,7 +2787,7 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
2765 timeout = STp->device->request_queue->rq_timeout; 2787 timeout = STp->device->request_queue->rq_timeout;
2766 } 2788 }
2767 cmd[4] = 3; 2789 cmd[4] = 3;
2768 DEBC(printk(ST_DEB_MSG "%s: Retensioning tape.\n", name)); 2790 DEBC_printk(STp, "Retensioning tape.\n");
2769 fileno = blkno = at_sm = 0; 2791 fileno = blkno = at_sm = 0;
2770 break; 2792 break;
2771 case MTEOM: 2793 case MTEOM:
@@ -2783,8 +2805,7 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
2783 fileno = (-1); 2805 fileno = (-1);
2784 cmd[0] = SPACE; 2806 cmd[0] = SPACE;
2785 cmd[1] = 3; 2807 cmd[1] = 3;
2786 DEBC(printk(ST_DEB_MSG "%s: Spacing to end of recorded medium.\n", 2808 DEBC_printk(STp, "Spacing to end of recorded medium.\n");
2787 name));
2788 blkno = -1; 2809 blkno = -1;
2789 at_sm = 0; 2810 at_sm = 0;
2790 break; 2811 break;
@@ -2800,7 +2821,7 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
2800 else 2821 else
2801 timeout = STp->long_timeout * 8; 2822 timeout = STp->long_timeout * 8;
2802 2823
2803 DEBC(printk(ST_DEB_MSG "%s: Erasing tape.\n", name)); 2824 DEBC_printk(STp, "Erasing tape.\n");
2804 fileno = blkno = at_sm = 0; 2825 fileno = blkno = at_sm = 0;
2805 break; 2826 break;
2806 case MTSETBLK: /* Set block length */ 2827 case MTSETBLK: /* Set block length */
@@ -2815,7 +2836,7 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
2815 STp->max_block > 0 && 2836 STp->max_block > 0 &&
2816 ((arg & MT_ST_BLKSIZE_MASK) < STp->min_block || 2837 ((arg & MT_ST_BLKSIZE_MASK) < STp->min_block ||
2817 (arg & MT_ST_BLKSIZE_MASK) > STp->max_block)) { 2838 (arg & MT_ST_BLKSIZE_MASK) > STp->max_block)) {
2818 printk(KERN_WARNING "%s: Illegal block size.\n", name); 2839 st_printk(KERN_WARNING, STp, "Illegal block size.\n");
2819 return (-EINVAL); 2840 return (-EINVAL);
2820 } 2841 }
2821 cmd[0] = MODE_SELECT; 2842 cmd[0] = MODE_SELECT;
@@ -2848,21 +2869,21 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
2848 (STp->buffer)->b_data[10] = (ltmp >> 8); 2869 (STp->buffer)->b_data[10] = (ltmp >> 8);
2849 (STp->buffer)->b_data[11] = ltmp; 2870 (STp->buffer)->b_data[11] = ltmp;
2850 timeout = STp->device->request_queue->rq_timeout; 2871 timeout = STp->device->request_queue->rq_timeout;
2851 DEBC( 2872 DEBC(
2852 if (cmd_in == MTSETBLK || cmd_in == SET_DENS_AND_BLK) 2873 if (cmd_in == MTSETBLK || cmd_in == SET_DENS_AND_BLK)
2853 printk(ST_DEB_MSG 2874 st_printk(ST_DEB_MSG, STp,
2854 "%s: Setting block size to %d bytes.\n", name, 2875 "Setting block size to %d bytes.\n",
2855 (STp->buffer)->b_data[9] * 65536 + 2876 (STp->buffer)->b_data[9] * 65536 +
2856 (STp->buffer)->b_data[10] * 256 + 2877 (STp->buffer)->b_data[10] * 256 +
2857 (STp->buffer)->b_data[11]); 2878 (STp->buffer)->b_data[11]);
2858 if (cmd_in == MTSETDENSITY || cmd_in == SET_DENS_AND_BLK) 2879 if (cmd_in == MTSETDENSITY || cmd_in == SET_DENS_AND_BLK)
2859 printk(ST_DEB_MSG 2880 st_printk(ST_DEB_MSG, STp,
2860 "%s: Setting density code to %x.\n", name, 2881 "Setting density code to %x.\n",
2861 (STp->buffer)->b_data[4]); 2882 (STp->buffer)->b_data[4]);
2862 if (cmd_in == MTSETDRVBUFFER) 2883 if (cmd_in == MTSETDRVBUFFER)
2863 printk(ST_DEB_MSG 2884 st_printk(ST_DEB_MSG, STp,
2864 "%s: Setting drive buffer code to %d.\n", name, 2885 "Setting drive buffer code to %d.\n",
2865 ((STp->buffer)->b_data[2] >> 4) & 7); 2886 ((STp->buffer)->b_data[2] >> 4) & 7);
2866 ) 2887 )
2867 break; 2888 break;
2868 default: 2889 default:
@@ -3019,7 +3040,6 @@ static int get_location(struct scsi_tape *STp, unsigned int *block, int *partiti
3019 int result; 3040 int result;
3020 unsigned char scmd[MAX_COMMAND_SIZE]; 3041 unsigned char scmd[MAX_COMMAND_SIZE];
3021 struct st_request *SRpnt; 3042 struct st_request *SRpnt;
3022 DEB( char *name = tape_name(STp); )
3023 3043
3024 if (STp->ready != ST_READY) 3044 if (STp->ready != ST_READY)
3025 return (-EIO); 3045 return (-EIO);
@@ -3043,7 +3063,7 @@ static int get_location(struct scsi_tape *STp, unsigned int *block, int *partiti
3043 (STp->device->scsi_level >= SCSI_2 && 3063 (STp->device->scsi_level >= SCSI_2 &&
3044 ((STp->buffer)->b_data[0] & 4) != 0)) { 3064 ((STp->buffer)->b_data[0] & 4) != 0)) {
3045 *block = *partition = 0; 3065 *block = *partition = 0;
3046 DEBC(printk(ST_DEB_MSG "%s: Can't read tape position.\n", name)); 3066 DEBC_printk(STp, " Can't read tape position.\n");
3047 result = (-EIO); 3067 result = (-EIO);
3048 } else { 3068 } else {
3049 result = 0; 3069 result = 0;
@@ -3062,8 +3082,8 @@ static int get_location(struct scsi_tape *STp, unsigned int *block, int *partiti
3062 (STp->buffer)->b_data[1] == 0) /* BOP of partition 0 */ 3082 (STp->buffer)->b_data[1] == 0) /* BOP of partition 0 */
3063 STp->ps[0].drv_block = STp->ps[0].drv_file = 0; 3083 STp->ps[0].drv_block = STp->ps[0].drv_file = 0;
3064 } 3084 }
3065 DEBC(printk(ST_DEB_MSG "%s: Got tape pos. blk %d part %d.\n", name, 3085 DEBC_printk(STp, "Got tape pos. blk %d part %d.\n",
3066 *block, *partition)); 3086 *block, *partition);
3067 } 3087 }
3068 st_release_request(SRpnt); 3088 st_release_request(SRpnt);
3069 SRpnt = NULL; 3089 SRpnt = NULL;
@@ -3083,15 +3103,14 @@ static int set_location(struct scsi_tape *STp, unsigned int block, int partition
3083 int timeout; 3103 int timeout;
3084 unsigned char scmd[MAX_COMMAND_SIZE]; 3104 unsigned char scmd[MAX_COMMAND_SIZE];
3085 struct st_request *SRpnt; 3105 struct st_request *SRpnt;
3086 DEB( char *name = tape_name(STp); )
3087 3106
3088 if (STp->ready != ST_READY) 3107 if (STp->ready != ST_READY)
3089 return (-EIO); 3108 return (-EIO);
3090 timeout = STp->long_timeout; 3109 timeout = STp->long_timeout;
3091 STps = &(STp->ps[STp->partition]); 3110 STps = &(STp->ps[STp->partition]);
3092 3111
3093 DEBC(printk(ST_DEB_MSG "%s: Setting block to %d and partition to %d.\n", 3112 DEBC_printk(STp, "Setting block to %d and partition to %d.\n",
3094 name, block, partition)); 3113 block, partition);
3095 DEB(if (partition < 0) 3114 DEB(if (partition < 0)
3096 return (-EIO); ) 3115 return (-EIO); )
3097 3116
@@ -3105,9 +3124,9 @@ static int set_location(struct scsi_tape *STp, unsigned int block, int partition
3105 else { 3124 else {
3106 STps->last_block_valid = 1; 3125 STps->last_block_valid = 1;
3107 STps->last_block_visited = blk; 3126 STps->last_block_visited = blk;
3108 DEBC(printk(ST_DEB_MSG 3127 DEBC_printk(STp, "Visited block %d for "
3109 "%s: Visited block %d for partition %d saved.\n", 3128 "partition %d saved.\n",
3110 name, blk, STp->partition)); 3129 blk, STp->partition);
3111 } 3130 }
3112 } 3131 }
3113 3132
@@ -3129,9 +3148,9 @@ static int set_location(struct scsi_tape *STp, unsigned int block, int partition
3129 if (STp->partition != partition) { 3148 if (STp->partition != partition) {
3130 scmd[1] |= 2; 3149 scmd[1] |= 2;
3131 scmd[8] = partition; 3150 scmd[8] = partition;
3132 DEBC(printk(ST_DEB_MSG 3151 DEBC_printk(STp, "Trying to change partition "
3133 "%s: Trying to change partition from %d to %d\n", 3152 "from %d to %d\n", STp->partition,
3134 name, STp->partition, partition)); 3153 partition);
3135 } 3154 }
3136 } 3155 }
3137 if (STp->immediate) { 3156 if (STp->immediate) {
@@ -3222,7 +3241,6 @@ static int switch_partition(struct scsi_tape *STp)
3222static int nbr_partitions(struct scsi_tape *STp) 3241static int nbr_partitions(struct scsi_tape *STp)
3223{ 3242{
3224 int result; 3243 int result;
3225 DEB( char *name = tape_name(STp); )
3226 3244
3227 if (STp->ready != ST_READY) 3245 if (STp->ready != ST_READY)
3228 return (-EIO); 3246 return (-EIO);
@@ -3230,13 +3248,12 @@ static int nbr_partitions(struct scsi_tape *STp)
3230 result = read_mode_page(STp, PART_PAGE, 1); 3248 result = read_mode_page(STp, PART_PAGE, 1);
3231 3249
3232 if (result) { 3250 if (result) {
3233 DEBC(printk(ST_DEB_MSG "%s: Can't read medium partition page.\n", 3251 DEBC_printk(STp, "Can't read medium partition page.\n");
3234 name));
3235 result = (-EIO); 3252 result = (-EIO);
3236 } else { 3253 } else {
3237 result = (STp->buffer)->b_data[MODE_HEADER_LENGTH + 3254 result = (STp->buffer)->b_data[MODE_HEADER_LENGTH +
3238 PP_OFF_NBR_ADD_PARTS] + 1; 3255 PP_OFF_NBR_ADD_PARTS] + 1;
3239 DEBC(printk(ST_DEB_MSG "%s: Number of partitions %d.\n", name, result)); 3256 DEBC_printk(STp, "Number of partitions %d.\n", result);
3240 } 3257 }
3241 3258
3242 return result; 3259 return result;
@@ -3264,21 +3281,20 @@ static int nbr_partitions(struct scsi_tape *STp)
3264 */ 3281 */
3265static int partition_tape(struct scsi_tape *STp, int size) 3282static int partition_tape(struct scsi_tape *STp, int size)
3266{ 3283{
3267 char *name = tape_name(STp);
3268 int result; 3284 int result;
3269 int pgo, psd_cnt, psdo; 3285 int pgo, psd_cnt, psdo;
3270 unsigned char *bp; 3286 unsigned char *bp;
3271 3287
3272 result = read_mode_page(STp, PART_PAGE, 0); 3288 result = read_mode_page(STp, PART_PAGE, 0);
3273 if (result) { 3289 if (result) {
3274 DEBC(printk(ST_DEB_MSG "%s: Can't read partition mode page.\n", name)); 3290 DEBC_printk(STp, "Can't read partition mode page.\n");
3275 return result; 3291 return result;
3276 } 3292 }
3277 /* The mode page is in the buffer. Let's modify it and write it. */ 3293 /* The mode page is in the buffer. Let's modify it and write it. */
3278 bp = (STp->buffer)->b_data; 3294 bp = (STp->buffer)->b_data;
3279 pgo = MODE_HEADER_LENGTH + bp[MH_OFF_BDESCS_LENGTH]; 3295 pgo = MODE_HEADER_LENGTH + bp[MH_OFF_BDESCS_LENGTH];
3280 DEBC(printk(ST_DEB_MSG "%s: Partition page length is %d bytes.\n", 3296 DEBC_printk(STp, "Partition page length is %d bytes.\n",
3281 name, bp[pgo + MP_OFF_PAGE_LENGTH] + 2)); 3297 bp[pgo + MP_OFF_PAGE_LENGTH] + 2);
3282 3298
3283 psd_cnt = (bp[pgo + MP_OFF_PAGE_LENGTH] + 2 - PART_PAGE_FIXED_LENGTH) / 2; 3299 psd_cnt = (bp[pgo + MP_OFF_PAGE_LENGTH] + 2 - PART_PAGE_FIXED_LENGTH) / 2;
3284 psdo = pgo + PART_PAGE_FIXED_LENGTH; 3300 psdo = pgo + PART_PAGE_FIXED_LENGTH;
@@ -3288,25 +3304,23 @@ static int partition_tape(struct scsi_tape *STp, int size)
3288 } 3304 }
3289 memset(bp + psdo, 0, bp[pgo + PP_OFF_NBR_ADD_PARTS] * 2); 3305 memset(bp + psdo, 0, bp[pgo + PP_OFF_NBR_ADD_PARTS] * 2);
3290 3306
3291 DEBC(printk("%s: psd_cnt %d, max.parts %d, nbr_parts %d\n", name, 3307 DEBC_printk(STp, "psd_cnt %d, max.parts %d, nbr_parts %d\n",
3292 psd_cnt, bp[pgo + PP_OFF_MAX_ADD_PARTS], 3308 psd_cnt, bp[pgo + PP_OFF_MAX_ADD_PARTS],
3293 bp[pgo + PP_OFF_NBR_ADD_PARTS])); 3309 bp[pgo + PP_OFF_NBR_ADD_PARTS]);
3294 3310
3295 if (size <= 0) { 3311 if (size <= 0) {
3296 bp[pgo + PP_OFF_NBR_ADD_PARTS] = 0; 3312 bp[pgo + PP_OFF_NBR_ADD_PARTS] = 0;
3297 if (psd_cnt <= bp[pgo + PP_OFF_MAX_ADD_PARTS]) 3313 if (psd_cnt <= bp[pgo + PP_OFF_MAX_ADD_PARTS])
3298 bp[pgo + MP_OFF_PAGE_LENGTH] = 6; 3314 bp[pgo + MP_OFF_PAGE_LENGTH] = 6;
3299 DEBC(printk(ST_DEB_MSG "%s: Formatting tape with one partition.\n", 3315 DEBC_printk(STp, "Formatting tape with one partition.\n");
3300 name));
3301 } else { 3316 } else {
3302 bp[psdo] = (size >> 8) & 0xff; 3317 bp[psdo] = (size >> 8) & 0xff;
3303 bp[psdo + 1] = size & 0xff; 3318 bp[psdo + 1] = size & 0xff;
3304 bp[pgo + 3] = 1; 3319 bp[pgo + 3] = 1;
3305 if (bp[pgo + MP_OFF_PAGE_LENGTH] < 8) 3320 if (bp[pgo + MP_OFF_PAGE_LENGTH] < 8)
3306 bp[pgo + MP_OFF_PAGE_LENGTH] = 8; 3321 bp[pgo + MP_OFF_PAGE_LENGTH] = 8;
3307 DEBC(printk(ST_DEB_MSG 3322 DEBC_printk(STp, "Formatting tape with two partitions "
3308 "%s: Formatting tape with two partitions (1 = %d MB).\n", 3323 "(1 = %d MB).\n", size);
3309 name, size));
3310 } 3324 }
3311 bp[pgo + PP_OFF_PART_UNITS] = 0; 3325 bp[pgo + PP_OFF_PART_UNITS] = 0;
3312 bp[pgo + PP_OFF_RESERVED] = 0; 3326 bp[pgo + PP_OFF_RESERVED] = 0;
@@ -3314,7 +3328,7 @@ static int partition_tape(struct scsi_tape *STp, int size)
3314 3328
3315 result = write_mode_page(STp, PART_PAGE, 1); 3329 result = write_mode_page(STp, PART_PAGE, 1);
3316 if (result) { 3330 if (result) {
3317 printk(KERN_INFO "%s: Partitioning of tape failed.\n", name); 3331 st_printk(KERN_INFO, STp, "Partitioning of tape failed.\n");
3318 result = (-EIO); 3332 result = (-EIO);
3319 } 3333 }
3320 3334
@@ -3332,15 +3346,14 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)
3332 struct scsi_tape *STp = file->private_data; 3346 struct scsi_tape *STp = file->private_data;
3333 struct st_modedef *STm; 3347 struct st_modedef *STm;
3334 struct st_partstat *STps; 3348 struct st_partstat *STps;
3335 char *name = tape_name(STp);
3336 void __user *p = (void __user *)arg; 3349 void __user *p = (void __user *)arg;
3337 3350
3338 if (mutex_lock_interruptible(&STp->lock)) 3351 if (mutex_lock_interruptible(&STp->lock))
3339 return -ERESTARTSYS; 3352 return -ERESTARTSYS;
3340 3353
3341 DEB( 3354 DEB(
3342 if (debugging && !STp->in_use) { 3355 if (debugging && !STp->in_use) {
3343 printk(ST_DEB_MSG "%s: Incorrect device.\n", name); 3356 st_printk(ST_DEB_MSG, STp, "Incorrect device.\n");
3344 retval = (-EIO); 3357 retval = (-EIO);
3345 goto out; 3358 goto out;
3346 } ) /* end DEB */ 3359 } ) /* end DEB */
@@ -3378,8 +3391,8 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)
3378 } 3391 }
3379 3392
3380 if (mtc.mt_op == MTSETDRVBUFFER && !capable(CAP_SYS_ADMIN)) { 3393 if (mtc.mt_op == MTSETDRVBUFFER && !capable(CAP_SYS_ADMIN)) {
3381 printk(KERN_WARNING 3394 st_printk(KERN_WARNING, STp,
3382 "%s: MTSETDRVBUFFER only allowed for root.\n", name); 3395 "MTSETDRVBUFFER only allowed for root.\n");
3383 retval = (-EPERM); 3396 retval = (-EPERM);
3384 goto out; 3397 goto out;
3385 } 3398 }
@@ -4087,7 +4100,8 @@ static int st_probe(struct device *dev)
4087 return -ENODEV; 4100 return -ENODEV;
4088 if ((stp = st_incompatible(SDp))) { 4101 if ((stp = st_incompatible(SDp))) {
4089 sdev_printk(KERN_INFO, SDp, "Found incompatible tape\n"); 4102 sdev_printk(KERN_INFO, SDp, "Found incompatible tape\n");
4090 printk(KERN_INFO "st: The suggested driver is %s.\n", stp); 4103 sdev_printk(KERN_INFO, SDp,
4104 "st: The suggested driver is %s.\n", stp);
4091 return -ENODEV; 4105 return -ENODEV;
4092 } 4106 }
4093 4107
@@ -4096,20 +4110,23 @@ static int st_probe(struct device *dev)
4096 i = st_max_sg_segs; 4110 i = st_max_sg_segs;
4097 buffer = new_tape_buffer((SDp->host)->unchecked_isa_dma, i); 4111 buffer = new_tape_buffer((SDp->host)->unchecked_isa_dma, i);
4098 if (buffer == NULL) { 4112 if (buffer == NULL) {
4099 printk(KERN_ERR 4113 sdev_printk(KERN_ERR, SDp,
4100 "st: Can't allocate new tape buffer. Device not attached.\n"); 4114 "st: Can't allocate new tape buffer. "
4115 "Device not attached.\n");
4101 goto out; 4116 goto out;
4102 } 4117 }
4103 4118
4104 disk = alloc_disk(1); 4119 disk = alloc_disk(1);
4105 if (!disk) { 4120 if (!disk) {
4106 printk(KERN_ERR "st: out of memory. Device not attached.\n"); 4121 sdev_printk(KERN_ERR, SDp,
4122 "st: out of memory. Device not attached.\n");
4107 goto out_buffer_free; 4123 goto out_buffer_free;
4108 } 4124 }
4109 4125
4110 tpnt = kzalloc(sizeof(struct scsi_tape), GFP_ATOMIC); 4126 tpnt = kzalloc(sizeof(struct scsi_tape), GFP_ATOMIC);
4111 if (tpnt == NULL) { 4127 if (tpnt == NULL) {
4112 printk(KERN_ERR "st: Can't allocate device descriptor.\n"); 4128 sdev_printk(KERN_ERR, SDp,
4129 "st: Can't allocate device descriptor.\n");
4113 goto out_put_disk; 4130 goto out_put_disk;
4114 } 4131 }
4115 kref_init(&tpnt->kref); 4132 kref_init(&tpnt->kref);