• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-WNDR4500-V1.0.1.40_1.0.68/src/linux/linux-2.6/drivers/block/paride/

Lines Matching defs:tape

5         This is the high-level driver for parallel port ATAPI tape
13 writes are padded to full tape blocks, so reading back a file
17 port ATAPI tape drive, but if their individual parameters are
201 /* bits in tape->flags */
221 int capacity; /* Size of tape in KB */
227 static int pt_identify(struct pt_unit *tape);
262 static inline u8 DRIVE(struct pt_unit *tape)
264 return 0xa0+0x10*tape->drive;
267 static int pt_wait(struct pt_unit *tape, int go, int stop, char *fun, char *msg)
270 struct pi_adapter *pi = tape->pi;
286 tape->name, fun, msg, r, s, e, j, p);
292 static int pt_command(struct pt_unit *tape, char *cmd, int dlen, char *fun)
294 struct pi_adapter *pi = tape->pi;
297 write_reg(pi, 6, DRIVE(tape));
299 if (pt_wait(tape, STAT_BUSY | STAT_DRQ, 0, fun, "before command")) {
308 if (pt_wait(tape, STAT_BUSY, STAT_DRQ, fun, "command DRQ")) {
314 printk("%s: %s: command phase error\n", tape->name, fun);
324 static int pt_completion(struct pt_unit *tape, char *buf, char *fun)
326 struct pi_adapter *pi = tape->pi;
329 r = pt_wait(tape, STAT_BUSY, STAT_DRQ | STAT_READY | STAT_ERR,
342 s = pt_wait(tape, STAT_BUSY, STAT_READY | STAT_ERR, fun, "data done");
349 static void pt_req_sense(struct pt_unit *tape, int quiet)
355 r = pt_command(tape, rs_cmd, 16, "Request sense");
358 pt_completion(tape, buf, "Request sense");
360 tape->last_sense = -1;
364 tape->name, buf[2] & 0xf, buf[12], buf[13]);
365 tape->last_sense = (buf[2] & 0xf) | ((buf[12] & 0xff) << 8)
370 static int pt_atapi(struct pt_unit *tape, char *cmd, int dlen, char *buf, char *fun)
374 r = pt_command(tape, cmd, dlen, fun);
377 r = pt_completion(tape, buf, fun);
379 pt_req_sense(tape, !fun);
389 static int pt_poll_dsc(struct pt_unit *tape, int pause, int tmo, char *msg)
391 struct pi_adapter *pi = tape->pi;
401 write_reg(pi, 6, DRIVE(tape));
410 printk("%s: %s DSC timeout\n", tape->name, msg);
412 printk("%s: %s stat=0x%x err=0x%x\n", tape->name, msg, s,
414 pt_req_sense(tape, 0);
420 static void pt_media_access_cmd(struct pt_unit *tape, int tmo, char *cmd, char *fun)
422 if (pt_command(tape, cmd, 0, fun)) {
423 pt_req_sense(tape, 0);
426 pi_disconnect(tape->pi);
427 pt_poll_dsc(tape, HZ, tmo, fun);
430 static void pt_rewind(struct pt_unit *tape)
434 pt_media_access_cmd(tape, PT_REWIND_TMO, rw_cmd, "rewind");
437 static void pt_write_fm(struct pt_unit *tape)
441 pt_media_access_cmd(tape, PT_TMO, wm_cmd, "write filemark");
446 static int pt_reset(struct pt_unit *tape)
448 struct pi_adapter *pi = tape->pi;
453 write_reg(pi, 6, DRIVE(tape));
467 printk("%s: Reset (%d) signature = ", tape->name, k);
479 static int pt_ready_wait(struct pt_unit *tape, int tmo)
486 tape->last_sense = 0;
487 pt_atapi(tape, tr_cmd, 0, NULL, DBMSG("test unit ready"));
488 p = tape->last_sense;
523 static int pt_identify(struct pt_unit *tape)
535 s = pt_atapi(tape, id_cmd, 36, buf, "identify");
543 tape->name, tape->drive, dt);
550 tape->flags = 0;
551 tape->capacity = 0;
552 tape->bs = 0;
554 if (!pt_ready_wait(tape, PT_READY_TMO))
555 tape->flags |= PT_MEDIA;
557 if (!pt_atapi(tape, ms_cmd, 36, buf, "mode sense")) {
559 tape->flags |= PT_WRITE_OK;
560 tape->bs = xn(buf, 10, 2);
563 if (!pt_atapi(tape, ls_cmd, 36, buf, "log sense"))
564 tape->capacity = xn(buf, 24, 4);
566 printk("%s: %s %s, %s", tape->name, mf, id, ms[tape->drive]);
567 if (!(tape->flags & PT_MEDIA))
570 if (!(tape->flags & PT_WRITE_OK))
572 printk(", blocksize %d, %d MB\n", tape->bs, tape->capacity / 1024);
583 static int pt_probe(struct pt_unit *tape)
585 if (tape->drive == -1) {
586 for (tape->drive = 0; tape->drive <= 1; tape->drive++)
587 if (!pt_reset(tape))
588 return pt_identify(tape);
590 if (!pt_reset(tape))
591 return pt_identify(tape);
598 struct pt_unit *tape;
606 struct pt_unit *tape = &pt[unit];
607 tape->pi = &tape->pia;
608 atomic_set(&tape->available, 1);
609 tape->flags = 0;
610 tape->last_sense = 0;
611 tape->present = 0;
612 tape->bufptr = NULL;
613 tape->drive = DU[D_SLV];
614 snprintf(tape->name, PT_NAMELEN, "%s%d", name, unit);
618 if (pi_init(tape->pi, 0, DU[D_PRT], DU[D_MOD], DU[D_UNI],
620 verbose, tape->name)) {
621 if (!pt_probe(tape)) {
622 tape->present = 1;
625 pi_release(tape->pi);
629 tape = pt;
630 if (pi_init(tape->pi, 1, -1, -1, -1, -1, -1, pt_scratch,
631 PI_PT, verbose, tape->name)) {
632 if (!pt_probe(tape)) {
633 tape->present = 1;
636 pi_release(tape->pi);
643 printk("%s: No ATAPI tape drive detected\n", name);
650 struct pt_unit *tape = pt + unit;
653 if (unit >= PT_UNITS || (!tape->present))
657 if (!atomic_dec_and_test(&tape->available))
660 pt_identify(tape);
663 if (!tape->flags & PT_MEDIA)
667 if ((!tape->flags & PT_WRITE_OK) && (file->f_mode & 2))
671 tape->flags |= PT_REWIND;
674 tape->bufptr = kmalloc(PT_BUFSIZE, GFP_KERNEL);
675 if (tape->bufptr == NULL) {
676 printk("%s: buffer allocation failed\n", tape->name);
680 file->private_data = tape;
684 atomic_inc(&tape->available);
691 struct pt_unit *tape = file->private_data;
703 pt_rewind(tape);
707 pt_write_fm(tape);
711 printk("%s: Unimplemented mt_op %d\n", tape->name,
717 printk("%s: Unimplemented ioctl 0x%x\n", tape->name, cmd);
726 struct pt_unit *tape = file->private_data;
728 if (atomic_read(&tape->available) > 1)
731 if (tape->flags & PT_WRITING)
732 pt_write_fm(tape);
734 if (tape->flags & PT_REWIND)
735 pt_rewind(tape);
737 kfree(tape->bufptr);
738 tape->bufptr = NULL;
740 atomic_inc(&tape->available);
748 struct pt_unit *tape = filp->private_data;
749 struct pi_adapter *pi = tape->pi;
753 if (!(tape->flags & (PT_READING | PT_WRITING))) {
754 tape->flags |= PT_READING;
755 if (pt_atapi(tape, rd_cmd, 0, NULL, "start read-ahead"))
757 } else if (tape->flags & PT_WRITING)
760 if (tape->flags & PT_EOF)
767 if (!pt_poll_dsc(tape, HZ / 100, PT_TMO, "read"))
773 b = (n - 1 + tape->bs) / tape->bs;
774 n = b * tape->bs; /* rounded up to even block */
778 r = pt_command(tape, rd_cmd, n, "read");
783 pt_req_sense(tape, 0);
789 r = pt_wait(tape, STAT_BUSY,
795 pt_req_sense(tape, 0);
800 tape->flags |= PT_EOF;
811 printk("%s: Phase error on read: %d\n", tape->name,
820 pi_read_block(pi, tape->bufptr, k);
825 if (copy_to_user(buf + t, tape->bufptr, b)) {
835 if (tape->flags & PT_EOF)
845 struct pt_unit *tape = filp->private_data;
846 struct pi_adapter *pi = tape->pi;
850 if (!(tape->flags & PT_WRITE_OK))
853 if (!(tape->flags & (PT_READING | PT_WRITING))) {
854 tape->flags |= PT_WRITING;
856 (tape, wr_cmd, 0, NULL, "start buffer-available mode"))
858 } else if (tape->flags & PT_READING)
861 if (tape->flags & PT_EOF)
868 if (!pt_poll_dsc(tape, HZ / 100, PT_TMO, "write"))
874 b = (n - 1 + tape->bs) / tape->bs;
875 n = b * tape->bs; /* rounded up to even block */
879 r = pt_command(tape, wr_cmd, n, "write");
884 pt_req_sense(tape, 0);
890 r = pt_wait(tape, STAT_BUSY,
896 pt_req_sense(tape, 0);
901 tape->flags |= PT_EOF;
913 tape->name, p);
924 if (copy_from_user(tape->bufptr, buf + t, b)) {
928 pi_write_block(pi, tape->bufptr, k);
936 if (tape->flags & PT_EOF)