Commit 10e76361 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] tape_name() in st.c

	* new inlined helper: tape_name(tape)
	* most of TAPE_NR() uses replaced with that animal
("st%d ...", TAPE_NR(STp), ... -> "%s ...", tape_name(STp), ... )
parent 84e4e82e
...@@ -230,13 +230,18 @@ static char * st_incompatible(Scsi_Device* SDp) ...@@ -230,13 +230,18 @@ static char * st_incompatible(Scsi_Device* SDp)
} }
static inline char *tape_name(Scsi_Tape *tape)
{
return tape->name;
}
/* Convert the result to success code */ /* Convert the result to success code */
static int st_chk_result(Scsi_Tape *STp, Scsi_Request * SRpnt) static int st_chk_result(Scsi_Tape *STp, Scsi_Request * SRpnt)
{ {
int dev;
int result = SRpnt->sr_result; int result = SRpnt->sr_result;
unsigned char *sense = SRpnt->sr_sense_buffer, scode; unsigned char *sense = SRpnt->sr_sense_buffer, scode;
DEB(const char *stp;) DEB(const char *stp;)
char *name = tape_name(STp);
if (!result) { if (!result) {
sense[0] = 0; /* We don't have sense data if this byte is zero */ sense[0] = 0; /* We don't have sense data if this byte is zero */
...@@ -250,11 +255,10 @@ static int st_chk_result(Scsi_Tape *STp, Scsi_Request * SRpnt) ...@@ -250,11 +255,10 @@ static int st_chk_result(Scsi_Tape *STp, Scsi_Request * SRpnt)
scode = 0; scode = 0;
} }
dev = TAPE_NR(SRpnt->sr_request->rq_dev);
DEB( DEB(
if (debugging) { if (debugging) {
printk(ST_DEB_MSG "st%d: Error: %x, cmd: %x %x %x %x %x %x Len: %d\n", printk(ST_DEB_MSG "%s: Error: %x, cmd: %x %x %x %x %x %x Len: %d\n",
dev, result, name, result,
SRpnt->sr_cmnd[0], SRpnt->sr_cmnd[1], SRpnt->sr_cmnd[2], SRpnt->sr_cmnd[0], SRpnt->sr_cmnd[1], SRpnt->sr_cmnd[2],
SRpnt->sr_cmnd[3], SRpnt->sr_cmnd[4], SRpnt->sr_cmnd[5], SRpnt->sr_cmnd[3], SRpnt->sr_cmnd[4], SRpnt->sr_cmnd[5],
SRpnt->sr_bufflen); SRpnt->sr_bufflen);
...@@ -271,12 +275,12 @@ static int st_chk_result(Scsi_Tape *STp, Scsi_Request * SRpnt) ...@@ -271,12 +275,12 @@ static int st_chk_result(Scsi_Tape *STp, Scsi_Request * SRpnt)
SRpnt->sr_cmnd[0] != MODE_SENSE && SRpnt->sr_cmnd[0] != MODE_SENSE &&
SRpnt->sr_cmnd[0] != TEST_UNIT_READY)) { /* Abnormal conditions for tape */ SRpnt->sr_cmnd[0] != TEST_UNIT_READY)) { /* Abnormal conditions for tape */
if (driver_byte(result) & DRIVER_SENSE) { if (driver_byte(result) & DRIVER_SENSE) {
printk(KERN_WARNING "st%d: Error with sense data: ", dev); printk(KERN_WARNING "%s: Error with sense data: ", name);
print_req_sense("st", SRpnt); print_req_sense("st", SRpnt);
} else } else
printk(KERN_WARNING printk(KERN_WARNING
"st%d: Error %x (sugg. bt 0x%x, driver bt 0x%x, host bt 0x%x).\n", "%s: Error %x (sugg. bt 0x%x, driver bt 0x%x, host bt 0x%x).\n",
dev, result, suggestion(result), name, result, suggestion(result),
driver_byte(result) & DRIVER_MASK, host_byte(result)); driver_byte(result) & DRIVER_MASK, host_byte(result));
} }
...@@ -311,7 +315,7 @@ static int st_chk_result(Scsi_Tape *STp, Scsi_Request * SRpnt) ...@@ -311,7 +315,7 @@ static int st_chk_result(Scsi_Tape *STp, Scsi_Request * SRpnt)
stp = "write"; stp = "write";
else else
stp = "ioctl"; stp = "ioctl";
printk(ST_DEB_MSG "st%d: Recovered %s error (%d).\n", dev, stp, printk(ST_DEB_MSG "%s: Recovered %s error (%d).\n", name, stp,
STp->recover_count); STp->recover_count);
} ) /* end DEB */ } ) /* end DEB */
...@@ -358,7 +362,6 @@ static void st_sleep_done(Scsi_Cmnd * SCpnt) ...@@ -358,7 +362,6 @@ static void st_sleep_done(Scsi_Cmnd * SCpnt)
complete(SCpnt->request->waiting); complete(SCpnt->request->waiting);
} }
/* Do the scsi command. Waits until command performed if do_wait is true. /* Do the scsi command. Waits until command performed if do_wait is true.
Otherwise write_behind_check() is used to check that the command Otherwise write_behind_check() is used to check that the command
has finished. */ has finished. */
...@@ -371,8 +374,8 @@ static Scsi_Request * ...@@ -371,8 +374,8 @@ static Scsi_Request *
if (SRpnt == NULL) { if (SRpnt == NULL) {
SRpnt = scsi_allocate_request(STp->device); SRpnt = scsi_allocate_request(STp->device);
if (SRpnt == NULL) { if (SRpnt == NULL) {
DEBC( printk(KERN_ERR "st%d: Can't get SCSI request.\n", DEBC( printk(KERN_ERR "%s: Can't get SCSI request.\n",
TAPE_NR(STp->devt)); ); tape_name(STp)); );
if (signal_pending(current)) if (signal_pending(current))
(STp->buffer)->syscall_result = (-EINTR); (STp->buffer)->syscall_result = (-EINTR);
else else
...@@ -459,8 +462,8 @@ static int cross_eof(Scsi_Tape * STp, int forward) ...@@ -459,8 +462,8 @@ static int cross_eof(Scsi_Tape * STp, int forward)
cmd[2] = cmd[3] = cmd[4] = 0xff; /* -1 filemarks */ cmd[2] = cmd[3] = cmd[4] = 0xff; /* -1 filemarks */
cmd[5] = 0; cmd[5] = 0;
DEBC(printk(ST_DEB_MSG "st%d: Stepping over filemark %s.\n", DEBC(printk(ST_DEB_MSG "%s: Stepping over filemark %s.\n",
TAPE_NR(STp->devt), forward ? "forward" : "backward")); tape_name(STp), forward ? "forward" : "backward"));
SRpnt = st_do_scsi(NULL, STp, cmd, 0, SCSI_DATA_NONE, SRpnt = st_do_scsi(NULL, STp, cmd, 0, SCSI_DATA_NONE,
STp->timeout, MAX_RETRIES, TRUE); STp->timeout, MAX_RETRIES, TRUE);
...@@ -471,8 +474,8 @@ static int cross_eof(Scsi_Tape * STp, int forward) ...@@ -471,8 +474,8 @@ static int cross_eof(Scsi_Tape * STp, int forward)
SRpnt = NULL; SRpnt = NULL;
if ((STp->buffer)->midlevel_result != 0) if ((STp->buffer)->midlevel_result != 0)
printk(KERN_ERR "st%d: Stepping over filemark %s failed.\n", printk(KERN_ERR "%s: Stepping over filemark %s failed.\n",
TAPE_NR(STp->devt), forward ? "forward" : "backward"); tape_name(STp), forward ? "forward" : "backward");
return (STp->buffer)->syscall_result; return (STp->buffer)->syscall_result;
} }
...@@ -491,8 +494,8 @@ static int flush_write_buffer(Scsi_Tape * STp) ...@@ -491,8 +494,8 @@ static int flush_write_buffer(Scsi_Tape * STp)
write_behind_check(STp); write_behind_check(STp);
if ((STp->buffer)->syscall_result) { if ((STp->buffer)->syscall_result) {
DEBC(printk(ST_DEB_MSG DEBC(printk(ST_DEB_MSG
"st%d: Async write error (flush) %x.\n", "%s: Async write error (flush) %x.\n",
TAPE_NR(STp->devt), (STp->buffer)->midlevel_result)) tape_name(STp), (STp->buffer)->midlevel_result))
if ((STp->buffer)->midlevel_result == INT_MAX) if ((STp->buffer)->midlevel_result == INT_MAX)
return (-ENOSPC); return (-ENOSPC);
return (-EIO); return (-EIO);
...@@ -507,8 +510,8 @@ static int flush_write_buffer(Scsi_Tape * STp) ...@@ -507,8 +510,8 @@ static int flush_write_buffer(Scsi_Tape * STp)
offset = (STp->buffer)->buffer_bytes; offset = (STp->buffer)->buffer_bytes;
transfer = ((offset + STp->block_size - 1) / transfer = ((offset + STp->block_size - 1) /
STp->block_size) * STp->block_size; STp->block_size) * STp->block_size;
DEBC(printk(ST_DEB_MSG "st%d: Flushing %d bytes.\n", DEBC(printk(ST_DEB_MSG "%s: Flushing %d bytes.\n",
TAPE_NR(STp->devt), transfer)); tape_name(STp), transfer));
memset((STp->buffer)->b_data + offset, 0, transfer - offset); memset((STp->buffer)->b_data + offset, 0, transfer - offset);
...@@ -534,8 +537,8 @@ static int flush_write_buffer(Scsi_Tape * STp) ...@@ -534,8 +537,8 @@ static int flush_write_buffer(Scsi_Tape * STp)
(STp->buffer)->buffer_bytes = 0; (STp->buffer)->buffer_bytes = 0;
result = (-ENOSPC); result = (-ENOSPC);
} else { } else {
printk(KERN_ERR "st%d: Error on flush.\n", printk(KERN_ERR "%s: Error on flush.\n",
TAPE_NR(STp->devt)); tape_name(STp));
result = (-EIO); result = (-EIO);
} }
STps->drv_block = (-1); STps->drv_block = (-1);
...@@ -613,7 +616,7 @@ static int set_mode_densblk(Scsi_Tape * STp, ST_mode * STm) ...@@ -613,7 +616,7 @@ static int set_mode_densblk(Scsi_Tape * STp, ST_mode * STm)
{ {
int set_it = FALSE; int set_it = FALSE;
unsigned long arg; unsigned long arg;
int dev = TAPE_NR(STp->devt); char *name = tape_name(STp);
if (!STp->density_changed && if (!STp->density_changed &&
STm->default_density >= 0 && STm->default_density >= 0 &&
...@@ -633,8 +636,8 @@ static int set_mode_densblk(Scsi_Tape * STp, ST_mode * STm) ...@@ -633,8 +636,8 @@ static int set_mode_densblk(Scsi_Tape * STp, ST_mode * STm)
if (set_it && if (set_it &&
st_int_ioctl(STp, SET_DENS_AND_BLK, arg)) { st_int_ioctl(STp, SET_DENS_AND_BLK, arg)) {
printk(KERN_WARNING printk(KERN_WARNING
"st%d: Can't set default block size to %d bytes and density %x.\n", "%s: Can't set default block size to %d bytes and density %x.\n",
dev, STm->default_blksize, STm->default_density); name, STm->default_blksize, STm->default_density);
if (modes_defined) if (modes_defined)
return (-EINVAL); return (-EINVAL);
} }
...@@ -646,11 +649,11 @@ static int set_mode_densblk(Scsi_Tape * STp, ST_mode * STm) ...@@ -646,11 +649,11 @@ static int set_mode_densblk(Scsi_Tape * STp, ST_mode * STm)
static int do_door_lock(Scsi_Tape * STp, int do_lock) static int do_door_lock(Scsi_Tape * STp, int do_lock)
{ {
int retval, cmd; int retval, cmd;
DEB(int dev = TAPE_NR(STp->devt);) DEB(char *name = tape_name(STp);)
cmd = do_lock ? SCSI_IOCTL_DOORLOCK : SCSI_IOCTL_DOORUNLOCK; cmd = do_lock ? SCSI_IOCTL_DOORLOCK : SCSI_IOCTL_DOORUNLOCK;
DEBC(printk(ST_DEB_MSG "st%d: %socking drive door.\n", dev, DEBC(printk(ST_DEB_MSG "%s: %socking drive door.\n", name,
do_lock ? "L" : "Unl")); do_lock ? "L" : "Unl"));
retval = scsi_ioctl(STp->device, cmd, NULL); retval = scsi_ioctl(STp->device, cmd, NULL);
if (!retval) { if (!retval) {
...@@ -779,15 +782,15 @@ static int check_tape(Scsi_Tape *STp, struct file *filp) ...@@ -779,15 +782,15 @@ static int check_tape(Scsi_Tape *STp, struct file *filp)
Scsi_Request *SRpnt = NULL; Scsi_Request *SRpnt = NULL;
ST_mode *STm; ST_mode *STm;
ST_partstat *STps; ST_partstat *STps;
int dev = TAPE_NR(STp->devt); char *name = tape_name(STp);
struct inode *inode = filp->f_dentry->d_inode; struct inode *inode = filp->f_dentry->d_inode;
int mode = TAPE_MODE(inode->i_rdev); int mode = TAPE_MODE(inode->i_rdev);
STp->ready = ST_READY; STp->ready = ST_READY;
if (mode != STp->current_mode) { if (mode != STp->current_mode) {
DEBC(printk(ST_DEB_MSG "st%d: Mode change from %d to %d.\n", DEBC(printk(ST_DEB_MSG "%s: Mode change from %d to %d.\n",
dev, STp->current_mode, mode)); name, STp->current_mode, mode));
new_session = TRUE; new_session = TRUE;
STp->current_mode = mode; STp->current_mode = mode;
} }
...@@ -858,12 +861,12 @@ static int check_tape(Scsi_Tape *STp, struct file *filp) ...@@ -858,12 +861,12 @@ static int check_tape(Scsi_Tape *STp, struct file *filp)
(STp->buffer)->b_data[5]; (STp->buffer)->b_data[5];
if ( DEB( debugging || ) !STp->inited) if ( DEB( debugging || ) !STp->inited)
printk(KERN_WARNING printk(KERN_WARNING
"st%d: Block limits %d - %d bytes.\n", dev, "%s: Block limits %d - %d bytes.\n", name,
STp->min_block, STp->max_block); STp->min_block, STp->max_block);
} else { } else {
STp->min_block = STp->max_block = (-1); STp->min_block = STp->max_block = (-1);
DEBC(printk(ST_DEB_MSG "st%d: Can't read block limits.\n", DEBC(printk(ST_DEB_MSG "%s: Can't read block limits.\n",
dev)); name));
} }
} }
...@@ -879,14 +882,14 @@ static int check_tape(Scsi_Tape *STp, struct file *filp) ...@@ -879,14 +882,14 @@ static int check_tape(Scsi_Tape *STp, struct file *filp)
} }
if ((STp->buffer)->syscall_result != 0) { if ((STp->buffer)->syscall_result != 0) {
DEBC(printk(ST_DEB_MSG "st%d: No Mode Sense.\n", dev)); DEBC(printk(ST_DEB_MSG "%s: No Mode Sense.\n", name));
STp->block_size = ST_DEFAULT_BLOCK; /* Educated guess (?) */ STp->block_size = ST_DEFAULT_BLOCK; /* Educated guess (?) */
(STp->buffer)->syscall_result = 0; /* Prevent error propagation */ (STp->buffer)->syscall_result = 0; /* Prevent error propagation */
STp->drv_write_prot = 0; STp->drv_write_prot = 0;
} else { } else {
DEBC(printk(ST_DEB_MSG DEBC(printk(ST_DEB_MSG
"st%d: Mode sense. Length %d, medium %x, WBS %x, BLL %d\n", "%s: Mode sense. Length %d, medium %x, WBS %x, BLL %d\n",
dev, name,
(STp->buffer)->b_data[0], (STp->buffer)->b_data[1], (STp->buffer)->b_data[0], (STp->buffer)->b_data[1],
(STp->buffer)->b_data[2], (STp->buffer)->b_data[3])); (STp->buffer)->b_data[2], (STp->buffer)->b_data[3]));
...@@ -896,8 +899,8 @@ static int check_tape(Scsi_Tape *STp, struct file *filp) ...@@ -896,8 +899,8 @@ static int check_tape(Scsi_Tape *STp, struct file *filp)
STp->block_size = (STp->buffer)->b_data[9] * 65536 + STp->block_size = (STp->buffer)->b_data[9] * 65536 +
(STp->buffer)->b_data[10] * 256 + (STp->buffer)->b_data[11]; (STp->buffer)->b_data[10] * 256 + (STp->buffer)->b_data[11];
DEBC(printk(ST_DEB_MSG DEBC(printk(ST_DEB_MSG
"st%d: Density %x, tape length: %x, drv buffer: %d\n", "%s: Density %x, tape length: %x, drv buffer: %d\n",
dev, STp->density, (STp->buffer)->b_data[5] * 65536 + name, STp->density, (STp->buffer)->b_data[5] * 65536 +
(STp->buffer)->b_data[6] * 256 + (STp->buffer)->b_data[7], (STp->buffer)->b_data[6] * 256 + (STp->buffer)->b_data[7],
STp->drv_buffer)); STp->drv_buffer));
} }
...@@ -915,14 +918,14 @@ static int check_tape(Scsi_Tape *STp, struct file *filp) ...@@ -915,14 +918,14 @@ static int check_tape(Scsi_Tape *STp, struct file *filp)
(STp->buffer)->buffer_bytes = (STp->buffer)->read_pointer = 0; (STp->buffer)->buffer_bytes = (STp->buffer)->read_pointer = 0;
DEBC(printk(ST_DEB_MSG DEBC(printk(ST_DEB_MSG
"st%d: Block size: %d, buffer size: %d (%d blocks).\n", dev, "%s: Block size: %d, buffer size: %d (%d blocks).\n", name,
STp->block_size, (STp->buffer)->buffer_size, STp->block_size, (STp->buffer)->buffer_size,
(STp->buffer)->buffer_blocks)); (STp->buffer)->buffer_blocks));
if (STp->drv_write_prot) { if (STp->drv_write_prot) {
STp->write_prot = 1; STp->write_prot = 1;
DEBC(printk(ST_DEB_MSG "st%d: Write protected\n", dev)); DEBC(printk(ST_DEB_MSG "%s: Write protected\n", name));
if ((st_flags & O_ACCMODE) == O_WRONLY || if ((st_flags & O_ACCMODE) == O_WRONLY ||
(st_flags & O_ACCMODE) == O_RDWR) { (st_flags & O_ACCMODE) == O_RDWR) {
...@@ -936,7 +939,7 @@ static int check_tape(Scsi_Tape *STp, struct file *filp) ...@@ -936,7 +939,7 @@ static int check_tape(Scsi_Tape *STp, struct file *filp)
after the driver has been initialized with tape in the drive and the after the driver has been initialized with tape in the drive and the
partition support has been enabled. */ partition support has been enabled. */
DEBC(printk(ST_DEB_MSG DEBC(printk(ST_DEB_MSG
"st%d: Updating partition number in status.\n", dev)); "%s: Updating partition number in status.\n", name));
if ((STp->partition = find_partition(STp)) < 0) { if ((STp->partition = find_partition(STp)) < 0) {
retval = STp->partition; retval = STp->partition;
goto err_out; goto err_out;
...@@ -955,8 +958,8 @@ static int check_tape(Scsi_Tape *STp, struct file *filp) ...@@ -955,8 +958,8 @@ static int check_tape(Scsi_Tape *STp, struct file *filp)
if (STp->default_drvbuffer != 0xff) { if (STp->default_drvbuffer != 0xff) {
if (st_int_ioctl(STp, MTSETDRVBUFFER, STp->default_drvbuffer)) if (st_int_ioctl(STp, MTSETDRVBUFFER, STp->default_drvbuffer))
printk(KERN_WARNING printk(KERN_WARNING
"st%d: Can't set default drive buffering to %d.\n", "%s: Can't set default drive buffering to %d.\n",
dev, STp->default_drvbuffer); name, STp->default_drvbuffer);
} }
} }
...@@ -975,6 +978,7 @@ static int st_open(struct inode *inode, struct file *filp) ...@@ -975,6 +978,7 @@ static int st_open(struct inode *inode, struct file *filp)
Scsi_Tape *STp; Scsi_Tape *STp;
ST_partstat *STps; ST_partstat *STps;
int dev = TAPE_NR(inode->i_rdev); int dev = TAPE_NR(inode->i_rdev);
char *name;
write_lock(&st_dev_arr_lock); write_lock(&st_dev_arr_lock);
if (dev >= st_template.dev_max || scsi_tapes == NULL || if (dev >= st_template.dev_max || scsi_tapes == NULL ||
...@@ -982,10 +986,11 @@ static int st_open(struct inode *inode, struct file *filp) ...@@ -982,10 +986,11 @@ static int st_open(struct inode *inode, struct file *filp)
write_unlock(&st_dev_arr_lock); write_unlock(&st_dev_arr_lock);
return (-ENXIO); return (-ENXIO);
} }
name = tape_name(STp);
if (STp->in_use) { if (STp->in_use) {
write_unlock(&st_dev_arr_lock); write_unlock(&st_dev_arr_lock);
DEB( printk(ST_DEB_MSG "st%d: Device already in use.\n", dev); ) DEB( printk(ST_DEB_MSG "%s: Device already in use.\n", name); )
return (-EBUSY); return (-EBUSY);
} }
STp->in_use = 1; STp->in_use = 1;
...@@ -1003,7 +1008,7 @@ static int st_open(struct inode *inode, struct file *filp) ...@@ -1003,7 +1008,7 @@ static int st_open(struct inode *inode, struct file *filp)
/* See that we have at least a one page buffer available */ /* See that we have at least a one page buffer available */
if (!enlarge_buffer(STp->buffer, PAGE_SIZE, STp->restr_dma)) { if (!enlarge_buffer(STp->buffer, PAGE_SIZE, STp->restr_dma)) {
printk(KERN_WARNING "st%d: Can't allocate tape buffer.\n", dev); printk(KERN_WARNING "%s: Can't allocate tape buffer.\n", name);
retval = (-EOVERFLOW); retval = (-EOVERFLOW);
goto err_out; goto err_out;
} }
...@@ -1047,25 +1052,25 @@ static int st_open(struct inode *inode, struct file *filp) ...@@ -1047,25 +1052,25 @@ static int st_open(struct inode *inode, struct file *filp)
static int st_flush(struct file *filp) static int st_flush(struct file *filp)
{ {
int result = 0, result2; int result = 0, result2;
struct inode *inode = filp->f_dentry->d_inode;
kdev_t devt = inode->i_rdev;
int dev = TAPE_NR(devt);
unsigned char cmd[MAX_COMMAND_SIZE]; unsigned char cmd[MAX_COMMAND_SIZE];
Scsi_Request *SRpnt; Scsi_Request *SRpnt;
Scsi_Tape *STp; Scsi_Tape *STp;
ST_mode *STm; ST_mode *STm;
ST_partstat *STps; ST_partstat *STps;
char *name;
struct inode *inode = filp->f_dentry->d_inode;
kdev_t devt = inode->i_rdev;
int dev;
if (file_count(filp) > 1) if (file_count(filp) > 1)
return 0; return 0;
dev = TAPE_NR(devt);
read_lock(&st_dev_arr_lock); read_lock(&st_dev_arr_lock);
STp = scsi_tapes[dev]; STp = scsi_tapes[dev];
read_unlock(&st_dev_arr_lock); read_unlock(&st_dev_arr_lock);
STm = &(STp->modes[STp->current_mode]); STm = &(STp->modes[STp->current_mode]);
STps = &(STp->ps[STp->partition]); STps = &(STp->ps[STp->partition]);
name = tape_name(STp);
if (STps->rw == ST_WRITING && !STp->pos_unknown) { if (STps->rw == ST_WRITING && !STp->pos_unknown) {
result = flush_write_buffer(STp); result = flush_write_buffer(STp);
...@@ -1076,22 +1081,22 @@ static int st_flush(struct file *filp) ...@@ -1076,22 +1081,22 @@ static int st_flush(struct file *filp)
if (STp->can_partitions && if (STp->can_partitions &&
(result2 = switch_partition(STp)) < 0) { (result2 = switch_partition(STp)) < 0) {
DEBC(printk(ST_DEB_MSG DEBC(printk(ST_DEB_MSG
"st%d: switch_partition at close failed.\n", dev)); "%s: switch_partition at close failed.\n", name));
if (result == 0) if (result == 0)
result = result2; result = result2;
goto out; goto out;
} }
DEBC( if (STp->nbr_requests) DEBC( if (STp->nbr_requests)
printk(KERN_WARNING "st%d: Number of r/w requests %d, dio used in %d, pages %d (%d).\n", printk(KERN_WARNING "%s: Number of r/w requests %d, dio used in %d, pages %d (%d).\n",
dev, STp->nbr_requests, STp->nbr_dio, STp->nbr_pages, STp->nbr_combinable)); name, STp->nbr_requests, STp->nbr_dio, STp->nbr_pages, STp->nbr_combinable));
if (STps->rw == ST_WRITING && !STp->pos_unknown) { if (STps->rw == ST_WRITING && !STp->pos_unknown) {
DEBC(printk(ST_DEB_MSG "st%d: File length %ld bytes.\n", DEBC(printk(ST_DEB_MSG "%s: File length %ld bytes.\n",
dev, (long) (filp->f_pos)); name, (long) (filp->f_pos));
printk(ST_DEB_MSG "st%d: Async write waits %d, finished %d.\n", printk(ST_DEB_MSG "%s: Async write waits %d, finished %d.\n",
dev, STp->nbr_waits, STp->nbr_finished); name, STp->nbr_waits, STp->nbr_finished);
) )
memset(cmd, 0, MAX_COMMAND_SIZE); memset(cmd, 0, MAX_COMMAND_SIZE);
...@@ -1115,7 +1120,7 @@ static int st_flush(struct file *filp) ...@@ -1115,7 +1120,7 @@ static int st_flush(struct file *filp)
/* Filter out successful write at EOM */ /* Filter out successful write at EOM */
scsi_release_request(SRpnt); scsi_release_request(SRpnt);
SRpnt = NULL; SRpnt = NULL;
printk(KERN_ERR "st%d: Error on write filemark.\n", dev); printk(KERN_ERR "%s: Error on write filemark.\n", name);
if (result == 0) if (result == 0)
result = (-EIO); result = (-EIO);
} else { } else {
...@@ -1129,8 +1134,8 @@ static int st_flush(struct file *filp) ...@@ -1129,8 +1134,8 @@ static int st_flush(struct file *filp)
STps->eof = ST_FM; STps->eof = ST_FM;
} }
DEBC(printk(ST_DEB_MSG "st%d: Buffer flushed, %d EOF(s) written\n", DEBC(printk(ST_DEB_MSG "%s: Buffer flushed, %d EOF(s) written\n",
dev, cmd[4])); name, cmd[4]));
} else if (!STp->rew_at_close) { } else if (!STp->rew_at_close) {
STps = &(STp->ps[STp->partition]); STps = &(STp->ps[STp->partition]);
if (!STm->sysv || STps->rw != ST_READING) { if (!STm->sysv || STps->rw != ST_READING) {
...@@ -1245,8 +1250,7 @@ static ssize_t rw_checks(Scsi_Tape *STp, struct file *filp, size_t count, loff_t ...@@ -1245,8 +1250,7 @@ static ssize_t rw_checks(Scsi_Tape *STp, struct file *filp, size_t count, loff_t
DEB( DEB(
if (!STp->in_use) { if (!STp->in_use) {
int dev = TAPE_NR(filp->f_dentry->d_inode->i_rdev); printk(ST_DEB_MSG "%s: Incorrect device.\n", tape_name(STp));
printk(ST_DEB_MSG "st%d: Incorrect device.\n", dev);
retval = (-EIO); retval = (-EIO);
goto out; goto out;
} ) /* end DEB */ } ) /* end DEB */
...@@ -1342,10 +1346,12 @@ static ssize_t ...@@ -1342,10 +1346,12 @@ static ssize_t
ST_partstat *STps; ST_partstat *STps;
ST_buffer *STbp; ST_buffer *STbp;
int dev = TAPE_NR(inode->i_rdev); int dev = TAPE_NR(inode->i_rdev);
char *name;
read_lock(&st_dev_arr_lock); read_lock(&st_dev_arr_lock);
STp = scsi_tapes[dev]; STp = scsi_tapes[dev];
read_unlock(&st_dev_arr_lock); read_unlock(&st_dev_arr_lock);
name = tape_name(STp);
if (down_interruptible(&STp->lock)) if (down_interruptible(&STp->lock))
return -ERESTARTSYS; return -ERESTARTSYS;
...@@ -1356,8 +1362,8 @@ static ssize_t ...@@ -1356,8 +1362,8 @@ static ssize_t
/* Write must be integral number of blocks */ /* Write must be integral number of blocks */
if (STp->block_size != 0 && (count % STp->block_size) != 0) { if (STp->block_size != 0 && (count % STp->block_size) != 0) {
printk(KERN_WARNING "st%d: Write not multiple of tape block size.\n", printk(KERN_WARNING "%s: Write not multiple of tape block size.\n",
dev); name);
retval = (-EINVAL); retval = (-EINVAL);
goto out; goto out;
} }
...@@ -1383,8 +1389,8 @@ static ssize_t ...@@ -1383,8 +1389,8 @@ static ssize_t
if (STm->default_compression != ST_DONT_TOUCH && if (STm->default_compression != ST_DONT_TOUCH &&
!(STp->compression_changed)) { !(STp->compression_changed)) {
if (st_compression(STp, (STm->default_compression == ST_YES))) { if (st_compression(STp, (STm->default_compression == ST_YES))) {
printk(KERN_WARNING "st%d: Can't set default compression.\n", printk(KERN_WARNING "%s: Can't set default compression.\n",
dev); name);
if (modes_defined) { if (modes_defined) {
retval = (-EINVAL); retval = (-EINVAL);
goto out; goto out;
...@@ -1397,8 +1403,8 @@ static ssize_t ...@@ -1397,8 +1403,8 @@ static ssize_t
if (STbp->writing) { if (STbp->writing) {
write_behind_check(STp); write_behind_check(STp);
if (STbp->syscall_result) { if (STbp->syscall_result) {
DEBC(printk(ST_DEB_MSG "st%d: Async write error (write) %x.\n", DEBC(printk(ST_DEB_MSG "%s: Async write error (write) %x.\n",
dev, STbp->midlevel_result)); name, STbp->midlevel_result));
if (STbp->midlevel_result == INT_MAX) if (STbp->midlevel_result == INT_MAX)
STps->eof = ST_EOM_OK; STps->eof = ST_EOM_OK;
else else
...@@ -1508,7 +1514,7 @@ static ssize_t ...@@ -1508,7 +1514,7 @@ static ssize_t
} }
if (STbp->syscall_result != 0) { if (STbp->syscall_result != 0) {
DEBC(printk(ST_DEB_MSG "st%d: Error on write:\n", dev)); DEBC(printk(ST_DEB_MSG "%s: Error on write:\n", name));
if ((SRpnt->sr_sense_buffer[0] & 0x70) == 0x70 && if ((SRpnt->sr_sense_buffer[0] & 0x70) == 0x70 &&
(SRpnt->sr_sense_buffer[2] & 0x40)) { (SRpnt->sr_sense_buffer[2] & 0x40)) {
if ((SRpnt->sr_sense_buffer[0] & 0x80) != 0) if ((SRpnt->sr_sense_buffer[0] & 0x80) != 0)
...@@ -1540,8 +1546,8 @@ static ssize_t ...@@ -1540,8 +1546,8 @@ static ssize_t
undone > 0 || count == 0) undone > 0 || count == 0)
retval = (-ENOSPC); /* EOM within current request */ retval = (-ENOSPC); /* EOM within current request */
DEBC(printk(ST_DEB_MSG DEBC(printk(ST_DEB_MSG
"st%d: EOM with %d bytes unwritten.\n", "%s: EOM with %d bytes unwritten.\n",
dev, transfer)); name, transfer));
} else { } else {
/* Previously buffered data not written */ /* Previously buffered data not written */
count -= do_count; count -= do_count;
...@@ -1550,8 +1556,8 @@ static ssize_t ...@@ -1550,8 +1556,8 @@ static ssize_t
STps->drv_block = (-1); /* Too cautious? */ STps->drv_block = (-1); /* Too cautious? */
retval = (-EIO); /* EOM for old data */ retval = (-EIO); /* EOM for old data */
DEBC(printk(ST_DEB_MSG DEBC(printk(ST_DEB_MSG
"st%d: EOM with lost data.\n", "%s: EOM with lost data.\n",
dev)); name));
} }
} else { } else {
filp->f_pos -= do_count; filp->f_pos -= do_count;
...@@ -1608,8 +1614,8 @@ static long read_tape(Scsi_Tape *STp, long count, Scsi_Request ** aSRpnt) ...@@ -1608,8 +1614,8 @@ static long read_tape(Scsi_Tape *STp, long count, Scsi_Request ** aSRpnt)
ST_mode *STm; ST_mode *STm;
ST_partstat *STps; ST_partstat *STps;
ST_buffer *STbp; ST_buffer *STbp;
int dev = TAPE_NR(STp->devt);
int retval = 0; int retval = 0;
char *name = tape_name(STp);
if (count == 0) if (count == 0)
return 0; return 0;
...@@ -1655,8 +1661,8 @@ static long read_tape(Scsi_Tape *STp, long count, Scsi_Request ** aSRpnt) ...@@ -1655,8 +1661,8 @@ static long read_tape(Scsi_Tape *STp, long count, Scsi_Request ** aSRpnt)
/* Something to check */ /* Something to check */
if (STbp->syscall_result) { if (STbp->syscall_result) {
retval = 1; retval = 1;
DEBC(printk(ST_DEB_MSG "st%d: Sense: %2x %2x %2x %2x %2x %2x %2x %2x\n", DEBC(printk(ST_DEB_MSG "%s: Sense: %2x %2x %2x %2x %2x %2x %2x %2x\n",
dev, name,
SRpnt->sr_sense_buffer[0], SRpnt->sr_sense_buffer[1], SRpnt->sr_sense_buffer[0], SRpnt->sr_sense_buffer[1],
SRpnt->sr_sense_buffer[2], SRpnt->sr_sense_buffer[3], SRpnt->sr_sense_buffer[2], SRpnt->sr_sense_buffer[3],
SRpnt->sr_sense_buffer[4], SRpnt->sr_sense_buffer[5], SRpnt->sr_sense_buffer[4], SRpnt->sr_sense_buffer[5],
...@@ -1691,7 +1697,7 @@ static long read_tape(Scsi_Tape *STp, long count, Scsi_Request ** aSRpnt) ...@@ -1691,7 +1697,7 @@ static long read_tape(Scsi_Tape *STp, long count, Scsi_Request ** aSRpnt)
scsi_release_request(SRpnt); scsi_release_request(SRpnt);
SRpnt = *aSRpnt = NULL; SRpnt = *aSRpnt = NULL;
if (transfer == blks) { /* We did not get anything, error */ if (transfer == blks) { /* We did not get anything, error */
printk(KERN_NOTICE "st%d: Incorrect block size.\n", dev); printk(KERN_NOTICE "%s: Incorrect block size.\n", name);
if (STps->drv_block >= 0) if (STps->drv_block >= 0)
STps->drv_block += blks - transfer + 1; STps->drv_block += blks - transfer + 1;
st_int_ioctl(STp, MTBSR, 1); st_int_ioctl(STp, MTBSR, 1);
...@@ -1701,8 +1707,8 @@ static long read_tape(Scsi_Tape *STp, long count, Scsi_Request ** aSRpnt) ...@@ -1701,8 +1707,8 @@ static long read_tape(Scsi_Tape *STp, long count, Scsi_Request ** aSRpnt)
STbp->buffer_bytes = (blks - transfer) * STbp->buffer_bytes = (blks - transfer) *
STp->block_size; STp->block_size;
DEBC(printk(ST_DEB_MSG DEBC(printk(ST_DEB_MSG
"st%d: ILI but enough data received %ld %d.\n", "%s: ILI but enough data received %ld %d.\n",
dev, count, STbp->buffer_bytes)); name, count, STbp->buffer_bytes));
if (STps->drv_block >= 0) if (STps->drv_block >= 0)
STps->drv_block += 1; STps->drv_block += 1;
if (st_int_ioctl(STp, MTBSR, 1)) if (st_int_ioctl(STp, MTBSR, 1))
...@@ -1719,8 +1725,8 @@ static long read_tape(Scsi_Tape *STp, long count, Scsi_Request ** aSRpnt) ...@@ -1719,8 +1725,8 @@ static long read_tape(Scsi_Tape *STp, long count, Scsi_Request ** aSRpnt)
STbp->buffer_bytes = STbp->buffer_bytes =
bytes - transfer * STp->block_size; bytes - transfer * STp->block_size;
DEBC(printk(ST_DEB_MSG DEBC(printk(ST_DEB_MSG
"st%d: EOF detected (%d bytes read).\n", "%s: EOF detected (%d bytes read).\n",
dev, STbp->buffer_bytes)); name, STbp->buffer_bytes));
} else if (SRpnt->sr_sense_buffer[2] & 0x40) { } else if (SRpnt->sr_sense_buffer[2] & 0x40) {
if (STps->eof == ST_FM) if (STps->eof == ST_FM)
STps->eof = ST_EOD_1; STps->eof = ST_EOD_1;
...@@ -1732,20 +1738,20 @@ static long read_tape(Scsi_Tape *STp, long count, Scsi_Request ** aSRpnt) ...@@ -1732,20 +1738,20 @@ static long read_tape(Scsi_Tape *STp, long count, Scsi_Request ** aSRpnt)
STbp->buffer_bytes = STbp->buffer_bytes =
bytes - transfer * STp->block_size; bytes - transfer * STp->block_size;
DEBC(printk(ST_DEB_MSG "st%d: EOM detected (%d bytes read).\n", DEBC(printk(ST_DEB_MSG "%s: EOM detected (%d bytes read).\n",
dev, STbp->buffer_bytes)); name, STbp->buffer_bytes));
} }
} }
/* end of EOF, EOM, ILI test */ /* end of EOF, EOM, ILI test */
else { /* nonzero sense key */ else { /* nonzero sense key */
DEBC(printk(ST_DEB_MSG DEBC(printk(ST_DEB_MSG
"st%d: Tape error while reading.\n", dev)); "%s: Tape error while reading.\n", name));
STps->drv_block = (-1); STps->drv_block = (-1);
if (STps->eof == ST_FM && if (STps->eof == ST_FM &&
(SRpnt->sr_sense_buffer[2] & 0x0f) == BLANK_CHECK) { (SRpnt->sr_sense_buffer[2] & 0x0f) == BLANK_CHECK) {
DEBC(printk(ST_DEB_MSG DEBC(printk(ST_DEB_MSG
"st%d: Zero returned for first BLANK CHECK after EOF.\n", "%s: Zero returned for first BLANK CHECK after EOF.\n",
dev)); name));
STps->eof = ST_EOD_2; /* First BLANK_CHECK after FM */ STps->eof = ST_EOD_2; /* First BLANK_CHECK after FM */
} else /* Some other extended sense code */ } else /* Some other extended sense code */
retval = (-EIO); retval = (-EIO);
...@@ -1786,10 +1792,12 @@ static ssize_t ...@@ -1786,10 +1792,12 @@ static ssize_t
ST_partstat *STps; ST_partstat *STps;
ST_buffer *STbp; ST_buffer *STbp;
int dev = TAPE_NR(inode->i_rdev); int dev = TAPE_NR(inode->i_rdev);
char *name;
read_lock(&st_dev_arr_lock); read_lock(&st_dev_arr_lock);
STp = scsi_tapes[dev]; STp = scsi_tapes[dev];
read_unlock(&st_dev_arr_lock); read_unlock(&st_dev_arr_lock);
name = tape_name(STp);
STbp = STp->buffer; STbp = STp->buffer;
if (down_interruptible(&STp->lock)) if (down_interruptible(&STp->lock))
...@@ -1815,7 +1823,7 @@ static ssize_t ...@@ -1815,7 +1823,7 @@ static ssize_t
} }
DEB( DEB(
if (debugging && STps->eof != ST_NOEOF) if (debugging && STps->eof != ST_NOEOF)
printk(ST_DEB_MSG "st%d: EOF/EOM flag up (%d). Bytes %d\n", dev, printk(ST_DEB_MSG "%s: EOF/EOM flag up (%d). Bytes %d\n", name,
STps->eof, STbp->buffer_bytes); STps->eof, STbp->buffer_bytes);
) /* end DEB */ ) /* end DEB */
...@@ -1866,7 +1874,7 @@ static ssize_t ...@@ -1866,7 +1874,7 @@ static ssize_t
DEB( DEB(
if (debugging && STps->eof != ST_NOEOF) if (debugging && STps->eof != ST_NOEOF)
printk(ST_DEB_MSG printk(ST_DEB_MSG
"st%d: EOF up (%d). Left %d, needed %d.\n", dev, "%s: EOF up (%d). Left %d, needed %d.\n", name,
STps->eof, STbp->buffer_bytes, STps->eof, STbp->buffer_bytes,
count - total); count - total);
) /* end DEB */ ) /* end DEB */
...@@ -1926,24 +1934,24 @@ static ssize_t ...@@ -1926,24 +1934,24 @@ static ssize_t
/* Set the driver options */ /* Set the driver options */
static void st_log_options(Scsi_Tape * STp, ST_mode * STm, int dev) static void st_log_options(Scsi_Tape * STp, ST_mode * STm, char *name)
{ {
printk(KERN_INFO printk(KERN_INFO
"st%d: Mode %d options: buffer writes: %d, async writes: %d, read ahead: %d\n", "%s: Mode %d options: buffer writes: %d, async writes: %d, read ahead: %d\n",
dev, STp->current_mode, STm->do_buffer_writes, STm->do_async_writes, name, STp->current_mode, STm->do_buffer_writes, STm->do_async_writes,
STm->do_read_ahead); STm->do_read_ahead);
printk(KERN_INFO printk(KERN_INFO
"st%d: can bsr: %d, two FMs: %d, fast mteom: %d, auto lock: %d,\n", "%s: can bsr: %d, two FMs: %d, fast mteom: %d, auto lock: %d,\n",
dev, STp->can_bsr, STp->two_fm, STp->fast_mteom, STp->do_auto_lock); name, STp->can_bsr, STp->two_fm, STp->fast_mteom, STp->do_auto_lock);
printk(KERN_INFO printk(KERN_INFO
"st%d: defs for wr: %d, no block limits: %d, partitions: %d, s2 log: %d\n", "%s: defs for wr: %d, no block limits: %d, partitions: %d, s2 log: %d\n",
dev, STm->defaults_for_writes, STp->omit_blklims, STp->can_partitions, name, STm->defaults_for_writes, STp->omit_blklims, STp->can_partitions,
STp->scsi2_logical); STp->scsi2_logical);
printk(KERN_INFO printk(KERN_INFO
"st%d: sysv: %d nowait: %d\n", dev, STm->sysv, STp->immediate); "%s: sysv: %d nowait: %d\n", name, STm->sysv, STp->immediate);
DEB(printk(KERN_INFO DEB(printk(KERN_INFO
"st%d: debugging: %d\n", "%s: debugging: %d\n",
dev, debugging);) name, debugging);)
} }
...@@ -1952,15 +1960,15 @@ static int st_set_options(Scsi_Tape *STp, long options) ...@@ -1952,15 +1960,15 @@ static int st_set_options(Scsi_Tape *STp, long options)
int value; int value;
long code; long code;
ST_mode *STm; ST_mode *STm;
int dev = TAPE_NR(STp->devt); char *name = tape_name(STp);
STm = &(STp->modes[STp->current_mode]); STm = &(STp->modes[STp->current_mode]);
if (!STm->defined) { if (!STm->defined) {
memcpy(STm, &(STp->modes[0]), sizeof(ST_mode)); memcpy(STm, &(STp->modes[0]), sizeof(ST_mode));
modes_defined = TRUE; modes_defined = TRUE;
DEBC(printk(ST_DEB_MSG DEBC(printk(ST_DEB_MSG
"st%d: Initialized mode %d definition from mode 0\n", "%s: Initialized mode %d definition from mode 0\n",
dev, STp->current_mode)); name, STp->current_mode));
} }
code = options & MT_ST_OPTIONS; code = options & MT_ST_OPTIONS;
...@@ -1980,7 +1988,7 @@ static int st_set_options(Scsi_Tape *STp, long options) ...@@ -1980,7 +1988,7 @@ static int st_set_options(Scsi_Tape *STp, long options)
STp->immediate = (options & MT_ST_NOWAIT) != 0; STp->immediate = (options & MT_ST_NOWAIT) != 0;
STm->sysv = (options & MT_ST_SYSV) != 0; STm->sysv = (options & MT_ST_SYSV) != 0;
DEB( debugging = (options & MT_ST_DEBUGGING) != 0; ) DEB( debugging = (options & MT_ST_DEBUGGING) != 0; )
st_log_options(STp, STm, dev); st_log_options(STp, STm, name);
} else if (code == MT_ST_SETBOOLEANS || code == MT_ST_CLEARBOOLEANS) { } else if (code == MT_ST_SETBOOLEANS || code == MT_ST_CLEARBOOLEANS) {
value = (code == MT_ST_SETBOOLEANS); value = (code == MT_ST_SETBOOLEANS);
if ((options & MT_ST_BUFFER_WRITES) != 0) if ((options & MT_ST_BUFFER_WRITES) != 0)
...@@ -2013,27 +2021,27 @@ static int st_set_options(Scsi_Tape *STp, long options) ...@@ -2013,27 +2021,27 @@ static int st_set_options(Scsi_Tape *STp, long options)
DEB( DEB(
if ((options & MT_ST_DEBUGGING) != 0) if ((options & MT_ST_DEBUGGING) != 0)
debugging = value; ) debugging = value; )
st_log_options(STp, STm, dev); st_log_options(STp, STm, name);
} else if (code == MT_ST_WRITE_THRESHOLD) { } else if (code == MT_ST_WRITE_THRESHOLD) {
value = (options & ~MT_ST_OPTIONS) * ST_KILOBYTE; value = (options & ~MT_ST_OPTIONS) * ST_KILOBYTE;
if (value < 1 || value > st_fixed_buffer_size) { if (value < 1 || value > st_fixed_buffer_size) {
printk(KERN_WARNING printk(KERN_WARNING
"st%d: Write threshold %d too small or too large.\n", "%s: Write threshold %d too small or too large.\n",
dev, value); name, value);
return (-EIO); return (-EIO);
} }
STp->write_threshold = value; STp->write_threshold = value;
printk(KERN_INFO "st%d: Write threshold set to %d bytes.\n", printk(KERN_INFO "%s: Write threshold set to %d bytes.\n",
dev, value); name, value);
} else if (code == MT_ST_DEF_BLKSIZE) { } else if (code == MT_ST_DEF_BLKSIZE) {
value = (options & ~MT_ST_OPTIONS); value = (options & ~MT_ST_OPTIONS);
if (value == ~MT_ST_OPTIONS) { if (value == ~MT_ST_OPTIONS) {
STm->default_blksize = (-1); STm->default_blksize = (-1);
printk(KERN_INFO "st%d: Default block size disabled.\n", dev); printk(KERN_INFO "%s: Default block size disabled.\n", name);
} else { } else {
STm->default_blksize = value; STm->default_blksize = value;
printk(KERN_INFO "st%d: Default block size set to %d bytes.\n", printk(KERN_INFO "%s: Default block size set to %d bytes.\n",
dev, STm->default_blksize); name, STm->default_blksize);
if (STp->ready == ST_READY) { if (STp->ready == ST_READY) {
STp->blksize_changed = FALSE; STp->blksize_changed = FALSE;
set_mode_densblk(STp, STm); set_mode_densblk(STp, STm);
...@@ -2043,12 +2051,12 @@ static int st_set_options(Scsi_Tape *STp, long options) ...@@ -2043,12 +2051,12 @@ static int st_set_options(Scsi_Tape *STp, long options)
value = (options & ~MT_ST_OPTIONS); value = (options & ~MT_ST_OPTIONS);
if ((value & MT_ST_SET_LONG_TIMEOUT) != 0) { if ((value & MT_ST_SET_LONG_TIMEOUT) != 0) {
STp->long_timeout = (value & ~MT_ST_SET_LONG_TIMEOUT) * HZ; STp->long_timeout = (value & ~MT_ST_SET_LONG_TIMEOUT) * HZ;
printk(KERN_INFO "st%d: Long timeout set to %d seconds.\n", dev, printk(KERN_INFO "%s: Long timeout set to %d seconds.\n", name,
(value & ~MT_ST_SET_LONG_TIMEOUT)); (value & ~MT_ST_SET_LONG_TIMEOUT));
} else { } else {
STp->timeout = value * HZ; STp->timeout = value * HZ;
printk(KERN_INFO "st%d: Normal timeout set to %d seconds.\n", printk(KERN_INFO "%s: Normal timeout set to %d seconds.\n",
dev, value); name, value);
} }
} else if (code == MT_ST_SET_CLN) { } else if (code == MT_ST_SET_CLN) {
value = (options & ~MT_ST_OPTIONS) & 0xff; value = (options & ~MT_ST_OPTIONS) & 0xff;
...@@ -2059,20 +2067,20 @@ static int st_set_options(Scsi_Tape *STp, long options) ...@@ -2059,20 +2067,20 @@ static int st_set_options(Scsi_Tape *STp, long options)
STp->cln_sense_mask = (options >> 8) & 0xff; STp->cln_sense_mask = (options >> 8) & 0xff;
STp->cln_sense_value = (options >> 16) & 0xff; STp->cln_sense_value = (options >> 16) & 0xff;
printk(KERN_INFO printk(KERN_INFO
"st%d: Cleaning request mode %d, mask %02x, value %02x\n", "%s: Cleaning request mode %d, mask %02x, value %02x\n",
dev, value, STp->cln_sense_mask, STp->cln_sense_value); name, value, STp->cln_sense_mask, STp->cln_sense_value);
} else if (code == MT_ST_DEF_OPTIONS) { } else if (code == MT_ST_DEF_OPTIONS) {
code = (options & ~MT_ST_CLEAR_DEFAULT); code = (options & ~MT_ST_CLEAR_DEFAULT);
value = (options & MT_ST_CLEAR_DEFAULT); value = (options & MT_ST_CLEAR_DEFAULT);
if (code == MT_ST_DEF_DENSITY) { if (code == MT_ST_DEF_DENSITY) {
if (value == MT_ST_CLEAR_DEFAULT) { if (value == MT_ST_CLEAR_DEFAULT) {
STm->default_density = (-1); STm->default_density = (-1);
printk(KERN_INFO "st%d: Density default disabled.\n", printk(KERN_INFO "%s: Density default disabled.\n",
dev); name);
} else { } else {
STm->default_density = value & 0xff; STm->default_density = value & 0xff;
printk(KERN_INFO "st%d: Density default set to %x\n", printk(KERN_INFO "%s: Density default set to %x\n",
dev, STm->default_density); name, STm->default_density);
if (STp->ready == ST_READY) { if (STp->ready == ST_READY) {
STp->density_changed = FALSE; STp->density_changed = FALSE;
set_mode_densblk(STp, STm); set_mode_densblk(STp, STm);
...@@ -2082,12 +2090,12 @@ static int st_set_options(Scsi_Tape *STp, long options) ...@@ -2082,12 +2090,12 @@ static int st_set_options(Scsi_Tape *STp, long options)
if (value == MT_ST_CLEAR_DEFAULT) { if (value == MT_ST_CLEAR_DEFAULT) {
STp->default_drvbuffer = 0xff; STp->default_drvbuffer = 0xff;
printk(KERN_INFO printk(KERN_INFO
"st%d: Drive buffer default disabled.\n", dev); "%s: Drive buffer default disabled.\n", name);
} else { } else {
STp->default_drvbuffer = value & 7; STp->default_drvbuffer = value & 7;
printk(KERN_INFO printk(KERN_INFO
"st%d: Drive buffer default set to %x\n", "%s: Drive buffer default set to %x\n",
dev, STp->default_drvbuffer); name, STp->default_drvbuffer);
if (STp->ready == ST_READY) if (STp->ready == ST_READY)
st_int_ioctl(STp, MTSETDRVBUFFER, STp->default_drvbuffer); st_int_ioctl(STp, MTSETDRVBUFFER, STp->default_drvbuffer);
} }
...@@ -2095,17 +2103,17 @@ static int st_set_options(Scsi_Tape *STp, long options) ...@@ -2095,17 +2103,17 @@ static int st_set_options(Scsi_Tape *STp, long options)
if (value == MT_ST_CLEAR_DEFAULT) { if (value == MT_ST_CLEAR_DEFAULT) {
STm->default_compression = ST_DONT_TOUCH; STm->default_compression = ST_DONT_TOUCH;
printk(KERN_INFO printk(KERN_INFO
"st%d: Compression default disabled.\n", dev); "%s: Compression default disabled.\n", name);
} else { } else {
if ((value & 0xff00) != 0) { if ((value & 0xff00) != 0) {
STp->c_algo = (value & 0xff00) >> 8; STp->c_algo = (value & 0xff00) >> 8;
printk(KERN_INFO "st%d: Compression algorithm set to 0x%x.\n", printk(KERN_INFO "%s: Compression algorithm set to 0x%x.\n",
dev, STp->c_algo); name, STp->c_algo);
} }
if ((value & 0xff) != 0xff) { if ((value & 0xff) != 0xff) {
STm->default_compression = (value & 1 ? ST_YES : ST_NO); STm->default_compression = (value & 1 ? ST_YES : ST_NO);
printk(KERN_INFO "st%d: Compression default set to %x\n", printk(KERN_INFO "%s: Compression default set to %x\n",
dev, (value & 1)); name, (value & 1));
if (STp->ready == ST_READY) { if (STp->ready == ST_READY) {
STp->compression_changed = FALSE; STp->compression_changed = FALSE;
st_compression(STp, (STm->default_compression == ST_YES)); st_compression(STp, (STm->default_compression == ST_YES));
...@@ -2217,7 +2225,7 @@ static int st_compression(Scsi_Tape * STp, int state) ...@@ -2217,7 +2225,7 @@ static int st_compression(Scsi_Tape * STp, int state)
int retval; int retval;
int mpoffs; /* Offset to mode page start */ int mpoffs; /* Offset to mode page start */
unsigned char *b_data = (STp->buffer)->b_data; unsigned char *b_data = (STp->buffer)->b_data;
DEB( int dev = TAPE_NR(STp->devt); ) DEB( char *name = tape_name(STp); )
if (STp->ready != ST_READY) if (STp->ready != ST_READY)
return (-EIO); return (-EIO);
...@@ -2225,18 +2233,18 @@ static int st_compression(Scsi_Tape * STp, int state) ...@@ -2225,18 +2233,18 @@ static int st_compression(Scsi_Tape * STp, int state)
/* Read the current page contents */ /* Read the current page contents */
retval = read_mode_page(STp, COMPRESSION_PAGE, FALSE); retval = read_mode_page(STp, COMPRESSION_PAGE, FALSE);
if (retval) { if (retval) {
DEBC(printk(ST_DEB_MSG "st%d: Compression mode page not supported.\n", DEBC(printk(ST_DEB_MSG "%s: Compression mode page not supported.\n",
dev)); name));
return (-EIO); return (-EIO);
} }
mpoffs = MODE_HEADER_LENGTH + b_data[MH_OFF_BDESCS_LENGTH]; mpoffs = MODE_HEADER_LENGTH + b_data[MH_OFF_BDESCS_LENGTH];
DEBC(printk(ST_DEB_MSG "st%d: Compression state is %d.\n", dev, DEBC(printk(ST_DEB_MSG "%s: Compression state is %d.\n", name,
(b_data[mpoffs + CP_OFF_DCE_DCC] & DCE_MASK ? 1 : 0))); (b_data[mpoffs + CP_OFF_DCE_DCC] & DCE_MASK ? 1 : 0)));
/* Check if compression can be changed */ /* Check if compression can be changed */
if ((b_data[mpoffs + CP_OFF_DCE_DCC] & DCC_MASK) == 0) { if ((b_data[mpoffs + CP_OFF_DCE_DCC] & DCC_MASK) == 0) {
DEBC(printk(ST_DEB_MSG "st%d: Compression not supported.\n", dev)); DEBC(printk(ST_DEB_MSG "%s: Compression not supported.\n", name));
return (-EIO); return (-EIO);
} }
...@@ -2254,11 +2262,11 @@ static int st_compression(Scsi_Tape * STp, int state) ...@@ -2254,11 +2262,11 @@ static int st_compression(Scsi_Tape * STp, int state)
retval = write_mode_page(STp, COMPRESSION_PAGE); retval = write_mode_page(STp, COMPRESSION_PAGE);
if (retval) { if (retval) {
DEBC(printk(ST_DEB_MSG "st%d: Compression change failed.\n", dev)); DEBC(printk(ST_DEB_MSG "%s: Compression change failed.\n", name));
return (-EIO); return (-EIO);
} }
DEBC(printk(ST_DEB_MSG "st%d: Compression state changed to %d.\n", DEBC(printk(ST_DEB_MSG "%s: Compression state changed to %d.\n",
dev, state)); name, state));
STp->compression_changed = TRUE; STp->compression_changed = TRUE;
return 0; return 0;
...@@ -2269,7 +2277,7 @@ static int st_compression(Scsi_Tape * STp, int state) ...@@ -2269,7 +2277,7 @@ static int st_compression(Scsi_Tape * STp, int state)
static int do_load_unload(Scsi_Tape *STp, struct file *filp, int load_code) static int do_load_unload(Scsi_Tape *STp, struct file *filp, int load_code)
{ {
int retval = (-EIO), timeout; int retval = (-EIO), timeout;
DEB(int dev = TAPE_NR(STp->devt);) DEB( char *name = tape_name(STp); )
unsigned char cmd[MAX_COMMAND_SIZE]; unsigned char cmd[MAX_COMMAND_SIZE];
ST_partstat *STps; ST_partstat *STps;
Scsi_Request *SRpnt; Scsi_Request *SRpnt;
...@@ -2290,8 +2298,8 @@ static int do_load_unload(Scsi_Tape *STp, struct file *filp, int load_code) ...@@ -2290,8 +2298,8 @@ static int do_load_unload(Scsi_Tape *STp, struct file *filp, int load_code)
*/ */
if (load_code >= 1 + MT_ST_HPLOADER_OFFSET if (load_code >= 1 + MT_ST_HPLOADER_OFFSET
&& load_code <= 6 + MT_ST_HPLOADER_OFFSET) { && load_code <= 6 + MT_ST_HPLOADER_OFFSET) {
DEBC(printk(ST_DEB_MSG "st%d: Enhanced %sload slot %2d.\n", DEBC(printk(ST_DEB_MSG "%s: Enhanced %sload slot %2d.\n",
dev, (cmd[4]) ? "" : "un", name, (cmd[4]) ? "" : "un",
load_code - MT_ST_HPLOADER_OFFSET)); load_code - MT_ST_HPLOADER_OFFSET));
cmd[3] = load_code - MT_ST_HPLOADER_OFFSET; /* MediaID field of C1553A */ cmd[3] = load_code - MT_ST_HPLOADER_OFFSET; /* MediaID field of C1553A */
} }
...@@ -2304,9 +2312,9 @@ static int do_load_unload(Scsi_Tape *STp, struct file *filp, int load_code) ...@@ -2304,9 +2312,9 @@ static int do_load_unload(Scsi_Tape *STp, struct file *filp, int load_code)
DEBC( DEBC(
if (!load_code) if (!load_code)
printk(ST_DEB_MSG "st%d: Unloading tape.\n", dev); printk(ST_DEB_MSG "%s: Unloading tape.\n", name);
else else
printk(ST_DEB_MSG "st%d: Loading tape.\n", dev); printk(ST_DEB_MSG "%s: Loading tape.\n", name);
); );
SRpnt = st_do_scsi(NULL, STp, cmd, 0, SCSI_DATA_NONE, SRpnt = st_do_scsi(NULL, STp, cmd, 0, SCSI_DATA_NONE,
...@@ -2351,7 +2359,7 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg) ...@@ -2351,7 +2359,7 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg)
ST_partstat *STps; ST_partstat *STps;
int fileno, blkno, at_sm, undone; int fileno, blkno, at_sm, undone;
int datalen = 0, direction = SCSI_DATA_NONE; int datalen = 0, direction = SCSI_DATA_NONE;
int dev = TAPE_NR(STp->devt); char *name = tape_name(STp);
if (STp->ready != ST_READY) { if (STp->ready != ST_READY) {
if (STp->ready == ST_NO_TAPE) if (STp->ready == ST_NO_TAPE)
...@@ -2375,8 +2383,8 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg) ...@@ -2375,8 +2383,8 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg)
cmd[2] = (arg >> 16); cmd[2] = (arg >> 16);
cmd[3] = (arg >> 8); cmd[3] = (arg >> 8);
cmd[4] = arg; cmd[4] = arg;
DEBC(printk(ST_DEB_MSG "st%d: Spacing tape forward over %d filemarks.\n", DEBC(printk(ST_DEB_MSG "%s: Spacing tape forward over %d filemarks.\n",
dev, cmd[2] * 65536 + cmd[3] * 256 + cmd[4])); name, cmd[2] * 65536 + cmd[3] * 256 + cmd[4]));
if (fileno >= 0) if (fileno >= 0)
fileno += arg; fileno += arg;
blkno = 0; blkno = 0;
...@@ -2396,8 +2404,8 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg) ...@@ -2396,8 +2404,8 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg)
ltmp = 0xff000000; ltmp = 0xff000000;
ltmp = ltmp | (cmd[2] << 16) | (cmd[3] << 8) | cmd[4]; ltmp = ltmp | (cmd[2] << 16) | (cmd[3] << 8) | cmd[4];
printk(ST_DEB_MSG printk(ST_DEB_MSG
"st%d: Spacing tape backward over %ld filemarks.\n", "%s: Spacing tape backward over %ld filemarks.\n",
dev, (-ltmp)); name, (-ltmp));
) )
if (fileno >= 0) if (fileno >= 0)
fileno -= arg; fileno -= arg;
...@@ -2410,7 +2418,7 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg) ...@@ -2410,7 +2418,7 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg)
cmd[2] = (arg >> 16); cmd[2] = (arg >> 16);
cmd[3] = (arg >> 8); cmd[3] = (arg >> 8);
cmd[4] = arg; cmd[4] = arg;
DEBC(printk(ST_DEB_MSG "st%d: Spacing tape forward %d blocks.\n", dev, DEBC(printk(ST_DEB_MSG "%s: Spacing tape forward %d blocks.\n", name,
cmd[2] * 65536 + cmd[3] * 256 + cmd[4])); cmd[2] * 65536 + cmd[3] * 256 + cmd[4]));
if (blkno >= 0) if (blkno >= 0)
blkno += arg; blkno += arg;
...@@ -2428,7 +2436,7 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg) ...@@ -2428,7 +2436,7 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg)
ltmp = 0xff000000; ltmp = 0xff000000;
ltmp = ltmp | (cmd[2] << 16) | (cmd[3] << 8) | cmd[4]; ltmp = ltmp | (cmd[2] << 16) | (cmd[3] << 8) | cmd[4];
printk(ST_DEB_MSG printk(ST_DEB_MSG
"st%d: Spacing tape backward %ld blocks.\n", dev, (-ltmp)); "%s: Spacing tape backward %ld blocks.\n", name, (-ltmp));
) )
if (blkno >= 0) if (blkno >= 0)
blkno -= arg; blkno -= arg;
...@@ -2440,7 +2448,7 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg) ...@@ -2440,7 +2448,7 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg)
cmd[2] = (arg >> 16); cmd[2] = (arg >> 16);
cmd[3] = (arg >> 8); cmd[3] = (arg >> 8);
cmd[4] = arg; cmd[4] = arg;
DEBC(printk(ST_DEB_MSG "st%d: Spacing tape forward %d setmarks.\n", dev, DEBC(printk(ST_DEB_MSG "%s: Spacing tape forward %d setmarks.\n", name,
cmd[2] * 65536 + cmd[3] * 256 + cmd[4])); cmd[2] * 65536 + cmd[3] * 256 + cmd[4]));
if (arg != 0) { if (arg != 0) {
blkno = fileno = (-1); blkno = fileno = (-1);
...@@ -2458,8 +2466,8 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg) ...@@ -2458,8 +2466,8 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg)
if (cmd[2] & 0x80) if (cmd[2] & 0x80)
ltmp = 0xff000000; ltmp = 0xff000000;
ltmp = ltmp | (cmd[2] << 16) | (cmd[3] << 8) | cmd[4]; ltmp = ltmp | (cmd[2] << 16) | (cmd[3] << 8) | cmd[4];
printk(ST_DEB_MSG "st%d: Spacing tape backward %ld setmarks.\n", printk(ST_DEB_MSG "%s: Spacing tape backward %ld setmarks.\n",
dev, (-ltmp)); name, (-ltmp));
) )
if (arg != 0) { if (arg != 0) {
blkno = fileno = (-1); blkno = fileno = (-1);
...@@ -2479,10 +2487,10 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg) ...@@ -2479,10 +2487,10 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg)
timeout = STp->timeout; timeout = STp->timeout;
DEBC( DEBC(
if (cmd_in == MTWEOF) if (cmd_in == MTWEOF)
printk(ST_DEB_MSG "st%d: Writing %d filemarks.\n", dev, printk(ST_DEB_MSG "%s: Writing %d filemarks.\n", name,
cmd[2] * 65536 + cmd[3] * 256 + cmd[4]); cmd[2] * 65536 + cmd[3] * 256 + cmd[4]);
else else
printk(ST_DEB_MSG "st%d: Writing %d setmarks.\n", dev, printk(ST_DEB_MSG "%s: Writing %d setmarks.\n", name,
cmd[2] * 65536 + cmd[3] * 256 + cmd[4]); cmd[2] * 65536 + cmd[3] * 256 + cmd[4]);
) )
if (fileno >= 0) if (fileno >= 0)
...@@ -2496,11 +2504,11 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg) ...@@ -2496,11 +2504,11 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg)
cmd[1] = 1; /* Don't wait for completion */ cmd[1] = 1; /* Don't wait for completion */
timeout = STp->timeout; timeout = STp->timeout;
} }
DEBC(printk(ST_DEB_MSG "st%d: Rewinding tape.\n", dev)); DEBC(printk(ST_DEB_MSG "%s: Rewinding tape.\n", name));
fileno = blkno = at_sm = 0; fileno = blkno = at_sm = 0;
break; break;
case MTNOP: case MTNOP:
DEBC(printk(ST_DEB_MSG "st%d: No op on tape.\n", dev)); DEBC(printk(ST_DEB_MSG "%s: No op on tape.\n", name));
return 0; /* Should do something ? */ return 0; /* Should do something ? */
break; break;
case MTRETEN: case MTRETEN:
...@@ -2510,7 +2518,7 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg) ...@@ -2510,7 +2518,7 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg)
timeout = STp->timeout; timeout = STp->timeout;
} }
cmd[4] = 3; cmd[4] = 3;
DEBC(printk(ST_DEB_MSG "st%d: Retensioning tape.\n", dev)); DEBC(printk(ST_DEB_MSG "%s: Retensioning tape.\n", name));
fileno = blkno = at_sm = 0; fileno = blkno = at_sm = 0;
break; break;
case MTEOM: case MTEOM:
...@@ -2528,8 +2536,8 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg) ...@@ -2528,8 +2536,8 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg)
fileno = (-1); fileno = (-1);
cmd[0] = SPACE; cmd[0] = SPACE;
cmd[1] = 3; cmd[1] = 3;
DEBC(printk(ST_DEB_MSG "st%d: Spacing to end of recorded medium.\n", DEBC(printk(ST_DEB_MSG "%s: Spacing to end of recorded medium.\n",
dev)); name));
blkno = 0; blkno = 0;
at_sm = 0; at_sm = 0;
break; break;
...@@ -2545,7 +2553,7 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg) ...@@ -2545,7 +2553,7 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg)
else else
timeout = STp->long_timeout * 8; timeout = STp->long_timeout * 8;
DEBC(printk(ST_DEB_MSG "st%d: Erasing tape.\n", dev)); DEBC(printk(ST_DEB_MSG "%s: Erasing tape.\n", name));
fileno = blkno = at_sm = 0; fileno = blkno = at_sm = 0;
break; break;
case MTSETBLK: /* Set block length */ case MTSETBLK: /* Set block length */
...@@ -2560,7 +2568,7 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg) ...@@ -2560,7 +2568,7 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg)
STp->max_block > 0 && STp->max_block > 0 &&
((arg & MT_ST_BLKSIZE_MASK) < STp->min_block || ((arg & MT_ST_BLKSIZE_MASK) < STp->min_block ||
(arg & MT_ST_BLKSIZE_MASK) > STp->max_block)) { (arg & MT_ST_BLKSIZE_MASK) > STp->max_block)) {
printk(KERN_WARNING "st%d: Illegal block size.\n", dev); printk(KERN_WARNING "%s: Illegal block size.\n", name);
return (-EINVAL); return (-EINVAL);
} }
cmd[0] = MODE_SELECT; cmd[0] = MODE_SELECT;
...@@ -2596,17 +2604,17 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg) ...@@ -2596,17 +2604,17 @@ static int st_int_ioctl(Scsi_Tape *STp, unsigned int cmd_in, unsigned long arg)
DEBC( DEBC(
if (cmd_in == MTSETBLK || cmd_in == SET_DENS_AND_BLK) if (cmd_in == MTSETBLK || cmd_in == SET_DENS_AND_BLK)
printk(ST_DEB_MSG printk(ST_DEB_MSG
"st%d: Setting block size to %d bytes.\n", dev, "%s: Setting block size to %d bytes.\n", name,
(STp->buffer)->b_data[9] * 65536 + (STp->buffer)->b_data[9] * 65536 +
(STp->buffer)->b_data[10] * 256 + (STp->buffer)->b_data[10] * 256 +
(STp->buffer)->b_data[11]); (STp->buffer)->b_data[11]);
if (cmd_in == MTSETDENSITY || cmd_in == SET_DENS_AND_BLK) if (cmd_in == MTSETDENSITY || cmd_in == SET_DENS_AND_BLK)
printk(ST_DEB_MSG printk(ST_DEB_MSG
"st%d: Setting density code to %x.\n", dev, "%s: Setting density code to %x.\n", name,
(STp->buffer)->b_data[4]); (STp->buffer)->b_data[4]);
if (cmd_in == MTSETDRVBUFFER) if (cmd_in == MTSETDRVBUFFER)
printk(ST_DEB_MSG printk(ST_DEB_MSG
"st%d: Setting drive buffer code to %d.\n", dev, "%s: Setting drive buffer code to %d.\n", name,
((STp->buffer)->b_data[2] >> 4) & 7); ((STp->buffer)->b_data[2] >> 4) & 7);
) )
break; break;
...@@ -2759,7 +2767,7 @@ static int get_location(Scsi_Tape *STp, unsigned int *block, int *partition, ...@@ -2759,7 +2767,7 @@ static int get_location(Scsi_Tape *STp, unsigned int *block, int *partition,
int result; int result;
unsigned char scmd[MAX_COMMAND_SIZE]; unsigned char scmd[MAX_COMMAND_SIZE];
Scsi_Request *SRpnt; Scsi_Request *SRpnt;
DEB( int dev = TAPE_NR(STp->devt); ) DEB( char *name = tape_name(STp); )
if (STp->ready != ST_READY) if (STp->ready != ST_READY)
return (-EIO); return (-EIO);
...@@ -2782,7 +2790,7 @@ static int get_location(Scsi_Tape *STp, unsigned int *block, int *partition, ...@@ -2782,7 +2790,7 @@ static int get_location(Scsi_Tape *STp, unsigned int *block, int *partition,
(STp->device->scsi_level >= SCSI_2 && (STp->device->scsi_level >= SCSI_2 &&
((STp->buffer)->b_data[0] & 4) != 0)) { ((STp->buffer)->b_data[0] & 4) != 0)) {
*block = *partition = 0; *block = *partition = 0;
DEBC(printk(ST_DEB_MSG "st%d: Can't read tape position.\n", dev)); DEBC(printk(ST_DEB_MSG "%s: Can't read tape position.\n", name));
result = (-EIO); result = (-EIO);
} else { } else {
result = 0; result = 0;
...@@ -2801,7 +2809,7 @@ static int get_location(Scsi_Tape *STp, unsigned int *block, int *partition, ...@@ -2801,7 +2809,7 @@ static int get_location(Scsi_Tape *STp, unsigned int *block, int *partition,
(STp->buffer)->b_data[1] == 0) /* BOP of partition 0 */ (STp->buffer)->b_data[1] == 0) /* BOP of partition 0 */
STp->ps[0].drv_block = STp->ps[0].drv_file = 0; STp->ps[0].drv_block = STp->ps[0].drv_file = 0;
} }
DEBC(printk(ST_DEB_MSG "st%d: Got tape pos. blk %d part %d.\n", dev, DEBC(printk(ST_DEB_MSG "%s: Got tape pos. blk %d part %d.\n", name,
*block, *partition)); *block, *partition));
} }
scsi_release_request(SRpnt); scsi_release_request(SRpnt);
...@@ -2822,15 +2830,15 @@ static int set_location(Scsi_Tape *STp, unsigned int block, int partition, ...@@ -2822,15 +2830,15 @@ static int set_location(Scsi_Tape *STp, unsigned int block, int partition,
int timeout; int timeout;
unsigned char scmd[MAX_COMMAND_SIZE]; unsigned char scmd[MAX_COMMAND_SIZE];
Scsi_Request *SRpnt; Scsi_Request *SRpnt;
DEB( int dev = TAPE_NR(STp->devt); ) DEB( char *name = tape_name(STp); )
if (STp->ready != ST_READY) if (STp->ready != ST_READY)
return (-EIO); return (-EIO);
timeout = STp->long_timeout; timeout = STp->long_timeout;
STps = &(STp->ps[STp->partition]); STps = &(STp->ps[STp->partition]);
DEBC(printk(ST_DEB_MSG "st%d: Setting block to %d and partition to %d.\n", DEBC(printk(ST_DEB_MSG "%s: Setting block to %d and partition to %d.\n",
dev, block, partition)); name, block, partition));
DEB(if (partition < 0) DEB(if (partition < 0)
return (-EIO); ) return (-EIO); )
...@@ -2845,8 +2853,8 @@ static int set_location(Scsi_Tape *STp, unsigned int block, int partition, ...@@ -2845,8 +2853,8 @@ static int set_location(Scsi_Tape *STp, unsigned int block, int partition,
STps->last_block_valid = TRUE; STps->last_block_valid = TRUE;
STps->last_block_visited = blk; STps->last_block_visited = blk;
DEBC(printk(ST_DEB_MSG DEBC(printk(ST_DEB_MSG
"st%d: Visited block %d for partition %d saved.\n", "%s: Visited block %d for partition %d saved.\n",
dev, blk, STp->partition)); name, blk, STp->partition));
} }
} }
...@@ -2869,8 +2877,8 @@ static int set_location(Scsi_Tape *STp, unsigned int block, int partition, ...@@ -2869,8 +2877,8 @@ static int set_location(Scsi_Tape *STp, unsigned int block, int partition,
scmd[1] |= 2; scmd[1] |= 2;
scmd[8] = partition; scmd[8] = partition;
DEBC(printk(ST_DEB_MSG DEBC(printk(ST_DEB_MSG
"st%d: Trying to change partition from %d to %d\n", "%s: Trying to change partition from %d to %d\n",
dev, STp->partition, partition)); name, STp->partition, partition));
} }
} }
if (STp->immediate) { if (STp->immediate) {
...@@ -2961,7 +2969,7 @@ static int switch_partition(Scsi_Tape *STp) ...@@ -2961,7 +2969,7 @@ static int switch_partition(Scsi_Tape *STp)
static int nbr_partitions(Scsi_Tape *STp) static int nbr_partitions(Scsi_Tape *STp)
{ {
int result; int result;
DEB( int dev = TAPE_NR(STp->devt) ); DEB( char *name = tape_name(STp); )
if (STp->ready != ST_READY) if (STp->ready != ST_READY)
return (-EIO); return (-EIO);
...@@ -2969,13 +2977,13 @@ static int nbr_partitions(Scsi_Tape *STp) ...@@ -2969,13 +2977,13 @@ static int nbr_partitions(Scsi_Tape *STp)
result = read_mode_page(STp, PART_PAGE, TRUE); result = read_mode_page(STp, PART_PAGE, TRUE);
if (result) { if (result) {
DEBC(printk(ST_DEB_MSG "st%d: Can't read medium partition page.\n", DEBC(printk(ST_DEB_MSG "%s: Can't read medium partition page.\n",
dev)); name));
result = (-EIO); result = (-EIO);
} else { } else {
result = (STp->buffer)->b_data[MODE_HEADER_LENGTH + result = (STp->buffer)->b_data[MODE_HEADER_LENGTH +
PP_OFF_NBR_ADD_PARTS] + 1; PP_OFF_NBR_ADD_PARTS] + 1;
DEBC(printk(ST_DEB_MSG "st%d: Number of partitions %d.\n", dev, result)); DEBC(printk(ST_DEB_MSG "%s: Number of partitions %d.\n", name, result));
} }
return result; return result;
...@@ -3003,20 +3011,21 @@ static int nbr_partitions(Scsi_Tape *STp) ...@@ -3003,20 +3011,21 @@ static int nbr_partitions(Scsi_Tape *STp)
*/ */
static int partition_tape(Scsi_Tape *STp, int size) static int partition_tape(Scsi_Tape *STp, int size)
{ {
int dev = TAPE_NR(STp->devt), result; char *name = tape_name(STp);
int result;
int pgo, psd_cnt, psdo; int pgo, psd_cnt, psdo;
unsigned char *bp; unsigned char *bp;
result = read_mode_page(STp, PART_PAGE, FALSE); result = read_mode_page(STp, PART_PAGE, FALSE);
if (result) { if (result) {
DEBC(printk(ST_DEB_MSG "st%d: Can't read partition mode page.\n", dev)); DEBC(printk(ST_DEB_MSG "%s: Can't read partition mode page.\n", name));
return result; return result;
} }
/* The mode page is in the buffer. Let's modify it and write it. */ /* The mode page is in the buffer. Let's modify it and write it. */
bp = (STp->buffer)->b_data; bp = (STp->buffer)->b_data;
pgo = MODE_HEADER_LENGTH + bp[MH_OFF_BDESCS_LENGTH]; pgo = MODE_HEADER_LENGTH + bp[MH_OFF_BDESCS_LENGTH];
DEBC(printk(ST_DEB_MSG "st%d: Partition page length is %d bytes.\n", DEBC(printk(ST_DEB_MSG "%s: Partition page length is %d bytes.\n",
dev, bp[pgo + MP_OFF_PAGE_LENGTH] + 2)); name, bp[pgo + MP_OFF_PAGE_LENGTH] + 2));
psd_cnt = (bp[pgo + MP_OFF_PAGE_LENGTH] + 2 - PART_PAGE_FIXED_LENGTH) / 2; psd_cnt = (bp[pgo + MP_OFF_PAGE_LENGTH] + 2 - PART_PAGE_FIXED_LENGTH) / 2;
psdo = pgo + PART_PAGE_FIXED_LENGTH; psdo = pgo + PART_PAGE_FIXED_LENGTH;
...@@ -3026,7 +3035,7 @@ static int partition_tape(Scsi_Tape *STp, int size) ...@@ -3026,7 +3035,7 @@ static int partition_tape(Scsi_Tape *STp, int size)
} }
memset(bp + psdo, 0, bp[pgo + PP_OFF_NBR_ADD_PARTS] * 2); memset(bp + psdo, 0, bp[pgo + PP_OFF_NBR_ADD_PARTS] * 2);
DEBC(printk("st%d: psd_cnt %d, max.parts %d, nbr_parts %d\n", dev, DEBC(printk("%s: psd_cnt %d, max.parts %d, nbr_parts %d\n", name,
psd_cnt, bp[pgo + PP_OFF_MAX_ADD_PARTS], psd_cnt, bp[pgo + PP_OFF_MAX_ADD_PARTS],
bp[pgo + PP_OFF_NBR_ADD_PARTS])); bp[pgo + PP_OFF_NBR_ADD_PARTS]));
...@@ -3034,8 +3043,8 @@ static int partition_tape(Scsi_Tape *STp, int size) ...@@ -3034,8 +3043,8 @@ static int partition_tape(Scsi_Tape *STp, int size)
bp[pgo + PP_OFF_NBR_ADD_PARTS] = 0; bp[pgo + PP_OFF_NBR_ADD_PARTS] = 0;
if (psd_cnt <= bp[pgo + PP_OFF_MAX_ADD_PARTS]) if (psd_cnt <= bp[pgo + PP_OFF_MAX_ADD_PARTS])
bp[pgo + MP_OFF_PAGE_LENGTH] = 6; bp[pgo + MP_OFF_PAGE_LENGTH] = 6;
DEBC(printk(ST_DEB_MSG "st%d: Formatting tape with one partition.\n", DEBC(printk(ST_DEB_MSG "%s: Formatting tape with one partition.\n",
dev)); name));
} else { } else {
bp[psdo] = (size >> 8) & 0xff; bp[psdo] = (size >> 8) & 0xff;
bp[psdo + 1] = size & 0xff; bp[psdo + 1] = size & 0xff;
...@@ -3043,8 +3052,8 @@ static int partition_tape(Scsi_Tape *STp, int size) ...@@ -3043,8 +3052,8 @@ static int partition_tape(Scsi_Tape *STp, int size)
if (bp[pgo + MP_OFF_PAGE_LENGTH] < 8) if (bp[pgo + MP_OFF_PAGE_LENGTH] < 8)
bp[pgo + MP_OFF_PAGE_LENGTH] = 8; bp[pgo + MP_OFF_PAGE_LENGTH] = 8;
DEBC(printk(ST_DEB_MSG DEBC(printk(ST_DEB_MSG
"st%d: Formatting tape with two partitions (1 = %d MB).\n", "%s: Formatting tape with two partitions (1 = %d MB).\n",
dev, size)); name, size));
} }
bp[pgo + PP_OFF_PART_UNITS] = 0; bp[pgo + PP_OFF_PART_UNITS] = 0;
bp[pgo + PP_OFF_RESERVED] = 0; bp[pgo + PP_OFF_RESERVED] = 0;
...@@ -3052,7 +3061,7 @@ static int partition_tape(Scsi_Tape *STp, int size) ...@@ -3052,7 +3061,7 @@ static int partition_tape(Scsi_Tape *STp, int size)
result = write_mode_page(STp, PART_PAGE); result = write_mode_page(STp, PART_PAGE);
if (result) { if (result) {
printk(KERN_INFO "st%d: Partitioning of tape failed.\n", dev); printk(KERN_INFO "%s: Partitioning of tape failed.\n", name);
result = (-EIO); result = (-EIO);
} }
...@@ -3072,17 +3081,20 @@ static int st_ioctl(struct inode *inode, struct file *file, ...@@ -3072,17 +3081,20 @@ static int st_ioctl(struct inode *inode, struct file *file,
ST_mode *STm; ST_mode *STm;
ST_partstat *STps; ST_partstat *STps;
int dev = TAPE_NR(inode->i_rdev); int dev = TAPE_NR(inode->i_rdev);
char *name;
read_lock(&st_dev_arr_lock); read_lock(&st_dev_arr_lock);
STp = scsi_tapes[dev]; STp = scsi_tapes[dev];
read_unlock(&st_dev_arr_lock); read_unlock(&st_dev_arr_lock);
name = tape_name(STp);
if (down_interruptible(&STp->lock)) if (down_interruptible(&STp->lock))
return -ERESTARTSYS; return -ERESTARTSYS;
DEB( DEB(
if (debugging && !STp->in_use) { if (debugging && !STp->in_use) {
printk(ST_DEB_MSG "st%d: Incorrect device.\n", dev); printk(ST_DEB_MSG "%s: Incorrect device.\n", name);
retval = (-EIO); retval = (-EIO);
goto out; goto out;
} ) /* end DEB */ } ) /* end DEB */
...@@ -3119,7 +3131,7 @@ static int st_ioctl(struct inode *inode, struct file *file, ...@@ -3119,7 +3131,7 @@ static int st_ioctl(struct inode *inode, struct file *file,
if (mtc.mt_op == MTSETDRVBUFFER && !capable(CAP_SYS_ADMIN)) { if (mtc.mt_op == MTSETDRVBUFFER && !capable(CAP_SYS_ADMIN)) {
printk(KERN_WARNING printk(KERN_WARNING
"st%d: MTSETDRVBUFFER only allowed for root.\n", dev); "%s: MTSETDRVBUFFER only allowed for root.\n", name);
retval = (-EPERM); retval = (-EPERM);
goto out; goto out;
} }
...@@ -3759,6 +3771,7 @@ static int st_attach(Scsi_Device * SDp) ...@@ -3759,6 +3771,7 @@ static int st_attach(Scsi_Device * SDp)
return 1; return 1;
} }
memset(tpnt, 0, sizeof(Scsi_Tape)); memset(tpnt, 0, sizeof(Scsi_Tape));
sprintf(tpnt->name, "st%d", i);
scsi_tapes[i] = tpnt; scsi_tapes[i] = tpnt;
dev_num = i; dev_num = i;
...@@ -3890,10 +3903,10 @@ static int st_attach(Scsi_Device * SDp) ...@@ -3890,10 +3903,10 @@ static int st_attach(Scsi_Device * SDp)
devfs_register_tape (tpnt->de_r[0]); devfs_register_tape (tpnt->de_r[0]);
printk(KERN_WARNING printk(KERN_WARNING
"Attached scsi tape st%d at scsi%d, channel %d, id %d, lun %d\n", "Attached scsi tape %s at scsi%d, channel %d, id %d, lun %d\n",
dev_num, SDp->host->host_no, SDp->channel, SDp->id, SDp->lun); tape_name(tpnt), SDp->host->host_no, SDp->channel, SDp->id, SDp->lun);
printk(KERN_WARNING "st%d: try direct i/o: %s, max page reachable by HBA %lu\n", printk(KERN_WARNING "%s: try direct i/o: %s, max page reachable by HBA %lu\n",
dev_num, tpnt->try_dio ? "yes" : "no", tpnt->max_pfn); tape_name(tpnt), tpnt->try_dio ? "yes" : "no", tpnt->max_pfn);
return 0; return 0;
}; };
......
...@@ -71,6 +71,7 @@ typedef struct { ...@@ -71,6 +71,7 @@ typedef struct {
/* The tape drive descriptor */ /* The tape drive descriptor */
typedef struct { typedef struct {
char name[8];
kdev_t devt; kdev_t devt;
Scsi_Device *device; Scsi_Device *device;
struct semaphore lock; /* For serialization */ struct semaphore lock; /* For serialization */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment