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