aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/osst.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/osst.c')
-rw-r--r--drivers/scsi/osst.c528
1 files changed, 282 insertions, 246 deletions
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index d9946bd95492..66ea47a9c53c 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -13,7 +13,7 @@
13 order) Klaus Ehrenfried, Wolfgang Denk, Steve Hirsch, Andreas Koppenh"ofer, 13 order) Klaus Ehrenfried, Wolfgang Denk, Steve Hirsch, Andreas Koppenh"ofer,
14 Michael Leodolter, Eyal Lebedinsky, J"org Weule, and Eric Youngdale. 14 Michael Leodolter, Eyal Lebedinsky, J"org Weule, and Eric Youngdale.
15 15
16 Copyright 1992 - 2002 Kai Makisara / 2000 - 2004 Willem Riede 16 Copyright 1992 - 2002 Kai Makisara / 2000 - 2006 Willem Riede
17 email osst@riede.org 17 email osst@riede.org
18 18
19 $Header: /cvsroot/osst/Driver/osst.c,v 1.73 2005/01/01 21:13:34 wriede Exp $ 19 $Header: /cvsroot/osst/Driver/osst.c,v 1.73 2005/01/01 21:13:34 wriede Exp $
@@ -24,7 +24,7 @@
24*/ 24*/
25 25
26static const char * cvsid = "$Id: osst.c,v 1.73 2005/01/01 21:13:34 wriede Exp $"; 26static const char * cvsid = "$Id: osst.c,v 1.73 2005/01/01 21:13:34 wriede Exp $";
27static const char * osst_version = "0.99.3"; 27static const char * osst_version = "0.99.4";
28 28
29/* The "failure to reconnect" firmware bug */ 29/* The "failure to reconnect" firmware bug */
30#define OSST_FW_NEED_POLL_MIN 10601 /*(107A)*/ 30#define OSST_FW_NEED_POLL_MIN 10601 /*(107A)*/
@@ -48,7 +48,6 @@ static const char * osst_version = "0.99.3";
48#include <linux/vmalloc.h> 48#include <linux/vmalloc.h>
49#include <linux/blkdev.h> 49#include <linux/blkdev.h>
50#include <linux/moduleparam.h> 50#include <linux/moduleparam.h>
51#include <linux/devfs_fs_kernel.h>
52#include <linux/delay.h> 51#include <linux/delay.h>
53#include <asm/uaccess.h> 52#include <asm/uaccess.h>
54#include <asm/dma.h> 53#include <asm/dma.h>
@@ -70,7 +69,6 @@ static const char * osst_version = "0.99.3";
70#include <scsi/scsi_eh.h> 69#include <scsi/scsi_eh.h>
71#include <scsi/scsi_host.h> 70#include <scsi/scsi_host.h>
72#include <scsi/scsi_ioctl.h> 71#include <scsi/scsi_ioctl.h>
73#include <scsi/scsi_request.h>
74 72
75#define ST_KILOBYTE 1024 73#define ST_KILOBYTE 1024
76 74
@@ -87,6 +85,7 @@ static int max_sg_segs = 0;
87MODULE_AUTHOR("Willem Riede"); 85MODULE_AUTHOR("Willem Riede");
88MODULE_DESCRIPTION("OnStream {DI-|FW-|SC-|USB}{30|50} Tape Driver"); 86MODULE_DESCRIPTION("OnStream {DI-|FW-|SC-|USB}{30|50} Tape Driver");
89MODULE_LICENSE("GPL"); 87MODULE_LICENSE("GPL");
88MODULE_ALIAS_CHARDEV_MAJOR(OSST_MAJOR);
90 89
91module_param(max_dev, int, 0444); 90module_param(max_dev, int, 0444);
92MODULE_PARM_DESC(max_dev, "Maximum number of OnStream Tape Drives to attach (4)"); 91MODULE_PARM_DESC(max_dev, "Maximum number of OnStream Tape Drives to attach (4)");
@@ -107,8 +106,6 @@ static struct osst_dev_parm {
107}; 106};
108#endif 107#endif
109 108
110static char *osst_formats[ST_NBR_MODES] ={"", "l", "m", "a"};
111
112/* Some default definitions have been moved to osst_options.h */ 109/* Some default definitions have been moved to osst_options.h */
113#define OSST_BUFFER_SIZE (OSST_BUFFER_BLOCKS * ST_KILOBYTE) 110#define OSST_BUFFER_SIZE (OSST_BUFFER_BLOCKS * ST_KILOBYTE)
114#define OSST_WRITE_THRESHOLD (OSST_WRITE_THRESHOLD_BLOCKS * ST_KILOBYTE) 111#define OSST_WRITE_THRESHOLD (OSST_WRITE_THRESHOLD_BLOCKS * ST_KILOBYTE)
@@ -179,16 +176,16 @@ static struct scsi_driver osst_template = {
179 } 176 }
180}; 177};
181 178
182static int osst_int_ioctl(struct osst_tape *STp, struct scsi_request ** aSRpnt, 179static int osst_int_ioctl(struct osst_tape *STp, struct osst_request ** aSRpnt,
183 unsigned int cmd_in, unsigned long arg); 180 unsigned int cmd_in, unsigned long arg);
184 181
185static int osst_set_frame_position(struct osst_tape *STp, struct scsi_request ** aSRpnt, int frame, int skip); 182static int osst_set_frame_position(struct osst_tape *STp, struct osst_request ** aSRpnt, int frame, int skip);
186 183
187static int osst_get_frame_position(struct osst_tape *STp, struct scsi_request ** aSRpnt); 184static int osst_get_frame_position(struct osst_tape *STp, struct osst_request ** aSRpnt);
188 185
189static int osst_flush_write_buffer(struct osst_tape *STp, struct scsi_request ** aSRpnt); 186static int osst_flush_write_buffer(struct osst_tape *STp, struct osst_request ** aSRpnt);
190 187
191static int osst_write_error_recovery(struct osst_tape * STp, struct scsi_request ** aSRpnt, int pending); 188static int osst_write_error_recovery(struct osst_tape * STp, struct osst_request ** aSRpnt, int pending);
192 189
193static inline char *tape_name(struct osst_tape *tape) 190static inline char *tape_name(struct osst_tape *tape)
194{ 191{
@@ -197,52 +194,84 @@ static inline char *tape_name(struct osst_tape *tape)
197 194
198/* Routines that handle the interaction with mid-layer SCSI routines */ 195/* Routines that handle the interaction with mid-layer SCSI routines */
199 196
197
198/* Normalize Sense */
199static void osst_analyze_sense(struct osst_request *SRpnt, struct st_cmdstatus *s)
200{
201 const u8 *ucp;
202 const u8 *sense = SRpnt->sense;
203
204 s->have_sense = scsi_normalize_sense(SRpnt->sense,
205 SCSI_SENSE_BUFFERSIZE, &s->sense_hdr);
206 s->flags = 0;
207
208 if (s->have_sense) {
209 s->deferred = 0;
210 s->remainder_valid =
211 scsi_get_sense_info_fld(sense, SCSI_SENSE_BUFFERSIZE, &s->uremainder64);
212 switch (sense[0] & 0x7f) {
213 case 0x71:
214 s->deferred = 1;
215 case 0x70:
216 s->fixed_format = 1;
217 s->flags = sense[2] & 0xe0;
218 break;
219 case 0x73:
220 s->deferred = 1;
221 case 0x72:
222 s->fixed_format = 0;
223 ucp = scsi_sense_desc_find(sense, SCSI_SENSE_BUFFERSIZE, 4);
224 s->flags = ucp ? (ucp[3] & 0xe0) : 0;
225 break;
226 }
227 }
228}
229
200/* Convert the result to success code */ 230/* Convert the result to success code */
201static int osst_chk_result(struct osst_tape * STp, struct scsi_request * SRpnt) 231static int osst_chk_result(struct osst_tape * STp, struct osst_request * SRpnt)
202{ 232{
203 char *name = tape_name(STp); 233 char *name = tape_name(STp);
204 int result = SRpnt->sr_result; 234 int result = SRpnt->result;
205 unsigned char * sense = SRpnt->sr_sense_buffer, scode; 235 u8 * sense = SRpnt->sense, scode;
206#if DEBUG 236#if DEBUG
207 const char *stp; 237 const char *stp;
208#endif 238#endif
239 struct st_cmdstatus *cmdstatp;
209 240
210 if (!result) { 241 if (!result)
211 sense[0] = 0; /* We don't have sense data if this byte is zero */
212 return 0; 242 return 0;
213 } 243
214 if ((driver_byte(result) & DRIVER_MASK) == DRIVER_SENSE) 244 cmdstatp = &STp->buffer->cmdstat;
215 scode = sense[2] & 0x0f; 245 osst_analyze_sense(SRpnt, cmdstatp);
216 else { 246
217 sense[0] = 0; /* We don't have sense data if this byte is zero */ 247 if (cmdstatp->have_sense)
248 scode = STp->buffer->cmdstat.sense_hdr.sense_key;
249 else
218 scode = 0; 250 scode = 0;
219 }
220#if DEBUG 251#if DEBUG
221 if (debugging) { 252 if (debugging) {
222 printk(OSST_DEB_MSG "%s:D: Error: %x, cmd: %x %x %x %x %x %x Len: %d\n", 253 printk(OSST_DEB_MSG "%s:D: Error: %x, cmd: %x %x %x %x %x %x\n",
223 name, result, 254 name, result,
224 SRpnt->sr_cmnd[0], SRpnt->sr_cmnd[1], SRpnt->sr_cmnd[2], 255 SRpnt->cmd[0], SRpnt->cmd[1], SRpnt->cmd[2],
225 SRpnt->sr_cmnd[3], SRpnt->sr_cmnd[4], SRpnt->sr_cmnd[5], 256 SRpnt->cmd[3], SRpnt->cmd[4], SRpnt->cmd[5]);
226 SRpnt->sr_bufflen);
227 if (scode) printk(OSST_DEB_MSG "%s:D: Sense: %02x, ASC: %02x, ASCQ: %02x\n", 257 if (scode) printk(OSST_DEB_MSG "%s:D: Sense: %02x, ASC: %02x, ASCQ: %02x\n",
228 name, scode, sense[12], sense[13]); 258 name, scode, sense[12], sense[13]);
229 if (driver_byte(result) & DRIVER_SENSE) 259 if (cmdstatp->have_sense)
230 scsi_print_req_sense("osst ", SRpnt); 260 __scsi_print_sense("osst ", SRpnt->sense, SCSI_SENSE_BUFFERSIZE);
231 } 261 }
232 else 262 else
233#endif 263#endif
234 if (!(driver_byte(result) & DRIVER_SENSE) || 264 if (cmdstatp->have_sense && (
235 ((sense[0] & 0x70) == 0x70 &&
236 scode != NO_SENSE && 265 scode != NO_SENSE &&
237 scode != RECOVERED_ERROR && 266 scode != RECOVERED_ERROR &&
238/* scode != UNIT_ATTENTION && */ 267/* scode != UNIT_ATTENTION && */
239 scode != BLANK_CHECK && 268 scode != BLANK_CHECK &&
240 scode != VOLUME_OVERFLOW && 269 scode != VOLUME_OVERFLOW &&
241 SRpnt->sr_cmnd[0] != MODE_SENSE && 270 SRpnt->cmd[0] != MODE_SENSE &&
242 SRpnt->sr_cmnd[0] != TEST_UNIT_READY)) { /* Abnormal conditions for tape */ 271 SRpnt->cmd[0] != TEST_UNIT_READY)) { /* Abnormal conditions for tape */
243 if (driver_byte(result) & DRIVER_SENSE) { 272 if (cmdstatp->have_sense) {
244 printk(KERN_WARNING "%s:W: Command with sense data:\n", name); 273 printk(KERN_WARNING "%s:W: Command with sense data:\n", name);
245 scsi_print_req_sense("osst:", SRpnt); 274 __scsi_print_sense("osst ", SRpnt->sense, SCSI_SENSE_BUFFERSIZE);
246 } 275 }
247 else { 276 else {
248 static int notyetprinted = 1; 277 static int notyetprinted = 1;
@@ -262,15 +291,14 @@ static int osst_chk_result(struct osst_tape * STp, struct scsi_request * SRpnt)
262 } 291 }
263 STp->pos_unknown |= STp->device->was_reset; 292 STp->pos_unknown |= STp->device->was_reset;
264 293
265 if ((sense[0] & 0x70) == 0x70 && 294 if (cmdstatp->have_sense && scode == RECOVERED_ERROR) {
266 scode == RECOVERED_ERROR) {
267 STp->recover_count++; 295 STp->recover_count++;
268 STp->recover_erreg++; 296 STp->recover_erreg++;
269#if DEBUG 297#if DEBUG
270 if (debugging) { 298 if (debugging) {
271 if (SRpnt->sr_cmnd[0] == READ_6) 299 if (SRpnt->cmd[0] == READ_6)
272 stp = "read"; 300 stp = "read";
273 else if (SRpnt->sr_cmnd[0] == WRITE_6) 301 else if (SRpnt->cmd[0] == WRITE_6)
274 stp = "write"; 302 stp = "write";
275 else 303 else
276 stp = "ioctl"; 304 stp = "ioctl";
@@ -286,74 +314,99 @@ static int osst_chk_result(struct osst_tape * STp, struct scsi_request * SRpnt)
286 314
287 315
288/* Wakeup from interrupt */ 316/* Wakeup from interrupt */
289static void osst_sleep_done (struct scsi_cmnd * SCpnt) 317static void osst_sleep_done(void *data, char *sense, int result, int resid)
290{ 318{
291 struct osst_tape * STp = container_of(SCpnt->request->rq_disk->private_data, struct osst_tape, driver); 319 struct osst_request *SRpnt = data;
292 320 struct osst_tape *STp = SRpnt->stp;
293 if ((STp->buffer)->writing &&
294 (SCpnt->sense_buffer[0] & 0x70) == 0x70 &&
295 (SCpnt->sense_buffer[2] & 0x40)) {
296 /* EOM at write-behind, has all been written? */
297 if ((SCpnt->sense_buffer[2] & 0x0f) == VOLUME_OVERFLOW)
298 STp->buffer->midlevel_result = SCpnt->result; /* Error */
299 else
300 STp->buffer->midlevel_result = INT_MAX; /* OK */
301 }
302 else
303 STp->buffer->midlevel_result = SCpnt->result;
304 SCpnt->request->rq_status = RQ_SCSI_DONE;
305 STp->buffer->last_SRpnt = SCpnt->sc_request;
306 321
322 memcpy(SRpnt->sense, sense, SCSI_SENSE_BUFFERSIZE);
323 STp->buffer->cmdstat.midlevel_result = SRpnt->result = result;
307#if DEBUG 324#if DEBUG
308 STp->write_pending = 0; 325 STp->write_pending = 0;
309#endif 326#endif
310 complete(SCpnt->request->waiting); 327 if (SRpnt->waiting)
328 complete(SRpnt->waiting);
311} 329}
312 330
331/* osst_request memory management */
332static struct osst_request *osst_allocate_request(void)
333{
334 return kzalloc(sizeof(struct osst_request), GFP_KERNEL);
335}
336
337static void osst_release_request(struct osst_request *streq)
338{
339 kfree(streq);
340}
313 341
314/* Do the scsi command. Waits until command performed if do_wait is true. 342/* Do the scsi command. Waits until command performed if do_wait is true.
315 Otherwise osst_write_behind_check() is used to check that the command 343 Otherwise osst_write_behind_check() is used to check that the command
316 has finished. */ 344 has finished. */
317static struct scsi_request * osst_do_scsi(struct scsi_request *SRpnt, struct osst_tape *STp, 345static struct osst_request * osst_do_scsi(struct osst_request *SRpnt, struct osst_tape *STp,
318 unsigned char *cmd, int bytes, int direction, int timeout, int retries, int do_wait) 346 unsigned char *cmd, int bytes, int direction, int timeout, int retries, int do_wait)
319{ 347{
320 unsigned char *bp; 348 unsigned char *bp;
349 unsigned short use_sg;
321#ifdef OSST_INJECT_ERRORS 350#ifdef OSST_INJECT_ERRORS
322 static int inject = 0; 351 static int inject = 0;
323 static int repeat = 0; 352 static int repeat = 0;
324#endif 353#endif
354 struct completion *waiting;
355
356 /* if async, make sure there's no command outstanding */
357 if (!do_wait && ((STp->buffer)->last_SRpnt)) {
358 printk(KERN_ERR "%s: Async command already active.\n",
359 tape_name(STp));
360 if (signal_pending(current))
361 (STp->buffer)->syscall_result = (-EINTR);
362 else
363 (STp->buffer)->syscall_result = (-EBUSY);
364 return NULL;
365 }
366
325 if (SRpnt == NULL) { 367 if (SRpnt == NULL) {
326 if ((SRpnt = scsi_allocate_request(STp->device, GFP_ATOMIC)) == NULL) { 368 SRpnt = osst_allocate_request();
327 printk(KERN_ERR "%s:E: Can't get SCSI request.\n", tape_name(STp)); 369 if (SRpnt == NULL) {
370 printk(KERN_ERR "%s: Can't allocate SCSI request.\n",
371 tape_name(STp));
328 if (signal_pending(current)) 372 if (signal_pending(current))
329 (STp->buffer)->syscall_result = (-EINTR); 373 (STp->buffer)->syscall_result = (-EINTR);
330 else 374 else
331 (STp->buffer)->syscall_result = (-EBUSY); 375 (STp->buffer)->syscall_result = (-EBUSY);
332 return NULL; 376 return NULL;
333 } 377 }
378 SRpnt->stp = STp;
334 } 379 }
335 380
336 init_completion(&STp->wait); 381 /* If async IO, set last_SRpnt. This ptr tells write_behind_check
337 SRpnt->sr_use_sg = (bytes > (STp->buffer)->sg[0].length) ? 382 which IO is outstanding. It's nulled out when the IO completes. */
338 (STp->buffer)->use_sg : 0; 383 if (!do_wait)
339 if (SRpnt->sr_use_sg) { 384 (STp->buffer)->last_SRpnt = SRpnt;
385
386 waiting = &STp->wait;
387 init_completion(waiting);
388 SRpnt->waiting = waiting;
389
390 use_sg = (bytes > STp->buffer->sg[0].length) ? STp->buffer->use_sg : 0;
391 if (use_sg) {
340 bp = (char *)&(STp->buffer->sg[0]); 392 bp = (char *)&(STp->buffer->sg[0]);
341 if (STp->buffer->sg_segs < SRpnt->sr_use_sg) 393 if (STp->buffer->sg_segs < use_sg)
342 SRpnt->sr_use_sg = STp->buffer->sg_segs; 394 use_sg = STp->buffer->sg_segs;
343 } 395 }
344 else 396 else
345 bp = (STp->buffer)->b_data; 397 bp = (STp->buffer)->b_data;
346 SRpnt->sr_data_direction = direction;
347 SRpnt->sr_cmd_len = 0;
348 SRpnt->sr_request->waiting = &(STp->wait);
349 SRpnt->sr_request->rq_status = RQ_SCSI_BUSY;
350 SRpnt->sr_request->rq_disk = STp->drive;
351 398
352 scsi_do_req(SRpnt, (void *)cmd, bp, bytes, osst_sleep_done, timeout, retries); 399 memcpy(SRpnt->cmd, cmd, sizeof(SRpnt->cmd));
400 STp->buffer->cmdstat.have_sense = 0;
401 STp->buffer->syscall_result = 0;
353 402
354 if (do_wait) { 403 if (scsi_execute_async(STp->device, cmd, COMMAND_SIZE(cmd[0]), direction, bp, bytes,
355 wait_for_completion(SRpnt->sr_request->waiting); 404 use_sg, timeout, retries, SRpnt, osst_sleep_done, GFP_KERNEL))
356 SRpnt->sr_request->waiting = NULL; 405 /* could not allocate the buffer or request was too large */
406 (STp->buffer)->syscall_result = (-EBUSY);
407 else if (do_wait) {
408 wait_for_completion(waiting);
409 SRpnt->waiting = NULL;
357 STp->buffer->syscall_result = osst_chk_result(STp, SRpnt); 410 STp->buffer->syscall_result = osst_chk_result(STp, SRpnt);
358#ifdef OSST_INJECT_ERRORS 411#ifdef OSST_INJECT_ERRORS
359 if (STp->buffer->syscall_result == 0 && 412 if (STp->buffer->syscall_result == 0 &&
@@ -386,21 +439,22 @@ static void osst_write_behind_check(struct osst_tape *STp)
386 STp->nbr_finished++; 439 STp->nbr_finished++;
387#endif 440#endif
388 wait_for_completion(&(STp->wait)); 441 wait_for_completion(&(STp->wait));
389 (STp->buffer)->last_SRpnt->sr_request->waiting = NULL; 442 STp->buffer->last_SRpnt->waiting = NULL;
390 443
391 STp->buffer->syscall_result = osst_chk_result(STp, STp->buffer->last_SRpnt); 444 STp->buffer->syscall_result = osst_chk_result(STp, STp->buffer->last_SRpnt);
392 445
393 if ((STp->buffer)->syscall_result) 446 if (STp->buffer->syscall_result)
394 (STp->buffer)->syscall_result = 447 STp->buffer->syscall_result =
395 osst_write_error_recovery(STp, &((STp->buffer)->last_SRpnt), 1); 448 osst_write_error_recovery(STp, &(STp->buffer->last_SRpnt), 1);
396 else 449 else
397 STp->first_frame_position++; 450 STp->first_frame_position++;
398 451
399 scsi_release_request((STp->buffer)->last_SRpnt); 452 osst_release_request(STp->buffer->last_SRpnt);
400 453
401 if (STbuffer->writing < STbuffer->buffer_bytes) 454 if (STbuffer->writing < STbuffer->buffer_bytes)
402 printk(KERN_WARNING "osst :A: write_behind_check: something left in buffer!\n"); 455 printk(KERN_WARNING "osst :A: write_behind_check: something left in buffer!\n");
403 456
457 STbuffer->last_SRpnt = NULL;
404 STbuffer->buffer_bytes -= STbuffer->writing; 458 STbuffer->buffer_bytes -= STbuffer->writing;
405 STbuffer->writing = 0; 459 STbuffer->writing = 0;
406 460
@@ -609,11 +663,11 @@ err_out:
609/* 663/*
610 * Wait for the unit to become Ready 664 * Wait for the unit to become Ready
611 */ 665 */
612static int osst_wait_ready(struct osst_tape * STp, struct scsi_request ** aSRpnt, 666static int osst_wait_ready(struct osst_tape * STp, struct osst_request ** aSRpnt,
613 unsigned timeout, int initial_delay) 667 unsigned timeout, int initial_delay)
614{ 668{
615 unsigned char cmd[MAX_COMMAND_SIZE]; 669 unsigned char cmd[MAX_COMMAND_SIZE];
616 struct scsi_request * SRpnt; 670 struct osst_request * SRpnt;
617 unsigned long startwait = jiffies; 671 unsigned long startwait = jiffies;
618#if DEBUG 672#if DEBUG
619 int dbg = debugging; 673 int dbg = debugging;
@@ -633,10 +687,10 @@ static int osst_wait_ready(struct osst_tape * STp, struct scsi_request ** aSRpnt
633 if (!SRpnt) return (-EBUSY); 687 if (!SRpnt) return (-EBUSY);
634 688
635 while ( STp->buffer->syscall_result && time_before(jiffies, startwait + timeout*HZ) && 689 while ( STp->buffer->syscall_result && time_before(jiffies, startwait + timeout*HZ) &&
636 (( SRpnt->sr_sense_buffer[2] == 2 && SRpnt->sr_sense_buffer[12] == 4 && 690 (( SRpnt->sense[2] == 2 && SRpnt->sense[12] == 4 &&
637 (SRpnt->sr_sense_buffer[13] == 1 || SRpnt->sr_sense_buffer[13] == 8) ) || 691 (SRpnt->sense[13] == 1 || SRpnt->sense[13] == 8) ) ||
638 ( SRpnt->sr_sense_buffer[2] == 6 && SRpnt->sr_sense_buffer[12] == 0x28 && 692 ( SRpnt->sense[2] == 6 && SRpnt->sense[12] == 0x28 &&
639 SRpnt->sr_sense_buffer[13] == 0 ) )) { 693 SRpnt->sense[13] == 0 ) )) {
640#if DEBUG 694#if DEBUG
641 if (debugging) { 695 if (debugging) {
642 printk(OSST_DEB_MSG "%s:D: Sleeping in onstream wait ready\n", name); 696 printk(OSST_DEB_MSG "%s:D: Sleeping in onstream wait ready\n", name);
@@ -660,8 +714,8 @@ static int osst_wait_ready(struct osst_tape * STp, struct scsi_request ** aSRpnt
660#if DEBUG 714#if DEBUG
661 printk(OSST_DEB_MSG "%s:D: Abnormal exit from onstream wait ready\n", name); 715 printk(OSST_DEB_MSG "%s:D: Abnormal exit from onstream wait ready\n", name);
662 printk(OSST_DEB_MSG "%s:D: Result = %d, Sense: 0=%02x, 2=%02x, 12=%02x, 13=%02x\n", name, 716 printk(OSST_DEB_MSG "%s:D: Result = %d, Sense: 0=%02x, 2=%02x, 12=%02x, 13=%02x\n", name,
663 STp->buffer->syscall_result, SRpnt->sr_sense_buffer[0], SRpnt->sr_sense_buffer[2], 717 STp->buffer->syscall_result, SRpnt->sense[0], SRpnt->sense[2],
664 SRpnt->sr_sense_buffer[12], SRpnt->sr_sense_buffer[13]); 718 SRpnt->sense[12], SRpnt->sense[13]);
665#endif 719#endif
666 return (-EIO); 720 return (-EIO);
667 } 721 }
@@ -674,10 +728,10 @@ static int osst_wait_ready(struct osst_tape * STp, struct scsi_request ** aSRpnt
674/* 728/*
675 * Wait for a tape to be inserted in the unit 729 * Wait for a tape to be inserted in the unit
676 */ 730 */
677static int osst_wait_for_medium(struct osst_tape * STp, struct scsi_request ** aSRpnt, unsigned timeout) 731static int osst_wait_for_medium(struct osst_tape * STp, struct osst_request ** aSRpnt, unsigned timeout)
678{ 732{
679 unsigned char cmd[MAX_COMMAND_SIZE]; 733 unsigned char cmd[MAX_COMMAND_SIZE];
680 struct scsi_request * SRpnt; 734 struct osst_request * SRpnt;
681 unsigned long startwait = jiffies; 735 unsigned long startwait = jiffies;
682#if DEBUG 736#if DEBUG
683 int dbg = debugging; 737 int dbg = debugging;
@@ -694,8 +748,7 @@ static int osst_wait_for_medium(struct osst_tape * STp, struct scsi_request ** a
694 if (!SRpnt) return (-EBUSY); 748 if (!SRpnt) return (-EBUSY);
695 749
696 while ( STp->buffer->syscall_result && time_before(jiffies, startwait + timeout*HZ) && 750 while ( STp->buffer->syscall_result && time_before(jiffies, startwait + timeout*HZ) &&
697 SRpnt->sr_sense_buffer[2] == 2 && SRpnt->sr_sense_buffer[12] == 0x3a && 751 SRpnt->sense[2] == 2 && SRpnt->sense[12] == 0x3a && SRpnt->sense[13] == 0 ) {
698 SRpnt->sr_sense_buffer[13] == 0 ) {
699#if DEBUG 752#if DEBUG
700 if (debugging) { 753 if (debugging) {
701 printk(OSST_DEB_MSG "%s:D: Sleeping in onstream wait medium\n", name); 754 printk(OSST_DEB_MSG "%s:D: Sleeping in onstream wait medium\n", name);
@@ -714,13 +767,13 @@ static int osst_wait_for_medium(struct osst_tape * STp, struct scsi_request ** a
714#if DEBUG 767#if DEBUG
715 debugging = dbg; 768 debugging = dbg;
716#endif 769#endif
717 if ( STp->buffer->syscall_result && SRpnt->sr_sense_buffer[2] != 2 && 770 if ( STp->buffer->syscall_result && SRpnt->sense[2] != 2 &&
718 SRpnt->sr_sense_buffer[12] != 4 && SRpnt->sr_sense_buffer[13] == 1) { 771 SRpnt->sense[12] != 4 && SRpnt->sense[13] == 1) {
719#if DEBUG 772#if DEBUG
720 printk(OSST_DEB_MSG "%s:D: Abnormal exit from onstream wait medium\n", name); 773 printk(OSST_DEB_MSG "%s:D: Abnormal exit from onstream wait medium\n", name);
721 printk(OSST_DEB_MSG "%s:D: Result = %d, Sense: 0=%02x, 2=%02x, 12=%02x, 13=%02x\n", name, 774 printk(OSST_DEB_MSG "%s:D: Result = %d, Sense: 0=%02x, 2=%02x, 12=%02x, 13=%02x\n", name,
722 STp->buffer->syscall_result, SRpnt->sr_sense_buffer[0], SRpnt->sr_sense_buffer[2], 775 STp->buffer->syscall_result, SRpnt->sense[0], SRpnt->sense[2],
723 SRpnt->sr_sense_buffer[12], SRpnt->sr_sense_buffer[13]); 776 SRpnt->sense[12], SRpnt->sense[13]);
724#endif 777#endif
725 return 0; 778 return 0;
726 } 779 }
@@ -730,7 +783,7 @@ static int osst_wait_for_medium(struct osst_tape * STp, struct scsi_request ** a
730 return 1; 783 return 1;
731} 784}
732 785
733static int osst_position_tape_and_confirm(struct osst_tape * STp, struct scsi_request ** aSRpnt, int frame) 786static int osst_position_tape_and_confirm(struct osst_tape * STp, struct osst_request ** aSRpnt, int frame)
734{ 787{
735 int retval; 788 int retval;
736 789
@@ -744,10 +797,10 @@ static int osst_position_tape_and_confirm(struct osst_tape * STp, struct scsi_re
744/* 797/*
745 * Wait for write(s) to complete 798 * Wait for write(s) to complete
746 */ 799 */
747static int osst_flush_drive_buffer(struct osst_tape * STp, struct scsi_request ** aSRpnt) 800static int osst_flush_drive_buffer(struct osst_tape * STp, struct osst_request ** aSRpnt)
748{ 801{
749 unsigned char cmd[MAX_COMMAND_SIZE]; 802 unsigned char cmd[MAX_COMMAND_SIZE];
750 struct scsi_request * SRpnt; 803 struct osst_request * SRpnt;
751 int result = 0; 804 int result = 0;
752 int delay = OSST_WAIT_WRITE_COMPLETE; 805 int delay = OSST_WAIT_WRITE_COMPLETE;
753#if DEBUG 806#if DEBUG
@@ -764,8 +817,8 @@ static int osst_flush_drive_buffer(struct osst_tape * STp, struct scsi_request *
764 *aSRpnt = SRpnt; 817 *aSRpnt = SRpnt;
765 if (!SRpnt) return (-EBUSY); 818 if (!SRpnt) return (-EBUSY);
766 if (STp->buffer->syscall_result) { 819 if (STp->buffer->syscall_result) {
767 if ((SRpnt->sr_sense_buffer[2] & 0x0f) == 2 && SRpnt->sr_sense_buffer[12] == 4) { 820 if ((SRpnt->sense[2] & 0x0f) == 2 && SRpnt->sense[12] == 4) {
768 if (SRpnt->sr_sense_buffer[13] == 8) { 821 if (SRpnt->sense[13] == 8) {
769 delay = OSST_WAIT_LONG_WRITE_COMPLETE; 822 delay = OSST_WAIT_LONG_WRITE_COMPLETE;
770 } 823 }
771 } else 824 } else
@@ -778,7 +831,7 @@ static int osst_flush_drive_buffer(struct osst_tape * STp, struct scsi_request *
778} 831}
779 832
780#define OSST_POLL_PER_SEC 10 833#define OSST_POLL_PER_SEC 10
781static int osst_wait_frame(struct osst_tape * STp, struct scsi_request ** aSRpnt, int curr, int minlast, int to) 834static int osst_wait_frame(struct osst_tape * STp, struct osst_request ** aSRpnt, int curr, int minlast, int to)
782{ 835{
783 unsigned long startwait = jiffies; 836 unsigned long startwait = jiffies;
784 char * name = tape_name(STp); 837 char * name = tape_name(STp);
@@ -833,9 +886,9 @@ static int osst_wait_frame(struct osst_tape * STp, struct scsi_request ** aSRpnt
833 return -EBUSY; 886 return -EBUSY;
834} 887}
835 888
836static int osst_recover_wait_frame(struct osst_tape * STp, struct scsi_request ** aSRpnt, int writing) 889static int osst_recover_wait_frame(struct osst_tape * STp, struct osst_request ** aSRpnt, int writing)
837{ 890{
838 struct scsi_request * SRpnt; 891 struct osst_request * SRpnt;
839 unsigned char cmd[MAX_COMMAND_SIZE]; 892 unsigned char cmd[MAX_COMMAND_SIZE];
840 unsigned long startwait = jiffies; 893 unsigned long startwait = jiffies;
841 int retval = 1; 894 int retval = 1;
@@ -856,7 +909,7 @@ static int osst_recover_wait_frame(struct osst_tape * STp, struct scsi_request *
856 909
857 while (retval && time_before (jiffies, startwait + 5*60*HZ)) { 910 while (retval && time_before (jiffies, startwait + 5*60*HZ)) {
858 911
859 if (STp->buffer->syscall_result && (SRpnt->sr_sense_buffer[2] & 0x0f) != 2) { 912 if (STp->buffer->syscall_result && (SRpnt->sense[2] & 0x0f) != 2) {
860 913
861 /* some failure - not just not-ready */ 914 /* some failure - not just not-ready */
862 retval = osst_write_error_recovery(STp, aSRpnt, 0); 915 retval = osst_write_error_recovery(STp, aSRpnt, 0);
@@ -881,9 +934,9 @@ static int osst_recover_wait_frame(struct osst_tape * STp, struct scsi_request *
881 if (STp->buffer->syscall_result) 934 if (STp->buffer->syscall_result)
882 printk(KERN_WARNING 935 printk(KERN_WARNING
883 "%s:W: Recover_wait_frame(read) cannot handle %02x:%02x:%02x\n", name, 936 "%s:W: Recover_wait_frame(read) cannot handle %02x:%02x:%02x\n", name,
884 (*aSRpnt)->sr_sense_buffer[ 2] & 0x0f, 937 (*aSRpnt)->sense[ 2] & 0x0f,
885 (*aSRpnt)->sr_sense_buffer[12], 938 (*aSRpnt)->sense[12],
886 (*aSRpnt)->sr_sense_buffer[13]); 939 (*aSRpnt)->sense[13]);
887 940
888 return retval; 941 return retval;
889} 942}
@@ -891,10 +944,10 @@ static int osst_recover_wait_frame(struct osst_tape * STp, struct scsi_request *
891/* 944/*
892 * Read the next OnStream tape frame at the current location 945 * Read the next OnStream tape frame at the current location
893 */ 946 */
894static int osst_read_frame(struct osst_tape * STp, struct scsi_request ** aSRpnt, int timeout) 947static int osst_read_frame(struct osst_tape * STp, struct osst_request ** aSRpnt, int timeout)
895{ 948{
896 unsigned char cmd[MAX_COMMAND_SIZE]; 949 unsigned char cmd[MAX_COMMAND_SIZE];
897 struct scsi_request * SRpnt; 950 struct osst_request * SRpnt;
898 int retval = 0; 951 int retval = 0;
899#if DEBUG 952#if DEBUG
900 os_aux_t * aux = STp->buffer->aux; 953 os_aux_t * aux = STp->buffer->aux;
@@ -932,10 +985,10 @@ static int osst_read_frame(struct osst_tape * STp, struct scsi_request ** aSRpnt
932 if (debugging) 985 if (debugging)
933 printk(OSST_DEB_MSG "%s:D: Sense: %2x %2x %2x %2x %2x %2x %2x %2x\n", 986 printk(OSST_DEB_MSG "%s:D: Sense: %2x %2x %2x %2x %2x %2x %2x %2x\n",
934 name, 987 name,
935 SRpnt->sr_sense_buffer[0], SRpnt->sr_sense_buffer[1], 988 SRpnt->sense[0], SRpnt->sense[1],
936 SRpnt->sr_sense_buffer[2], SRpnt->sr_sense_buffer[3], 989 SRpnt->sense[2], SRpnt->sense[3],
937 SRpnt->sr_sense_buffer[4], SRpnt->sr_sense_buffer[5], 990 SRpnt->sense[4], SRpnt->sense[5],
938 SRpnt->sr_sense_buffer[6], SRpnt->sr_sense_buffer[7]); 991 SRpnt->sense[6], SRpnt->sense[7]);
939#endif 992#endif
940 } 993 }
941 else 994 else
@@ -962,10 +1015,10 @@ static int osst_read_frame(struct osst_tape * STp, struct scsi_request ** aSRpnt
962 return (retval); 1015 return (retval);
963} 1016}
964 1017
965static int osst_initiate_read(struct osst_tape * STp, struct scsi_request ** aSRpnt) 1018static int osst_initiate_read(struct osst_tape * STp, struct osst_request ** aSRpnt)
966{ 1019{
967 struct st_partstat * STps = &(STp->ps[STp->partition]); 1020 struct st_partstat * STps = &(STp->ps[STp->partition]);
968 struct scsi_request * SRpnt ; 1021 struct osst_request * SRpnt ;
969 unsigned char cmd[MAX_COMMAND_SIZE]; 1022 unsigned char cmd[MAX_COMMAND_SIZE];
970 int retval = 0; 1023 int retval = 0;
971 char * name = tape_name(STp); 1024 char * name = tape_name(STp);
@@ -999,7 +1052,7 @@ static int osst_initiate_read(struct osst_tape * STp, struct scsi_request ** aSR
999 return retval; 1052 return retval;
1000} 1053}
1001 1054
1002static int osst_get_logical_frame(struct osst_tape * STp, struct scsi_request ** aSRpnt, 1055static int osst_get_logical_frame(struct osst_tape * STp, struct osst_request ** aSRpnt,
1003 int frame_seq_number, int quiet) 1056 int frame_seq_number, int quiet)
1004{ 1057{
1005 struct st_partstat * STps = &(STp->ps[STp->partition]); 1058 struct st_partstat * STps = &(STp->ps[STp->partition]);
@@ -1128,7 +1181,7 @@ static int osst_get_logical_frame(struct osst_tape * STp, struct scsi_request **
1128 return (STps->eof); 1181 return (STps->eof);
1129} 1182}
1130 1183
1131static int osst_seek_logical_blk(struct osst_tape * STp, struct scsi_request ** aSRpnt, int logical_blk_num) 1184static int osst_seek_logical_blk(struct osst_tape * STp, struct osst_request ** aSRpnt, int logical_blk_num)
1132{ 1185{
1133 struct st_partstat * STps = &(STp->ps[STp->partition]); 1186 struct st_partstat * STps = &(STp->ps[STp->partition]);
1134 char * name = tape_name(STp); 1187 char * name = tape_name(STp);
@@ -1237,7 +1290,7 @@ error:
1237#define OSST_SECTOR_SHIFT 9 1290#define OSST_SECTOR_SHIFT 9
1238#define OSST_SECTOR_MASK 0x03F 1291#define OSST_SECTOR_MASK 0x03F
1239 1292
1240static int osst_get_sector(struct osst_tape * STp, struct scsi_request ** aSRpnt) 1293static int osst_get_sector(struct osst_tape * STp, struct osst_request ** aSRpnt)
1241{ 1294{
1242 int sector; 1295 int sector;
1243#if DEBUG 1296#if DEBUG
@@ -1267,7 +1320,7 @@ static int osst_get_sector(struct osst_tape * STp, struct scsi_request ** aSRpnt
1267 return sector; 1320 return sector;
1268} 1321}
1269 1322
1270static int osst_seek_sector(struct osst_tape * STp, struct scsi_request ** aSRpnt, int sector) 1323static int osst_seek_sector(struct osst_tape * STp, struct osst_request ** aSRpnt, int sector)
1271{ 1324{
1272 struct st_partstat * STps = &(STp->ps[STp->partition]); 1325 struct st_partstat * STps = &(STp->ps[STp->partition]);
1273 int frame = sector >> OSST_FRAME_SHIFT, 1326 int frame = sector >> OSST_FRAME_SHIFT,
@@ -1330,10 +1383,10 @@ static int osst_seek_sector(struct osst_tape * STp, struct scsi_request ** aSRpn
1330 * Precondition for this function to work: all frames in the 1383 * Precondition for this function to work: all frames in the
1331 * drive's buffer must be of one type (DATA, MARK or EOD)! 1384 * drive's buffer must be of one type (DATA, MARK or EOD)!
1332 */ 1385 */
1333static int osst_read_back_buffer_and_rewrite(struct osst_tape * STp, struct scsi_request ** aSRpnt, 1386static int osst_read_back_buffer_and_rewrite(struct osst_tape * STp, struct osst_request ** aSRpnt,
1334 unsigned int frame, unsigned int skip, int pending) 1387 unsigned int frame, unsigned int skip, int pending)
1335{ 1388{
1336 struct scsi_request * SRpnt = * aSRpnt; 1389 struct osst_request * SRpnt = * aSRpnt;
1337 unsigned char * buffer, * p; 1390 unsigned char * buffer, * p;
1338 unsigned char cmd[MAX_COMMAND_SIZE]; 1391 unsigned char cmd[MAX_COMMAND_SIZE];
1339 int flag, new_frame, i; 1392 int flag, new_frame, i;
@@ -1477,8 +1530,8 @@ static int osst_read_back_buffer_and_rewrite(struct osst_tape * STp, struct scsi
1477 SRpnt = osst_do_scsi(SRpnt, STp, cmd, 0, DMA_NONE, STp->timeout, 1530 SRpnt = osst_do_scsi(SRpnt, STp, cmd, 0, DMA_NONE, STp->timeout,
1478 MAX_RETRIES, 1); 1531 MAX_RETRIES, 1);
1479 1532
1480 if (SRpnt->sr_sense_buffer[2] == 2 && SRpnt->sr_sense_buffer[12] == 4 && 1533 if (SRpnt->sense[2] == 2 && SRpnt->sense[12] == 4 &&
1481 (SRpnt->sr_sense_buffer[13] == 1 || SRpnt->sr_sense_buffer[13] == 8)) { 1534 (SRpnt->sense[13] == 1 || SRpnt->sense[13] == 8)) {
1482 /* in the process of becoming ready */ 1535 /* in the process of becoming ready */
1483 msleep(100); 1536 msleep(100);
1484 continue; 1537 continue;
@@ -1495,17 +1548,17 @@ static int osst_read_back_buffer_and_rewrite(struct osst_tape * STp, struct scsi
1495 } 1548 }
1496 *aSRpnt = SRpnt; 1549 *aSRpnt = SRpnt;
1497 if (flag) { 1550 if (flag) {
1498 if ((SRpnt->sr_sense_buffer[ 2] & 0x0f) == 13 && 1551 if ((SRpnt->sense[ 2] & 0x0f) == 13 &&
1499 SRpnt->sr_sense_buffer[12] == 0 && 1552 SRpnt->sense[12] == 0 &&
1500 SRpnt->sr_sense_buffer[13] == 2) { 1553 SRpnt->sense[13] == 2) {
1501 printk(KERN_ERR "%s:E: Volume overflow in write error recovery\n", name); 1554 printk(KERN_ERR "%s:E: Volume overflow in write error recovery\n", name);
1502 vfree(buffer); 1555 vfree(buffer);
1503 return (-EIO); /* hit end of tape = fail */ 1556 return (-EIO); /* hit end of tape = fail */
1504 } 1557 }
1505 i = ((SRpnt->sr_sense_buffer[3] << 24) | 1558 i = ((SRpnt->sense[3] << 24) |
1506 (SRpnt->sr_sense_buffer[4] << 16) | 1559 (SRpnt->sense[4] << 16) |
1507 (SRpnt->sr_sense_buffer[5] << 8) | 1560 (SRpnt->sense[5] << 8) |
1508 SRpnt->sr_sense_buffer[6] ) - new_frame; 1561 SRpnt->sense[6] ) - new_frame;
1509 p = &buffer[i * OS_DATA_SIZE]; 1562 p = &buffer[i * OS_DATA_SIZE];
1510#if DEBUG 1563#if DEBUG
1511 printk(OSST_DEB_MSG "%s:D: Additional write error at %d\n", name, new_frame+i); 1564 printk(OSST_DEB_MSG "%s:D: Additional write error at %d\n", name, new_frame+i);
@@ -1528,11 +1581,11 @@ static int osst_read_back_buffer_and_rewrite(struct osst_tape * STp, struct scsi
1528 return 0; 1581 return 0;
1529} 1582}
1530 1583
1531static int osst_reposition_and_retry(struct osst_tape * STp, struct scsi_request ** aSRpnt, 1584static int osst_reposition_and_retry(struct osst_tape * STp, struct osst_request ** aSRpnt,
1532 unsigned int frame, unsigned int skip, int pending) 1585 unsigned int frame, unsigned int skip, int pending)
1533{ 1586{
1534 unsigned char cmd[MAX_COMMAND_SIZE]; 1587 unsigned char cmd[MAX_COMMAND_SIZE];
1535 struct scsi_request * SRpnt; 1588 struct osst_request * SRpnt;
1536 char * name = tape_name(STp); 1589 char * name = tape_name(STp);
1537 int expected = 0; 1590 int expected = 0;
1538 int attempts = 1000 / skip; 1591 int attempts = 1000 / skip;
@@ -1584,9 +1637,9 @@ static int osst_reposition_and_retry(struct osst_tape * STp, struct scsi_request
1584 *aSRpnt = SRpnt; 1637 *aSRpnt = SRpnt;
1585 1638
1586 if (STp->buffer->syscall_result) { /* additional write error */ 1639 if (STp->buffer->syscall_result) { /* additional write error */
1587 if ((SRpnt->sr_sense_buffer[ 2] & 0x0f) == 13 && 1640 if ((SRpnt->sense[ 2] & 0x0f) == 13 &&
1588 SRpnt->sr_sense_buffer[12] == 0 && 1641 SRpnt->sense[12] == 0 &&
1589 SRpnt->sr_sense_buffer[13] == 2) { 1642 SRpnt->sense[13] == 2) {
1590 printk(KERN_ERR 1643 printk(KERN_ERR
1591 "%s:E: Volume overflow in write error recovery\n", 1644 "%s:E: Volume overflow in write error recovery\n",
1592 name); 1645 name);
@@ -1631,9 +1684,9 @@ static int osst_reposition_and_retry(struct osst_tape * STp, struct scsi_request
1631 * Error recovery algorithm for the OnStream tape. 1684 * Error recovery algorithm for the OnStream tape.
1632 */ 1685 */
1633 1686
1634static int osst_write_error_recovery(struct osst_tape * STp, struct scsi_request ** aSRpnt, int pending) 1687static int osst_write_error_recovery(struct osst_tape * STp, struct osst_request ** aSRpnt, int pending)
1635{ 1688{
1636 struct scsi_request * SRpnt = * aSRpnt; 1689 struct osst_request * SRpnt = * aSRpnt;
1637 struct st_partstat * STps = & STp->ps[STp->partition]; 1690 struct st_partstat * STps = & STp->ps[STp->partition];
1638 char * name = tape_name(STp); 1691 char * name = tape_name(STp);
1639 int retval = 0; 1692 int retval = 0;
@@ -1642,20 +1695,20 @@ static int osst_write_error_recovery(struct osst_tape * STp, struct scsi_request
1642 1695
1643 rw_state = STps->rw; 1696 rw_state = STps->rw;
1644 1697
1645 if ((SRpnt->sr_sense_buffer[ 2] & 0x0f) != 3 1698 if ((SRpnt->sense[ 2] & 0x0f) != 3
1646 || SRpnt->sr_sense_buffer[12] != 12 1699 || SRpnt->sense[12] != 12
1647 || SRpnt->sr_sense_buffer[13] != 0) { 1700 || SRpnt->sense[13] != 0) {
1648#if DEBUG 1701#if DEBUG
1649 printk(OSST_DEB_MSG "%s:D: Write error recovery cannot handle %02x:%02x:%02x\n", name, 1702 printk(OSST_DEB_MSG "%s:D: Write error recovery cannot handle %02x:%02x:%02x\n", name,
1650 SRpnt->sr_sense_buffer[2], SRpnt->sr_sense_buffer[12], SRpnt->sr_sense_buffer[13]); 1703 SRpnt->sense[2], SRpnt->sense[12], SRpnt->sense[13]);
1651#endif 1704#endif
1652 return (-EIO); 1705 return (-EIO);
1653 } 1706 }
1654 frame = (SRpnt->sr_sense_buffer[3] << 24) | 1707 frame = (SRpnt->sense[3] << 24) |
1655 (SRpnt->sr_sense_buffer[4] << 16) | 1708 (SRpnt->sense[4] << 16) |
1656 (SRpnt->sr_sense_buffer[5] << 8) | 1709 (SRpnt->sense[5] << 8) |
1657 SRpnt->sr_sense_buffer[6]; 1710 SRpnt->sense[6];
1658 skip = SRpnt->sr_sense_buffer[9]; 1711 skip = SRpnt->sense[9];
1659 1712
1660#if DEBUG 1713#if DEBUG
1661 printk(OSST_DEB_MSG "%s:D: Detected physical bad frame at %u, advised to skip %d\n", name, frame, skip); 1714 printk(OSST_DEB_MSG "%s:D: Detected physical bad frame at %u, advised to skip %d\n", name, frame, skip);
@@ -1710,7 +1763,7 @@ static int osst_write_error_recovery(struct osst_tape * STp, struct scsi_request
1710 return retval; 1763 return retval;
1711} 1764}
1712 1765
1713static int osst_space_over_filemarks_backward(struct osst_tape * STp, struct scsi_request ** aSRpnt, 1766static int osst_space_over_filemarks_backward(struct osst_tape * STp, struct osst_request ** aSRpnt,
1714 int mt_op, int mt_count) 1767 int mt_op, int mt_count)
1715{ 1768{
1716 char * name = tape_name(STp); 1769 char * name = tape_name(STp);
@@ -1809,7 +1862,7 @@ found:
1809 * 1862 *
1810 * Just scans for the filemark sequentially. 1863 * Just scans for the filemark sequentially.
1811 */ 1864 */
1812static int osst_space_over_filemarks_forward_slow(struct osst_tape * STp, struct scsi_request ** aSRpnt, 1865static int osst_space_over_filemarks_forward_slow(struct osst_tape * STp, struct osst_request ** aSRpnt,
1813 int mt_op, int mt_count) 1866 int mt_op, int mt_count)
1814{ 1867{
1815 int cnt = 0; 1868 int cnt = 0;
@@ -1863,7 +1916,7 @@ static int osst_space_over_filemarks_forward_slow(struct osst_tape * STp, struct
1863/* 1916/*
1864 * Fast linux specific version of OnStream FSF 1917 * Fast linux specific version of OnStream FSF
1865 */ 1918 */
1866static int osst_space_over_filemarks_forward_fast(struct osst_tape * STp, struct scsi_request ** aSRpnt, 1919static int osst_space_over_filemarks_forward_fast(struct osst_tape * STp, struct osst_request ** aSRpnt,
1867 int mt_op, int mt_count) 1920 int mt_op, int mt_count)
1868{ 1921{
1869 char * name = tape_name(STp); 1922 char * name = tape_name(STp);
@@ -2014,10 +2067,10 @@ static int osst_space_over_filemarks_forward_fast(struct osst_tape * STp, struct
2014 * to test the error recovery mechanism. 2067 * to test the error recovery mechanism.
2015 */ 2068 */
2016#if DEBUG 2069#if DEBUG
2017static void osst_set_retries(struct osst_tape * STp, struct scsi_request ** aSRpnt, int retries) 2070static void osst_set_retries(struct osst_tape * STp, struct osst_request ** aSRpnt, int retries)
2018{ 2071{
2019 unsigned char cmd[MAX_COMMAND_SIZE]; 2072 unsigned char cmd[MAX_COMMAND_SIZE];
2020 struct scsi_request * SRpnt = * aSRpnt; 2073 struct osst_request * SRpnt = * aSRpnt;
2021 char * name = tape_name(STp); 2074 char * name = tape_name(STp);
2022 2075
2023 memset(cmd, 0, MAX_COMMAND_SIZE); 2076 memset(cmd, 0, MAX_COMMAND_SIZE);
@@ -2046,7 +2099,7 @@ static void osst_set_retries(struct osst_tape * STp, struct scsi_request ** aSRp
2046#endif 2099#endif
2047 2100
2048 2101
2049static int osst_write_filemark(struct osst_tape * STp, struct scsi_request ** aSRpnt) 2102static int osst_write_filemark(struct osst_tape * STp, struct osst_request ** aSRpnt)
2050{ 2103{
2051 int result; 2104 int result;
2052 int this_mark_ppos = STp->first_frame_position; 2105 int this_mark_ppos = STp->first_frame_position;
@@ -2074,7 +2127,7 @@ static int osst_write_filemark(struct osst_tape * STp, struct scsi_request ** aS
2074 return result; 2127 return result;
2075} 2128}
2076 2129
2077static int osst_write_eod(struct osst_tape * STp, struct scsi_request ** aSRpnt) 2130static int osst_write_eod(struct osst_tape * STp, struct osst_request ** aSRpnt)
2078{ 2131{
2079 int result; 2132 int result;
2080#if DEBUG 2133#if DEBUG
@@ -2097,7 +2150,7 @@ static int osst_write_eod(struct osst_tape * STp, struct scsi_request ** aSRpnt)
2097 return result; 2150 return result;
2098} 2151}
2099 2152
2100static int osst_write_filler(struct osst_tape * STp, struct scsi_request ** aSRpnt, int where, int count) 2153static int osst_write_filler(struct osst_tape * STp, struct osst_request ** aSRpnt, int where, int count)
2101{ 2154{
2102 char * name = tape_name(STp); 2155 char * name = tape_name(STp);
2103 2156
@@ -2122,7 +2175,7 @@ static int osst_write_filler(struct osst_tape * STp, struct scsi_request ** aSRp
2122 return osst_flush_drive_buffer(STp, aSRpnt); 2175 return osst_flush_drive_buffer(STp, aSRpnt);
2123} 2176}
2124 2177
2125static int __osst_write_header(struct osst_tape * STp, struct scsi_request ** aSRpnt, int where, int count) 2178static int __osst_write_header(struct osst_tape * STp, struct osst_request ** aSRpnt, int where, int count)
2126{ 2179{
2127 char * name = tape_name(STp); 2180 char * name = tape_name(STp);
2128 int result; 2181 int result;
@@ -2149,7 +2202,7 @@ static int __osst_write_header(struct osst_tape * STp, struct scsi_request ** aS
2149 return result; 2202 return result;
2150} 2203}
2151 2204
2152static int osst_write_header(struct osst_tape * STp, struct scsi_request ** aSRpnt, int locate_eod) 2205static int osst_write_header(struct osst_tape * STp, struct osst_request ** aSRpnt, int locate_eod)
2153{ 2206{
2154 os_header_t * header; 2207 os_header_t * header;
2155 int result; 2208 int result;
@@ -2223,7 +2276,7 @@ static int osst_write_header(struct osst_tape * STp, struct scsi_request ** aSRp
2223 return result; 2276 return result;
2224} 2277}
2225 2278
2226static int osst_reset_header(struct osst_tape * STp, struct scsi_request ** aSRpnt) 2279static int osst_reset_header(struct osst_tape * STp, struct osst_request ** aSRpnt)
2227{ 2280{
2228 if (STp->header_cache != NULL) 2281 if (STp->header_cache != NULL)
2229 memset(STp->header_cache, 0, sizeof(os_header_t)); 2282 memset(STp->header_cache, 0, sizeof(os_header_t));
@@ -2236,7 +2289,7 @@ static int osst_reset_header(struct osst_tape * STp, struct scsi_request ** aSRp
2236 return osst_write_header(STp, aSRpnt, 1); 2289 return osst_write_header(STp, aSRpnt, 1);
2237} 2290}
2238 2291
2239static int __osst_analyze_headers(struct osst_tape * STp, struct scsi_request ** aSRpnt, int ppos) 2292static int __osst_analyze_headers(struct osst_tape * STp, struct osst_request ** aSRpnt, int ppos)
2240{ 2293{
2241 char * name = tape_name(STp); 2294 char * name = tape_name(STp);
2242 os_header_t * header; 2295 os_header_t * header;
@@ -2413,7 +2466,7 @@ static int __osst_analyze_headers(struct osst_tape * STp, struct scsi_request **
2413 return 1; 2466 return 1;
2414} 2467}
2415 2468
2416static int osst_analyze_headers(struct osst_tape * STp, struct scsi_request ** aSRpnt) 2469static int osst_analyze_headers(struct osst_tape * STp, struct osst_request ** aSRpnt)
2417{ 2470{
2418 int position, ppos; 2471 int position, ppos;
2419 int first, last; 2472 int first, last;
@@ -2468,7 +2521,7 @@ static int osst_analyze_headers(struct osst_tape * STp, struct scsi_request ** a
2468 return 1; 2521 return 1;
2469} 2522}
2470 2523
2471static int osst_verify_position(struct osst_tape * STp, struct scsi_request ** aSRpnt) 2524static int osst_verify_position(struct osst_tape * STp, struct osst_request ** aSRpnt)
2472{ 2525{
2473 int frame_position = STp->first_frame_position; 2526 int frame_position = STp->first_frame_position;
2474 int frame_seq_numbr = STp->frame_seq_number; 2527 int frame_seq_numbr = STp->frame_seq_number;
@@ -2544,11 +2597,11 @@ static unsigned int osst_parse_firmware_rev (const char * str)
2544/* 2597/*
2545 * Configure the OnStream SCII tape drive for default operation 2598 * Configure the OnStream SCII tape drive for default operation
2546 */ 2599 */
2547static int osst_configure_onstream(struct osst_tape *STp, struct scsi_request ** aSRpnt) 2600static int osst_configure_onstream(struct osst_tape *STp, struct osst_request ** aSRpnt)
2548{ 2601{
2549 unsigned char cmd[MAX_COMMAND_SIZE]; 2602 unsigned char cmd[MAX_COMMAND_SIZE];
2550 char * name = tape_name(STp); 2603 char * name = tape_name(STp);
2551 struct scsi_request * SRpnt = * aSRpnt; 2604 struct osst_request * SRpnt = * aSRpnt;
2552 osst_mode_parameter_header_t * header; 2605 osst_mode_parameter_header_t * header;
2553 osst_block_size_page_t * bs; 2606 osst_block_size_page_t * bs;
2554 osst_capabilities_page_t * cp; 2607 osst_capabilities_page_t * cp;
@@ -2715,7 +2768,7 @@ static int osst_configure_onstream(struct osst_tape *STp, struct scsi_request **
2715 2768
2716/* Step over EOF if it has been inadvertently crossed (ioctl not used because 2769/* Step over EOF if it has been inadvertently crossed (ioctl not used because
2717 it messes up the block number). */ 2770 it messes up the block number). */
2718static int cross_eof(struct osst_tape *STp, struct scsi_request ** aSRpnt, int forward) 2771static int cross_eof(struct osst_tape *STp, struct osst_request ** aSRpnt, int forward)
2719{ 2772{
2720 int result; 2773 int result;
2721 char * name = tape_name(STp); 2774 char * name = tape_name(STp);
@@ -2744,10 +2797,10 @@ static int cross_eof(struct osst_tape *STp, struct scsi_request ** aSRpnt, int f
2744 2797
2745/* Get the tape position. */ 2798/* Get the tape position. */
2746 2799
2747static int osst_get_frame_position(struct osst_tape *STp, struct scsi_request ** aSRpnt) 2800static int osst_get_frame_position(struct osst_tape *STp, struct osst_request ** aSRpnt)
2748{ 2801{
2749 unsigned char scmd[MAX_COMMAND_SIZE]; 2802 unsigned char scmd[MAX_COMMAND_SIZE];
2750 struct scsi_request * SRpnt; 2803 struct osst_request * SRpnt;
2751 int result = 0; 2804 int result = 0;
2752 char * name = tape_name(STp); 2805 char * name = tape_name(STp);
2753 2806
@@ -2772,14 +2825,14 @@ static int osst_get_frame_position(struct osst_tape *STp, struct scsi_request **
2772 *aSRpnt = SRpnt; 2825 *aSRpnt = SRpnt;
2773 2826
2774 if (STp->buffer->syscall_result) 2827 if (STp->buffer->syscall_result)
2775 result = ((SRpnt->sr_sense_buffer[2] & 0x0f) == 3) ? -EIO : -EINVAL; /* 3: Write Error */ 2828 result = ((SRpnt->sense[2] & 0x0f) == 3) ? -EIO : -EINVAL; /* 3: Write Error */
2776 2829
2777 if (result == -EINVAL) 2830 if (result == -EINVAL)
2778 printk(KERN_ERR "%s:E: Can't read tape position.\n", name); 2831 printk(KERN_ERR "%s:E: Can't read tape position.\n", name);
2779 else { 2832 else {
2780 if (result == -EIO) { /* re-read position - this needs to preserve media errors */ 2833 if (result == -EIO) { /* re-read position - this needs to preserve media errors */
2781 unsigned char mysense[16]; 2834 unsigned char mysense[16];
2782 memcpy (mysense, SRpnt->sr_sense_buffer, 16); 2835 memcpy (mysense, SRpnt->sense, 16);
2783 memset (scmd, 0, MAX_COMMAND_SIZE); 2836 memset (scmd, 0, MAX_COMMAND_SIZE);
2784 scmd[0] = READ_POSITION; 2837 scmd[0] = READ_POSITION;
2785 STp->buffer->b_data = mybuf; STp->buffer->buffer_size = 24; 2838 STp->buffer->b_data = mybuf; STp->buffer->buffer_size = 24;
@@ -2788,10 +2841,10 @@ static int osst_get_frame_position(struct osst_tape *STp, struct scsi_request **
2788#if DEBUG 2841#if DEBUG
2789 printk(OSST_DEB_MSG "%s:D: Reread position, reason=[%02x:%02x:%02x], result=[%s%02x:%02x:%02x]\n", 2842 printk(OSST_DEB_MSG "%s:D: Reread position, reason=[%02x:%02x:%02x], result=[%s%02x:%02x:%02x]\n",
2790 name, mysense[2], mysense[12], mysense[13], STp->buffer->syscall_result?"":"ok:", 2843 name, mysense[2], mysense[12], mysense[13], STp->buffer->syscall_result?"":"ok:",
2791 SRpnt->sr_sense_buffer[2],SRpnt->sr_sense_buffer[12],SRpnt->sr_sense_buffer[13]); 2844 SRpnt->sense[2],SRpnt->sense[12],SRpnt->sense[13]);
2792#endif 2845#endif
2793 if (!STp->buffer->syscall_result) 2846 if (!STp->buffer->syscall_result)
2794 memcpy (SRpnt->sr_sense_buffer, mysense, 16); 2847 memcpy (SRpnt->sense, mysense, 16);
2795 else 2848 else
2796 printk(KERN_WARNING "%s:W: Double error in get position\n", name); 2849 printk(KERN_WARNING "%s:W: Double error in get position\n", name);
2797 } 2850 }
@@ -2828,10 +2881,10 @@ static int osst_get_frame_position(struct osst_tape *STp, struct scsi_request **
2828 2881
2829 2882
2830/* Set the tape block */ 2883/* Set the tape block */
2831static int osst_set_frame_position(struct osst_tape *STp, struct scsi_request ** aSRpnt, int ppos, int skip) 2884static int osst_set_frame_position(struct osst_tape *STp, struct osst_request ** aSRpnt, int ppos, int skip)
2832{ 2885{
2833 unsigned char scmd[MAX_COMMAND_SIZE]; 2886 unsigned char scmd[MAX_COMMAND_SIZE];
2834 struct scsi_request * SRpnt; 2887 struct osst_request * SRpnt;
2835 struct st_partstat * STps; 2888 struct st_partstat * STps;
2836 int result = 0; 2889 int result = 0;
2837 int pp = (ppos == 3000 && !skip)? 0 : ppos; 2890 int pp = (ppos == 3000 && !skip)? 0 : ppos;
@@ -2886,7 +2939,7 @@ static int osst_set_frame_position(struct osst_tape *STp, struct scsi_request **
2886 return result; 2939 return result;
2887} 2940}
2888 2941
2889static int osst_write_trailer(struct osst_tape *STp, struct scsi_request ** aSRpnt, int leave_at_EOT) 2942static int osst_write_trailer(struct osst_tape *STp, struct osst_request ** aSRpnt, int leave_at_EOT)
2890{ 2943{
2891 struct st_partstat * STps = &(STp->ps[STp->partition]); 2944 struct st_partstat * STps = &(STp->ps[STp->partition]);
2892 int result = 0; 2945 int result = 0;
@@ -2913,12 +2966,12 @@ out:
2913/* osst versions of st functions - augmented and stripped to suit OnStream only */ 2966/* osst versions of st functions - augmented and stripped to suit OnStream only */
2914 2967
2915/* Flush the write buffer (never need to write if variable blocksize). */ 2968/* Flush the write buffer (never need to write if variable blocksize). */
2916static int osst_flush_write_buffer(struct osst_tape *STp, struct scsi_request ** aSRpnt) 2969static int osst_flush_write_buffer(struct osst_tape *STp, struct osst_request ** aSRpnt)
2917{ 2970{
2918 int offset, transfer, blks = 0; 2971 int offset, transfer, blks = 0;
2919 int result = 0; 2972 int result = 0;
2920 unsigned char cmd[MAX_COMMAND_SIZE]; 2973 unsigned char cmd[MAX_COMMAND_SIZE];
2921 struct scsi_request * SRpnt = *aSRpnt; 2974 struct osst_request * SRpnt = *aSRpnt;
2922 struct st_partstat * STps; 2975 struct st_partstat * STps;
2923 char * name = tape_name(STp); 2976 char * name = tape_name(STp);
2924 2977
@@ -2926,13 +2979,13 @@ static int osst_flush_write_buffer(struct osst_tape *STp, struct scsi_request **
2926 if (SRpnt == (STp->buffer)->last_SRpnt) 2979 if (SRpnt == (STp->buffer)->last_SRpnt)
2927#if DEBUG 2980#if DEBUG
2928 { printk(OSST_DEB_MSG 2981 { printk(OSST_DEB_MSG
2929 "%s:D: aSRpnt points to scsi_request that write_behind_check will release -- cleared\n", name); 2982 "%s:D: aSRpnt points to osst_request that write_behind_check will release -- cleared\n", name);
2930#endif 2983#endif
2931 *aSRpnt = SRpnt = NULL; 2984 *aSRpnt = SRpnt = NULL;
2932#if DEBUG 2985#if DEBUG
2933 } else if (SRpnt) 2986 } else if (SRpnt)
2934 printk(OSST_DEB_MSG 2987 printk(OSST_DEB_MSG
2935 "%s:D: aSRpnt does not point to scsi_request that write_behind_check will release -- strange\n", name); 2988 "%s:D: aSRpnt does not point to osst_request that write_behind_check will release -- strange\n", name);
2936#endif 2989#endif
2937 osst_write_behind_check(STp); 2990 osst_write_behind_check(STp);
2938 if ((STp->buffer)->syscall_result) { 2991 if ((STp->buffer)->syscall_result) {
@@ -3010,12 +3063,12 @@ static int osst_flush_write_buffer(struct osst_tape *STp, struct scsi_request **
3010#if DEBUG 3063#if DEBUG
3011 printk(OSST_DEB_MSG 3064 printk(OSST_DEB_MSG
3012 "%s:D: write sense [0]=0x%02x [2]=%02x [12]=%02x [13]=%02x\n", 3065 "%s:D: write sense [0]=0x%02x [2]=%02x [12]=%02x [13]=%02x\n",
3013 name, SRpnt->sr_sense_buffer[0], SRpnt->sr_sense_buffer[2], 3066 name, SRpnt->sense[0], SRpnt->sense[2],
3014 SRpnt->sr_sense_buffer[12], SRpnt->sr_sense_buffer[13]); 3067 SRpnt->sense[12], SRpnt->sense[13]);
3015#endif 3068#endif
3016 if ((SRpnt->sr_sense_buffer[0] & 0x70) == 0x70 && 3069 if ((SRpnt->sense[0] & 0x70) == 0x70 &&
3017 (SRpnt->sr_sense_buffer[2] & 0x40) && /* FIXME - SC-30 drive doesn't assert EOM bit */ 3070 (SRpnt->sense[2] & 0x40) && /* FIXME - SC-30 drive doesn't assert EOM bit */
3018 (SRpnt->sr_sense_buffer[2] & 0x0f) == NO_SENSE) { 3071 (SRpnt->sense[2] & 0x0f) == NO_SENSE) {
3019 STp->dirty = 0; 3072 STp->dirty = 0;
3020 (STp->buffer)->buffer_bytes = 0; 3073 (STp->buffer)->buffer_bytes = 0;
3021 result = (-ENOSPC); 3074 result = (-ENOSPC);
@@ -3043,7 +3096,7 @@ static int osst_flush_write_buffer(struct osst_tape *STp, struct scsi_request **
3043 3096
3044/* Flush the tape buffer. The tape will be positioned correctly unless 3097/* Flush the tape buffer. The tape will be positioned correctly unless
3045 seek_next is true. */ 3098 seek_next is true. */
3046static int osst_flush_buffer(struct osst_tape * STp, struct scsi_request ** aSRpnt, int seek_next) 3099static int osst_flush_buffer(struct osst_tape * STp, struct osst_request ** aSRpnt, int seek_next)
3047{ 3100{
3048 struct st_partstat * STps; 3101 struct st_partstat * STps;
3049 int backspace = 0, result = 0; 3102 int backspace = 0, result = 0;
@@ -3105,10 +3158,10 @@ static int osst_flush_buffer(struct osst_tape * STp, struct scsi_request ** aSRp
3105 return result; 3158 return result;
3106} 3159}
3107 3160
3108static int osst_write_frame(struct osst_tape * STp, struct scsi_request ** aSRpnt, int synchronous) 3161static int osst_write_frame(struct osst_tape * STp, struct osst_request ** aSRpnt, int synchronous)
3109{ 3162{
3110 unsigned char cmd[MAX_COMMAND_SIZE]; 3163 unsigned char cmd[MAX_COMMAND_SIZE];
3111 struct scsi_request * SRpnt; 3164 struct osst_request * SRpnt;
3112 int blks; 3165 int blks;
3113#if DEBUG 3166#if DEBUG
3114 char * name = tape_name(STp); 3167 char * name = tape_name(STp);
@@ -3169,9 +3222,9 @@ static int osst_write_frame(struct osst_tape * STp, struct scsi_request ** aSRpn
3169 if (debugging) 3222 if (debugging)
3170 printk(OSST_DEB_MSG "%s:D: Error on write:\n", name); 3223 printk(OSST_DEB_MSG "%s:D: Error on write:\n", name);
3171#endif 3224#endif
3172 if ((SRpnt->sr_sense_buffer[0] & 0x70) == 0x70 && 3225 if ((SRpnt->sense[0] & 0x70) == 0x70 &&
3173 (SRpnt->sr_sense_buffer[2] & 0x40)) { 3226 (SRpnt->sense[2] & 0x40)) {
3174 if ((SRpnt->sr_sense_buffer[2] & 0x0f) == VOLUME_OVERFLOW) 3227 if ((SRpnt->sense[2] & 0x0f) == VOLUME_OVERFLOW)
3175 return (-ENOSPC); 3228 return (-ENOSPC);
3176 } 3229 }
3177 else { 3230 else {
@@ -3188,7 +3241,7 @@ static int osst_write_frame(struct osst_tape * STp, struct scsi_request ** aSRpn
3188 return 0; 3241 return 0;
3189} 3242}
3190 3243
3191/* Lock or unlock the drive door. Don't use when struct scsi_request allocated. */ 3244/* Lock or unlock the drive door. Don't use when struct osst_request allocated. */
3192static int do_door_lock(struct osst_tape * STp, int do_lock) 3245static int do_door_lock(struct osst_tape * STp, int do_lock)
3193{ 3246{
3194 int retval, cmd; 3247 int retval, cmd;
@@ -3236,7 +3289,7 @@ static ssize_t osst_write(struct file * filp, const char __user * buf, size_t co
3236 int write_threshold; 3289 int write_threshold;
3237 int doing_write = 0; 3290 int doing_write = 0;
3238 const char __user * b_point; 3291 const char __user * b_point;
3239 struct scsi_request * SRpnt = NULL; 3292 struct osst_request * SRpnt = NULL;
3240 struct st_modedef * STm; 3293 struct st_modedef * STm;
3241 struct st_partstat * STps; 3294 struct st_partstat * STps;
3242 struct osst_tape * STp = filp->private_data; 3295 struct osst_tape * STp = filp->private_data;
@@ -3427,7 +3480,7 @@ if (SRpnt) printk(KERN_ERR "%s:A: Not supposed to have SRpnt at line %d\n", name
3427#if DEBUG 3480#if DEBUG
3428 if (debugging) 3481 if (debugging)
3429 printk(OSST_DEB_MSG "%s:D: Writing %d bytes to file %d block %d lblk %d fseq %d fppos %d\n", 3482 printk(OSST_DEB_MSG "%s:D: Writing %d bytes to file %d block %d lblk %d fseq %d fppos %d\n",
3430 name, count, STps->drv_file, STps->drv_block, 3483 name, (int) count, STps->drv_file, STps->drv_block,
3431 STp->logical_blk_num, STp->frame_seq_number, STp->first_frame_position); 3484 STp->logical_blk_num, STp->frame_seq_number, STp->first_frame_position);
3432#endif 3485#endif
3433 b_point = buf; 3486 b_point = buf;
@@ -3463,7 +3516,7 @@ if (SRpnt) printk(KERN_ERR "%s:A: Not supposed to have SRpnt at line %d\n", name
3463#if DEBUG 3516#if DEBUG
3464 if (debugging) 3517 if (debugging)
3465 printk(OSST_DEB_MSG "%s:D: EOM with %d bytes unwritten.\n", 3518 printk(OSST_DEB_MSG "%s:D: EOM with %d bytes unwritten.\n",
3466 name, transfer); 3519 name, (int) transfer);
3467#endif 3520#endif
3468 } 3521 }
3469 else { 3522 else {
@@ -3481,7 +3534,7 @@ if (SRpnt) printk(KERN_ERR "%s:A: Not supposed to have SRpnt at line %d\n", name
3481 3534
3482 if (retval < 0) { 3535 if (retval < 0) {
3483 if (SRpnt != NULL) { 3536 if (SRpnt != NULL) {
3484 scsi_release_request(SRpnt); 3537 osst_release_request(SRpnt);
3485 SRpnt = NULL; 3538 SRpnt = NULL;
3486 } 3539 }
3487 STp->buffer->buffer_bytes = 0; 3540 STp->buffer->buffer_bytes = 0;
@@ -3543,7 +3596,7 @@ if (SRpnt) printk(KERN_ERR "%s:A: Not supposed to have SRpnt at line %d\n", name
3543 retval = total; 3596 retval = total;
3544 3597
3545out: 3598out:
3546 if (SRpnt != NULL) scsi_release_request(SRpnt); 3599 if (SRpnt != NULL) osst_release_request(SRpnt);
3547 3600
3548 up(&STp->lock); 3601 up(&STp->lock);
3549 3602
@@ -3559,7 +3612,7 @@ static ssize_t osst_read(struct file * filp, char __user * buf, size_t count, lo
3559 int special; 3612 int special;
3560 struct st_modedef * STm; 3613 struct st_modedef * STm;
3561 struct st_partstat * STps; 3614 struct st_partstat * STps;
3562 struct scsi_request * SRpnt = NULL; 3615 struct osst_request * SRpnt = NULL;
3563 struct osst_tape * STp = filp->private_data; 3616 struct osst_tape * STp = filp->private_data;
3564 char * name = tape_name(STp); 3617 char * name = tape_name(STp);
3565 3618
@@ -3667,7 +3720,7 @@ static ssize_t osst_read(struct file * filp, char __user * buf, size_t count, lo
3667#if DEBUG 3720#if DEBUG
3668 if (debugging && STps->eof != ST_NOEOF) 3721 if (debugging && STps->eof != ST_NOEOF)
3669 printk(OSST_DEB_MSG "%s:D: EOF up (%d). Left %d, needed %d.\n", name, 3722 printk(OSST_DEB_MSG "%s:D: EOF up (%d). Left %d, needed %d.\n", name,
3670 STps->eof, (STp->buffer)->buffer_bytes, count - total); 3723 STps->eof, (STp->buffer)->buffer_bytes, (int) (count - total));
3671#endif 3724#endif
3672 /* force multiple of block size, note block_size may have been adjusted */ 3725 /* force multiple of block size, note block_size may have been adjusted */
3673 transfer = (((STp->buffer)->buffer_bytes < count - total ? 3726 transfer = (((STp->buffer)->buffer_bytes < count - total ?
@@ -3728,7 +3781,7 @@ static ssize_t osst_read(struct file * filp, char __user * buf, size_t count, lo
3728 retval = total; 3781 retval = total;
3729 3782
3730out: 3783out:
3731 if (SRpnt != NULL) scsi_release_request(SRpnt); 3784 if (SRpnt != NULL) osst_release_request(SRpnt);
3732 3785
3733 up(&STp->lock); 3786 up(&STp->lock);
3734 3787
@@ -3916,7 +3969,7 @@ static int osst_set_options(struct osst_tape *STp, long options)
3916 3969
3917 3970
3918/* Internal ioctl function */ 3971/* Internal ioctl function */
3919static int osst_int_ioctl(struct osst_tape * STp, struct scsi_request ** aSRpnt, 3972static int osst_int_ioctl(struct osst_tape * STp, struct osst_request ** aSRpnt,
3920 unsigned int cmd_in, unsigned long arg) 3973 unsigned int cmd_in, unsigned long arg)
3921{ 3974{
3922 int timeout; 3975 int timeout;
@@ -3924,7 +3977,7 @@ static int osst_int_ioctl(struct osst_tape * STp, struct scsi_request ** aSRpnt,
3924 int i, ioctl_result; 3977 int i, ioctl_result;
3925 int chg_eof = 1; 3978 int chg_eof = 1;
3926 unsigned char cmd[MAX_COMMAND_SIZE]; 3979 unsigned char cmd[MAX_COMMAND_SIZE];
3927 struct scsi_request * SRpnt = * aSRpnt; 3980 struct osst_request * SRpnt = * aSRpnt;
3928 struct st_partstat * STps; 3981 struct st_partstat * STps;
3929 int fileno, blkno, at_sm, frame_seq_numbr, logical_blk_num; 3982 int fileno, blkno, at_sm, frame_seq_numbr, logical_blk_num;
3930 int datalen = 0, direction = DMA_NONE; 3983 int datalen = 0, direction = DMA_NONE;
@@ -4282,14 +4335,14 @@ os_bypass:
4282 } else if (cmd_in == MTERASE) { 4335 } else if (cmd_in == MTERASE) {
4283 STp->header_ok = 0; 4336 STp->header_ok = 0;
4284 } else if (SRpnt) { /* SCSI command was not completely successful. */ 4337 } else if (SRpnt) { /* SCSI command was not completely successful. */
4285 if (SRpnt->sr_sense_buffer[2] & 0x40) { 4338 if (SRpnt->sense[2] & 0x40) {
4286 STps->eof = ST_EOM_OK; 4339 STps->eof = ST_EOM_OK;
4287 STps->drv_block = 0; 4340 STps->drv_block = 0;
4288 } 4341 }
4289 if (chg_eof) 4342 if (chg_eof)
4290 STps->eof = ST_NOEOF; 4343 STps->eof = ST_NOEOF;
4291 4344
4292 if ((SRpnt->sr_sense_buffer[2] & 0x0f) == BLANK_CHECK) 4345 if ((SRpnt->sense[2] & 0x0f) == BLANK_CHECK)
4293 STps->eof = ST_EOD; 4346 STps->eof = ST_EOD;
4294 4347
4295 if (cmd_in == MTLOAD && osst_wait_for_medium(STp, &SRpnt, 60)) 4348 if (cmd_in == MTLOAD && osst_wait_for_medium(STp, &SRpnt, 60))
@@ -4307,7 +4360,7 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp)
4307 unsigned short flags; 4360 unsigned short flags;
4308 int i, b_size, new_session = 0, retval = 0; 4361 int i, b_size, new_session = 0, retval = 0;
4309 unsigned char cmd[MAX_COMMAND_SIZE]; 4362 unsigned char cmd[MAX_COMMAND_SIZE];
4310 struct scsi_request * SRpnt = NULL; 4363 struct osst_request * SRpnt = NULL;
4311 struct osst_tape * STp; 4364 struct osst_tape * STp;
4312 struct st_modedef * STm; 4365 struct st_modedef * STm;
4313 struct st_partstat * STps; 4366 struct st_partstat * STps;
@@ -4415,17 +4468,17 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp)
4415 retval = (STp->buffer)->syscall_result; /* FIXME - valid? */ 4468 retval = (STp->buffer)->syscall_result; /* FIXME - valid? */
4416 goto err_out; 4469 goto err_out;
4417 } 4470 }
4418 if ((SRpnt->sr_sense_buffer[0] & 0x70) == 0x70 && 4471 if ((SRpnt->sense[0] & 0x70) == 0x70 &&
4419 (SRpnt->sr_sense_buffer[2] & 0x0f) == NOT_READY && 4472 (SRpnt->sense[2] & 0x0f) == NOT_READY &&
4420 SRpnt->sr_sense_buffer[12] == 4 ) { 4473 SRpnt->sense[12] == 4 ) {
4421#if DEBUG 4474#if DEBUG
4422 printk(OSST_DEB_MSG "%s:D: Unit not ready, cause %x\n", name, SRpnt->sr_sense_buffer[13]); 4475 printk(OSST_DEB_MSG "%s:D: Unit not ready, cause %x\n", name, SRpnt->sense[13]);
4423#endif 4476#endif
4424 if (filp->f_flags & O_NONBLOCK) { 4477 if (filp->f_flags & O_NONBLOCK) {
4425 retval = -EAGAIN; 4478 retval = -EAGAIN;
4426 goto err_out; 4479 goto err_out;
4427 } 4480 }
4428 if (SRpnt->sr_sense_buffer[13] == 2) { /* initialize command required (LOAD) */ 4481 if (SRpnt->sense[13] == 2) { /* initialize command required (LOAD) */
4429 memset (cmd, 0, MAX_COMMAND_SIZE); 4482 memset (cmd, 0, MAX_COMMAND_SIZE);
4430 cmd[0] = START_STOP; 4483 cmd[0] = START_STOP;
4431 cmd[1] = 1; 4484 cmd[1] = 1;
@@ -4433,10 +4486,10 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp)
4433 SRpnt = osst_do_scsi(SRpnt, STp, cmd, 0, DMA_NONE, 4486 SRpnt = osst_do_scsi(SRpnt, STp, cmd, 0, DMA_NONE,
4434 STp->timeout, MAX_RETRIES, 1); 4487 STp->timeout, MAX_RETRIES, 1);
4435 } 4488 }
4436 osst_wait_ready(STp, &SRpnt, (SRpnt->sr_sense_buffer[13]==1?15:3) * 60, 0); 4489 osst_wait_ready(STp, &SRpnt, (SRpnt->sense[13]==1?15:3) * 60, 0);
4437 } 4490 }
4438 if ((SRpnt->sr_sense_buffer[0] & 0x70) == 0x70 && 4491 if ((SRpnt->sense[0] & 0x70) == 0x70 &&
4439 (SRpnt->sr_sense_buffer[2] & 0x0f) == UNIT_ATTENTION) { /* New media? */ 4492 (SRpnt->sense[2] & 0x0f) == UNIT_ATTENTION) { /* New media? */
4440#if DEBUG 4493#if DEBUG
4441 printk(OSST_DEB_MSG "%s:D: Unit wants attention\n", name); 4494 printk(OSST_DEB_MSG "%s:D: Unit wants attention\n", name);
4442#endif 4495#endif
@@ -4449,8 +4502,8 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp)
4449 4502
4450 SRpnt = osst_do_scsi(SRpnt, STp, cmd, 0, DMA_NONE, 4503 SRpnt = osst_do_scsi(SRpnt, STp, cmd, 0, DMA_NONE,
4451 STp->timeout, MAX_RETRIES, 1); 4504 STp->timeout, MAX_RETRIES, 1);
4452 if ((SRpnt->sr_sense_buffer[0] & 0x70) != 0x70 || 4505 if ((SRpnt->sense[0] & 0x70) != 0x70 ||
4453 (SRpnt->sr_sense_buffer[2] & 0x0f) != UNIT_ATTENTION) 4506 (SRpnt->sense[2] & 0x0f) != UNIT_ATTENTION)
4454 break; 4507 break;
4455 } 4508 }
4456 4509
@@ -4476,7 +4529,7 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp)
4476 * open without reconfiguring and re-reading the headers 4529 * open without reconfiguring and re-reading the headers
4477 */ 4530 */
4478 if (!STp->buffer->syscall_result && STp->header_ok && 4531 if (!STp->buffer->syscall_result && STp->header_ok &&
4479 !SRpnt->sr_result && SRpnt->sr_sense_buffer[0] == 0) { 4532 !SRpnt->result && SRpnt->sense[0] == 0) {
4480 4533
4481 memset(cmd, 0, MAX_COMMAND_SIZE); 4534 memset(cmd, 0, MAX_COMMAND_SIZE);
4482 cmd[0] = MODE_SENSE; 4535 cmd[0] = MODE_SENSE;
@@ -4515,7 +4568,7 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp)
4515 } 4568 }
4516 STp->buffer->buffer_blocks = OS_DATA_SIZE / STp->block_size; 4569 STp->buffer->buffer_blocks = OS_DATA_SIZE / STp->block_size;
4517 STp->fast_open = 1; 4570 STp->fast_open = 1;
4518 scsi_release_request(SRpnt); 4571 osst_release_request(SRpnt);
4519 return 0; 4572 return 0;
4520 } 4573 }
4521#if DEBUG 4574#if DEBUG
@@ -4528,7 +4581,7 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp)
4528 STp->fast_open = 0; 4581 STp->fast_open = 0;
4529 4582
4530 if ((STp->buffer)->syscall_result != 0 && /* in all error conditions except no medium */ 4583 if ((STp->buffer)->syscall_result != 0 && /* in all error conditions except no medium */
4531 (SRpnt->sr_sense_buffer[2] != 2 || SRpnt->sr_sense_buffer[12] != 0x3A) ) { 4584 (SRpnt->sense[2] != 2 || SRpnt->sense[12] != 0x3A) ) {
4532 4585
4533 memset(cmd, 0, MAX_COMMAND_SIZE); 4586 memset(cmd, 0, MAX_COMMAND_SIZE);
4534 cmd[0] = MODE_SELECT; 4587 cmd[0] = MODE_SELECT;
@@ -4558,11 +4611,11 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp)
4558 4611
4559 SRpnt = osst_do_scsi(SRpnt, STp, cmd, 0, DMA_NONE, 4612 SRpnt = osst_do_scsi(SRpnt, STp, cmd, 0, DMA_NONE,
4560 STp->timeout, MAX_RETRIES, 1); 4613 STp->timeout, MAX_RETRIES, 1);
4561 if ((SRpnt->sr_sense_buffer[0] & 0x70) != 0x70 || 4614 if ((SRpnt->sense[0] & 0x70) != 0x70 ||
4562 (SRpnt->sr_sense_buffer[2] & 0x0f) == NOT_READY) 4615 (SRpnt->sense[2] & 0x0f) == NOT_READY)
4563 break; 4616 break;
4564 4617
4565 if ((SRpnt->sr_sense_buffer[2] & 0x0f) == UNIT_ATTENTION) { 4618 if ((SRpnt->sense[2] & 0x0f) == UNIT_ATTENTION) {
4566 STp->pos_unknown = 0; 4619 STp->pos_unknown = 0;
4567 STp->partition = STp->new_partition = 0; 4620 STp->partition = STp->new_partition = 0;
4568 if (STp->can_partitions) 4621 if (STp->can_partitions)
@@ -4586,13 +4639,13 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp)
4586 4639
4587 if ((STp->buffer)->syscall_result != 0) { 4640 if ((STp->buffer)->syscall_result != 0) {
4588 if ((STp->device)->scsi_level >= SCSI_2 && 4641 if ((STp->device)->scsi_level >= SCSI_2 &&
4589 (SRpnt->sr_sense_buffer[0] & 0x70) == 0x70 && 4642 (SRpnt->sense[0] & 0x70) == 0x70 &&
4590 (SRpnt->sr_sense_buffer[2] & 0x0f) == NOT_READY && 4643 (SRpnt->sense[2] & 0x0f) == NOT_READY &&
4591 SRpnt->sr_sense_buffer[12] == 0x3a) { /* Check ASC */ 4644 SRpnt->sense[12] == 0x3a) { /* Check ASC */
4592 STp->ready = ST_NO_TAPE; 4645 STp->ready = ST_NO_TAPE;
4593 } else 4646 } else
4594 STp->ready = ST_NOT_READY; 4647 STp->ready = ST_NOT_READY;
4595 scsi_release_request(SRpnt); 4648 osst_release_request(SRpnt);
4596 SRpnt = NULL; 4649 SRpnt = NULL;
4597 STp->density = 0; /* Clear the erroneous "residue" */ 4650 STp->density = 0; /* Clear the erroneous "residue" */
4598 STp->write_prot = 0; 4651 STp->write_prot = 0;
@@ -4652,14 +4705,14 @@ static int os_scsi_tape_open(struct inode * inode, struct file * filp)
4652 4705
4653 osst_analyze_headers(STp, &SRpnt); 4706 osst_analyze_headers(STp, &SRpnt);
4654 4707
4655 scsi_release_request(SRpnt); 4708 osst_release_request(SRpnt);
4656 SRpnt = NULL; 4709 SRpnt = NULL;
4657 4710
4658 return 0; 4711 return 0;
4659 4712
4660err_out: 4713err_out:
4661 if (SRpnt != NULL) 4714 if (SRpnt != NULL)
4662 scsi_release_request(SRpnt); 4715 osst_release_request(SRpnt);
4663 normalize_buffer(STp->buffer); 4716 normalize_buffer(STp->buffer);
4664 STp->header_ok = 0; 4717 STp->header_ok = 0;
4665 STp->in_use = 0; 4718 STp->in_use = 0;
@@ -4676,7 +4729,7 @@ static int os_scsi_tape_flush(struct file * filp)
4676 struct osst_tape * STp = filp->private_data; 4729 struct osst_tape * STp = filp->private_data;
4677 struct st_modedef * STm = &(STp->modes[STp->current_mode]); 4730 struct st_modedef * STm = &(STp->modes[STp->current_mode]);
4678 struct st_partstat * STps = &(STp->ps[STp->partition]); 4731 struct st_partstat * STps = &(STp->ps[STp->partition]);
4679 struct scsi_request * SRpnt = NULL; 4732 struct osst_request * SRpnt = NULL;
4680 char * name = tape_name(STp); 4733 char * name = tape_name(STp);
4681 4734
4682 if (file_count(filp) > 1) 4735 if (file_count(filp) > 1)
@@ -4739,7 +4792,7 @@ out:
4739 if (result == 0 && result2 < 0) 4792 if (result == 0 && result2 < 0)
4740 result = result2; 4793 result = result2;
4741 } 4794 }
4742 if (SRpnt) scsi_release_request(SRpnt); 4795 if (SRpnt) osst_release_request(SRpnt);
4743 4796
4744 if (STp->abort_count || STp->recover_count) { 4797 if (STp->abort_count || STp->recover_count) {
4745 printk(KERN_INFO "%s:I:", name); 4798 printk(KERN_INFO "%s:I:", name);
@@ -4793,7 +4846,7 @@ static int osst_ioctl(struct inode * inode,struct file * file,
4793 unsigned int blk; 4846 unsigned int blk;
4794 struct st_modedef * STm; 4847 struct st_modedef * STm;
4795 struct st_partstat * STps; 4848 struct st_partstat * STps;
4796 struct scsi_request * SRpnt = NULL; 4849 struct osst_request * SRpnt = NULL;
4797 struct osst_tape * STp = file->private_data; 4850 struct osst_tape * STp = file->private_data;
4798 char * name = tape_name(STp); 4851 char * name = tape_name(STp);
4799 void __user * p = (void __user *)arg; 4852 void __user * p = (void __user *)arg;
@@ -5107,14 +5160,14 @@ static int osst_ioctl(struct inode * inode,struct file * file,
5107 retval = -EFAULT; 5160 retval = -EFAULT;
5108 goto out; 5161 goto out;
5109 } 5162 }
5110 if (SRpnt) scsi_release_request(SRpnt); 5163 if (SRpnt) osst_release_request(SRpnt);
5111 5164
5112 up(&STp->lock); 5165 up(&STp->lock);
5113 5166
5114 return scsi_ioctl(STp->device, cmd_in, p); 5167 return scsi_ioctl(STp->device, cmd_in, p);
5115 5168
5116out: 5169out:
5117 if (SRpnt) scsi_release_request(SRpnt); 5170 if (SRpnt) osst_release_request(SRpnt);
5118 5171
5119 up(&STp->lock); 5172 up(&STp->lock);
5120 5173
@@ -5667,7 +5720,7 @@ static int osst_probe(struct device *dev)
5667 struct st_partstat * STps; 5720 struct st_partstat * STps;
5668 struct osst_buffer * buffer; 5721 struct osst_buffer * buffer;
5669 struct gendisk * drive; 5722 struct gendisk * drive;
5670 int i, mode, dev_num; 5723 int i, dev_num;
5671 5724
5672 if (SDp->type != TYPE_TAPE || !osst_supports(SDp)) 5725 if (SDp->type != TYPE_TAPE || !osst_supports(SDp))
5673 return -ENODEV; 5726 return -ENODEV;
@@ -5803,18 +5856,6 @@ static int osst_probe(struct device *dev)
5803 snprintf(name, 8, "%s%s", "n", tape_name(tpnt)); 5856 snprintf(name, 8, "%s%s", "n", tape_name(tpnt));
5804 osst_sysfs_add(MKDEV(OSST_MAJOR, dev_num + 128), dev, tpnt, name); 5857 osst_sysfs_add(MKDEV(OSST_MAJOR, dev_num + 128), dev, tpnt, name);
5805 } 5858 }
5806 for (mode = 0; mode < ST_NBR_MODES; ++mode) {
5807 /* Rewind entry */
5808 devfs_mk_cdev(MKDEV(OSST_MAJOR, dev_num + (mode << 5)),
5809 S_IFCHR | S_IRUGO | S_IWUGO,
5810 "%s/ot%s", SDp->devfs_name, osst_formats[mode]);
5811
5812 /* No-rewind entry */
5813 devfs_mk_cdev(MKDEV(OSST_MAJOR, dev_num + (mode << 5) + 128),
5814 S_IFCHR | S_IRUGO | S_IWUGO,
5815 "%s/ot%sn", SDp->devfs_name, osst_formats[mode]);
5816 }
5817 drive->number = devfs_register_tape(SDp->devfs_name);
5818 5859
5819 sdev_printk(KERN_INFO, SDp, 5860 sdev_printk(KERN_INFO, SDp,
5820 "osst :I: Attached OnStream %.5s tape as %s\n", 5861 "osst :I: Attached OnStream %.5s tape as %s\n",
@@ -5831,7 +5872,7 @@ static int osst_remove(struct device *dev)
5831{ 5872{
5832 struct scsi_device * SDp = to_scsi_device(dev); 5873 struct scsi_device * SDp = to_scsi_device(dev);
5833 struct osst_tape * tpnt; 5874 struct osst_tape * tpnt;
5834 int i, mode; 5875 int i;
5835 5876
5836 if ((SDp->type != TYPE_TAPE) || (osst_nr_dev <= 0)) 5877 if ((SDp->type != TYPE_TAPE) || (osst_nr_dev <= 0))
5837 return 0; 5878 return 0;
@@ -5842,11 +5883,6 @@ static int osst_remove(struct device *dev)
5842 osst_sysfs_destroy(MKDEV(OSST_MAJOR, i)); 5883 osst_sysfs_destroy(MKDEV(OSST_MAJOR, i));
5843 osst_sysfs_destroy(MKDEV(OSST_MAJOR, i+128)); 5884 osst_sysfs_destroy(MKDEV(OSST_MAJOR, i+128));
5844 tpnt->device = NULL; 5885 tpnt->device = NULL;
5845 for (mode = 0; mode < ST_NBR_MODES; ++mode) {
5846 devfs_remove("%s/ot%s", SDp->devfs_name, osst_formats[mode]);
5847 devfs_remove("%s/ot%sn", SDp->devfs_name, osst_formats[mode]);
5848 }
5849 devfs_unregister_tape(tpnt->drive->number);
5850 put_disk(tpnt->drive); 5886 put_disk(tpnt->drive);
5851 os_scsi_tapes[i] = NULL; 5887 os_scsi_tapes[i] = NULL;
5852 osst_nr_dev--; 5888 osst_nr_dev--;