• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/components/opensource/linux/linux-2.6.36/drivers/block/paride/

Lines Matching refs: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;
654 if (unit >= PT_UNITS || (!tape->present)) {
660 if (!atomic_dec_and_test(&tape->available))
663 pt_identify(tape);
666 if (!(tape->flags & PT_MEDIA))
670 if ((!(tape->flags & PT_WRITE_OK)) && (file->f_mode & FMODE_WRITE))
674 tape->flags |= PT_REWIND;
677 tape->bufptr = kmalloc(PT_BUFSIZE, GFP_KERNEL);
678 if (tape->bufptr == NULL) {
679 printk("%s: buffer allocation failed\n", tape->name);
683 file->private_data = tape;
688 atomic_inc(&tape->available);
695 struct pt_unit *tape = file->private_data;
708 pt_rewind(tape);
714 pt_write_fm(tape);
719 printk(KERN_DEBUG "%s: Unimplemented mt_op %d\n", tape->name,
732 struct pt_unit *tape = file->private_data;
734 if (atomic_read(&tape->available) > 1)
737 if (tape->flags & PT_WRITING)
738 pt_write_fm(tape);
740 if (tape->flags & PT_REWIND)
741 pt_rewind(tape);
743 kfree(tape->bufptr);
744 tape->bufptr = NULL;
746 atomic_inc(&tape->available);
754 struct pt_unit *tape = filp->private_data;
755 struct pi_adapter *pi = tape->pi;
759 if (!(tape->flags & (PT_READING | PT_WRITING))) {
760 tape->flags |= PT_READING;
761 if (pt_atapi(tape, rd_cmd, 0, NULL, "start read-ahead"))
763 } else if (tape->flags & PT_WRITING)
766 if (tape->flags & PT_EOF)
773 if (!pt_poll_dsc(tape, HZ / 100, PT_TMO, "read"))
779 b = (n - 1 + tape->bs) / tape->bs;
780 n = b * tape->bs; /* rounded up to even block */
784 r = pt_command(tape, rd_cmd, n, "read");
789 pt_req_sense(tape, 0);
795 r = pt_wait(tape, STAT_BUSY,
801 pt_req_sense(tape, 0);
806 tape->flags |= PT_EOF;
817 printk("%s: Phase error on read: %d\n", tape->name,
826 pi_read_block(pi, tape->bufptr, k);
831 if (copy_to_user(buf + t, tape->bufptr, b)) {
841 if (tape->flags & PT_EOF)
851 struct pt_unit *tape = filp->private_data;
852 struct pi_adapter *pi = tape->pi;
856 if (!(tape->flags & PT_WRITE_OK))
859 if (!(tape->flags & (PT_READING | PT_WRITING))) {
860 tape->flags |= PT_WRITING;
862 (tape, wr_cmd, 0, NULL, "start buffer-available mode"))
864 } else if (tape->flags & PT_READING)
867 if (tape->flags & PT_EOF)
874 if (!pt_poll_dsc(tape, HZ / 100, PT_TMO, "write"))
880 b = (n - 1 + tape->bs) / tape->bs;
881 n = b * tape->bs; /* rounded up to even block */
885 r = pt_command(tape, wr_cmd, n, "write");
890 pt_req_sense(tape, 0);
896 r = pt_wait(tape, STAT_BUSY,
902 pt_req_sense(tape, 0);
907 tape->flags |= PT_EOF;
919 tape->name, p);
930 if (copy_from_user(tape->bufptr, buf + t, b)) {
934 pi_write_block(pi, tape->bufptr, k);
942 if (tape->flags & PT_EOF)