diff options
author | Borislav Petkov <petkovbb@googlemail.com> | 2008-02-05 20:57:54 -0500 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-02-05 20:57:54 -0500 |
commit | 5a04cfa911f9c3c648240bd95002479d83619260 (patch) | |
tree | 07ea31b7df7482dfac6c43f3f96e9e2162407244 /drivers/ide | |
parent | 24d57f8b2880755b3704c110cd431b4dd6b75580 (diff) |
ide-tape: cleanup the remaining codestyle issues
... thus decreasing checkpatch.pl errors to 0.
Bart:
- remove needless function prototypes while at it
- remove needless parentheses while at it
- add missing KERN_ level to ide_tape_probe()
- other minor fixups
Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide')
-rw-r--r-- | drivers/ide/ide-tape.c | 832 |
1 files changed, 480 insertions, 352 deletions
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 0c56abe4378b..11e1383150d9 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -506,7 +506,7 @@ enum { | |||
506 | * The variables below are used for the character device interface. Additional | 506 | * The variables below are used for the character device interface. Additional |
507 | * state variables are defined in our ide_drive_t structure. | 507 | * state variables are defined in our ide_drive_t structure. |
508 | */ | 508 | */ |
509 | static struct ide_tape_obj * idetape_devs[MAX_HWIFS * MAX_DRIVES]; | 509 | static struct ide_tape_obj *idetape_devs[MAX_HWIFS * MAX_DRIVES]; |
510 | 510 | ||
511 | #define ide_tape_f(file) ((file)->private_data) | 511 | #define ide_tape_f(file) ((file)->private_data) |
512 | 512 | ||
@@ -522,20 +522,18 @@ static struct ide_tape_obj *ide_tape_chrdev_get(unsigned int i) | |||
522 | return tape; | 522 | return tape; |
523 | } | 523 | } |
524 | 524 | ||
525 | static int idetape_chrdev_release (struct inode *inode, struct file *filp); | ||
526 | static void idetape_write_release (ide_drive_t *drive, unsigned int minor); | ||
527 | |||
528 | /* | 525 | /* |
529 | * Too bad. The drive wants to send us data which we are not ready to accept. | 526 | * Too bad. The drive wants to send us data which we are not ready to accept. |
530 | * Just throw it away. | 527 | * Just throw it away. |
531 | */ | 528 | */ |
532 | static void idetape_discard_data (ide_drive_t *drive, unsigned int bcount) | 529 | static void idetape_discard_data(ide_drive_t *drive, unsigned int bcount) |
533 | { | 530 | { |
534 | while (bcount--) | 531 | while (bcount--) |
535 | (void) HWIF(drive)->INB(IDE_DATA_REG); | 532 | (void) HWIF(drive)->INB(IDE_DATA_REG); |
536 | } | 533 | } |
537 | 534 | ||
538 | static void idetape_input_buffers (ide_drive_t *drive, idetape_pc_t *pc, unsigned int bcount) | 535 | static void idetape_input_buffers(ide_drive_t *drive, idetape_pc_t *pc, |
536 | unsigned int bcount) | ||
539 | { | 537 | { |
540 | struct idetape_bh *bh = pc->bh; | 538 | struct idetape_bh *bh = pc->bh; |
541 | int count; | 539 | int count; |
@@ -547,8 +545,11 @@ static void idetape_input_buffers (ide_drive_t *drive, idetape_pc_t *pc, unsigne | |||
547 | idetape_discard_data(drive, bcount); | 545 | idetape_discard_data(drive, bcount); |
548 | return; | 546 | return; |
549 | } | 547 | } |
550 | count = min((unsigned int)(bh->b_size - atomic_read(&bh->b_count)), bcount); | 548 | count = min( |
551 | HWIF(drive)->atapi_input_bytes(drive, bh->b_data + atomic_read(&bh->b_count), count); | 549 | (unsigned int)(bh->b_size - atomic_read(&bh->b_count)), |
550 | bcount); | ||
551 | HWIF(drive)->atapi_input_bytes(drive, bh->b_data + | ||
552 | atomic_read(&bh->b_count), count); | ||
552 | bcount -= count; | 553 | bcount -= count; |
553 | atomic_add(count, &bh->b_count); | 554 | atomic_add(count, &bh->b_count); |
554 | if (atomic_read(&bh->b_count) == bh->b_size) { | 555 | if (atomic_read(&bh->b_count) == bh->b_size) { |
@@ -560,15 +561,16 @@ static void idetape_input_buffers (ide_drive_t *drive, idetape_pc_t *pc, unsigne | |||
560 | pc->bh = bh; | 561 | pc->bh = bh; |
561 | } | 562 | } |
562 | 563 | ||
563 | static void idetape_output_buffers (ide_drive_t *drive, idetape_pc_t *pc, unsigned int bcount) | 564 | static void idetape_output_buffers(ide_drive_t *drive, idetape_pc_t *pc, |
565 | unsigned int bcount) | ||
564 | { | 566 | { |
565 | struct idetape_bh *bh = pc->bh; | 567 | struct idetape_bh *bh = pc->bh; |
566 | int count; | 568 | int count; |
567 | 569 | ||
568 | while (bcount) { | 570 | while (bcount) { |
569 | if (bh == NULL) { | 571 | if (bh == NULL) { |
570 | printk(KERN_ERR "ide-tape: bh == NULL in " | 572 | printk(KERN_ERR "ide-tape: bh == NULL in %s\n", |
571 | "idetape_output_buffers\n"); | 573 | __func__); |
572 | return; | 574 | return; |
573 | } | 575 | } |
574 | count = min((unsigned int)pc->b_count, (unsigned int)bcount); | 576 | count = min((unsigned int)pc->b_count, (unsigned int)bcount); |
@@ -577,7 +579,8 @@ static void idetape_output_buffers (ide_drive_t *drive, idetape_pc_t *pc, unsign | |||
577 | pc->b_data += count; | 579 | pc->b_data += count; |
578 | pc->b_count -= count; | 580 | pc->b_count -= count; |
579 | if (!pc->b_count) { | 581 | if (!pc->b_count) { |
580 | pc->bh = bh = bh->b_reqnext; | 582 | bh = bh->b_reqnext; |
583 | pc->bh = bh; | ||
581 | if (bh) { | 584 | if (bh) { |
582 | pc->b_data = bh->b_data; | 585 | pc->b_data = bh->b_data; |
583 | pc->b_count = atomic_read(&bh->b_count); | 586 | pc->b_count = atomic_read(&bh->b_count); |
@@ -586,7 +589,7 @@ static void idetape_output_buffers (ide_drive_t *drive, idetape_pc_t *pc, unsign | |||
586 | } | 589 | } |
587 | } | 590 | } |
588 | 591 | ||
589 | static void idetape_update_buffers (idetape_pc_t *pc) | 592 | static void idetape_update_buffers(idetape_pc_t *pc) |
590 | { | 593 | { |
591 | struct idetape_bh *bh = pc->bh; | 594 | struct idetape_bh *bh = pc->bh; |
592 | int count; | 595 | int count; |
@@ -596,8 +599,8 @@ static void idetape_update_buffers (idetape_pc_t *pc) | |||
596 | return; | 599 | return; |
597 | while (bcount) { | 600 | while (bcount) { |
598 | if (bh == NULL) { | 601 | if (bh == NULL) { |
599 | printk(KERN_ERR "ide-tape: bh == NULL in " | 602 | printk(KERN_ERR "ide-tape: bh == NULL in %s\n", |
600 | "idetape_update_buffers\n"); | 603 | __func__); |
601 | return; | 604 | return; |
602 | } | 605 | } |
603 | count = min((unsigned int)bh->b_size, (unsigned int)bcount); | 606 | count = min((unsigned int)bh->b_size, (unsigned int)bcount); |
@@ -615,14 +618,14 @@ static void idetape_update_buffers (idetape_pc_t *pc) | |||
615 | * driver. A storage space for a maximum of IDETAPE_PC_STACK packet | 618 | * driver. A storage space for a maximum of IDETAPE_PC_STACK packet |
616 | * commands is allocated at initialization time. | 619 | * commands is allocated at initialization time. |
617 | */ | 620 | */ |
618 | static idetape_pc_t *idetape_next_pc_storage (ide_drive_t *drive) | 621 | static idetape_pc_t *idetape_next_pc_storage(ide_drive_t *drive) |
619 | { | 622 | { |
620 | idetape_tape_t *tape = drive->driver_data; | 623 | idetape_tape_t *tape = drive->driver_data; |
621 | 624 | ||
622 | debug_log(DBG_PCRQ_STACK, "pc_stack_index=%d\n", tape->pc_stack_index); | 625 | debug_log(DBG_PCRQ_STACK, "pc_stack_index=%d\n", tape->pc_stack_index); |
623 | 626 | ||
624 | if (tape->pc_stack_index == IDETAPE_PC_STACK) | 627 | if (tape->pc_stack_index == IDETAPE_PC_STACK) |
625 | tape->pc_stack_index=0; | 628 | tape->pc_stack_index = 0; |
626 | return (&tape->pc_stack[tape->pc_stack_index++]); | 629 | return (&tape->pc_stack[tape->pc_stack_index++]); |
627 | } | 630 | } |
628 | 631 | ||
@@ -631,26 +634,26 @@ static idetape_pc_t *idetape_next_pc_storage (ide_drive_t *drive) | |||
631 | * Since we queue packet commands in the request queue, we need to | 634 | * Since we queue packet commands in the request queue, we need to |
632 | * allocate a request, along with the allocation of a packet command. | 635 | * allocate a request, along with the allocation of a packet command. |
633 | */ | 636 | */ |
634 | 637 | ||
635 | /************************************************************** | 638 | /************************************************************** |
636 | * * | 639 | * * |
637 | * This should get fixed to use kmalloc(.., GFP_ATOMIC) * | 640 | * This should get fixed to use kmalloc(.., GFP_ATOMIC) * |
638 | * followed later on by kfree(). -ml * | 641 | * followed later on by kfree(). -ml * |
639 | * * | 642 | * * |
640 | **************************************************************/ | 643 | **************************************************************/ |
641 | 644 | ||
642 | static struct request *idetape_next_rq_storage (ide_drive_t *drive) | 645 | static struct request *idetape_next_rq_storage(ide_drive_t *drive) |
643 | { | 646 | { |
644 | idetape_tape_t *tape = drive->driver_data; | 647 | idetape_tape_t *tape = drive->driver_data; |
645 | 648 | ||
646 | debug_log(DBG_PCRQ_STACK, "rq_stack_index=%d\n", tape->rq_stack_index); | 649 | debug_log(DBG_PCRQ_STACK, "rq_stack_index=%d\n", tape->rq_stack_index); |
647 | 650 | ||
648 | if (tape->rq_stack_index == IDETAPE_PC_STACK) | 651 | if (tape->rq_stack_index == IDETAPE_PC_STACK) |
649 | tape->rq_stack_index=0; | 652 | tape->rq_stack_index = 0; |
650 | return (&tape->rq_stack[tape->rq_stack_index++]); | 653 | return (&tape->rq_stack[tape->rq_stack_index++]); |
651 | } | 654 | } |
652 | 655 | ||
653 | static void idetape_init_pc (idetape_pc_t *pc) | 656 | static void idetape_init_pc(idetape_pc_t *pc) |
654 | { | 657 | { |
655 | memset(pc->c, 0, 12); | 658 | memset(pc->c, 0, 12); |
656 | pc->retries = 0; | 659 | pc->retries = 0; |
@@ -746,7 +749,7 @@ static void idetape_activate_next_stage(ide_drive_t *drive) | |||
746 | } | 749 | } |
747 | 750 | ||
748 | /* Free a stage along with its related buffers completely. */ | 751 | /* Free a stage along with its related buffers completely. */ |
749 | static void __idetape_kfree_stage (idetape_stage_t *stage) | 752 | static void __idetape_kfree_stage(idetape_stage_t *stage) |
750 | { | 753 | { |
751 | struct idetape_bh *prev_bh, *bh = stage->bh; | 754 | struct idetape_bh *prev_bh, *bh = stage->bh; |
752 | int size; | 755 | int size; |
@@ -767,7 +770,7 @@ static void __idetape_kfree_stage (idetape_stage_t *stage) | |||
767 | kfree(stage); | 770 | kfree(stage); |
768 | } | 771 | } |
769 | 772 | ||
770 | static void idetape_kfree_stage (idetape_tape_t *tape, idetape_stage_t *stage) | 773 | static void idetape_kfree_stage(idetape_tape_t *tape, idetape_stage_t *stage) |
771 | { | 774 | { |
772 | __idetape_kfree_stage(stage); | 775 | __idetape_kfree_stage(stage); |
773 | } | 776 | } |
@@ -776,7 +779,7 @@ static void idetape_kfree_stage (idetape_tape_t *tape, idetape_stage_t *stage) | |||
776 | * Remove tape->first_stage from the pipeline. The caller should avoid race | 779 | * Remove tape->first_stage from the pipeline. The caller should avoid race |
777 | * conditions. | 780 | * conditions. |
778 | */ | 781 | */ |
779 | static void idetape_remove_stage_head (ide_drive_t *drive) | 782 | static void idetape_remove_stage_head(ide_drive_t *drive) |
780 | { | 783 | { |
781 | idetape_tape_t *tape = drive->driver_data; | 784 | idetape_tape_t *tape = drive->driver_data; |
782 | idetape_stage_t *stage; | 785 | idetape_stage_t *stage; |
@@ -799,9 +802,11 @@ static void idetape_remove_stage_head (ide_drive_t *drive) | |||
799 | if (tape->first_stage == NULL) { | 802 | if (tape->first_stage == NULL) { |
800 | tape->last_stage = NULL; | 803 | tape->last_stage = NULL; |
801 | if (tape->next_stage != NULL) | 804 | if (tape->next_stage != NULL) |
802 | printk(KERN_ERR "ide-tape: bug: tape->next_stage != NULL\n"); | 805 | printk(KERN_ERR "ide-tape: bug: tape->next_stage !=" |
806 | " NULL\n"); | ||
803 | if (tape->nr_stages) | 807 | if (tape->nr_stages) |
804 | printk(KERN_ERR "ide-tape: bug: nr_stages should be 0 now\n"); | 808 | printk(KERN_ERR "ide-tape: bug: nr_stages should be 0 " |
809 | "now\n"); | ||
805 | } | 810 | } |
806 | } | 811 | } |
807 | 812 | ||
@@ -847,9 +852,9 @@ static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects) | |||
847 | debug_log(DBG_PROCS, "Enter %s\n", __func__); | 852 | debug_log(DBG_PROCS, "Enter %s\n", __func__); |
848 | 853 | ||
849 | switch (uptodate) { | 854 | switch (uptodate) { |
850 | case 0: error = IDETAPE_ERROR_GENERAL; break; | 855 | case 0: error = IDETAPE_ERROR_GENERAL; break; |
851 | case 1: error = 0; break; | 856 | case 1: error = 0; break; |
852 | default: error = uptodate; | 857 | default: error = uptodate; |
853 | } | 858 | } |
854 | rq->errors = error; | 859 | rq->errors = error; |
855 | if (error) | 860 | if (error) |
@@ -873,7 +878,8 @@ static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects) | |||
873 | if (error) { | 878 | if (error) { |
874 | set_bit(IDETAPE_PIPELINE_ERROR, &tape->flags); | 879 | set_bit(IDETAPE_PIPELINE_ERROR, &tape->flags); |
875 | if (error == IDETAPE_ERROR_EOD) | 880 | if (error == IDETAPE_ERROR_EOD) |
876 | idetape_abort_pipeline(drive, active_stage); | 881 | idetape_abort_pipeline(drive, |
882 | active_stage); | ||
877 | } | 883 | } |
878 | } else if (rq->cmd[0] & REQ_IDETAPE_READ) { | 884 | } else if (rq->cmd[0] & REQ_IDETAPE_READ) { |
879 | if (error == IDETAPE_ERROR_EOD) { | 885 | if (error == IDETAPE_ERROR_EOD) { |
@@ -906,9 +912,6 @@ static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects) | |||
906 | } | 912 | } |
907 | } | 913 | } |
908 | ide_end_drive_cmd(drive, 0, 0); | 914 | ide_end_drive_cmd(drive, 0, 0); |
909 | // blkdev_dequeue_request(rq); | ||
910 | // drive->rq = NULL; | ||
911 | // end_that_request_last(rq); | ||
912 | 915 | ||
913 | if (remove_stage) | 916 | if (remove_stage) |
914 | idetape_remove_stage_head(drive); | 917 | idetape_remove_stage_head(drive); |
@@ -918,7 +921,7 @@ static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects) | |||
918 | return 0; | 921 | return 0; |
919 | } | 922 | } |
920 | 923 | ||
921 | static ide_startstop_t idetape_request_sense_callback (ide_drive_t *drive) | 924 | static ide_startstop_t idetape_request_sense_callback(ide_drive_t *drive) |
922 | { | 925 | { |
923 | idetape_tape_t *tape = drive->driver_data; | 926 | idetape_tape_t *tape = drive->driver_data; |
924 | 927 | ||
@@ -928,15 +931,16 @@ static ide_startstop_t idetape_request_sense_callback (ide_drive_t *drive) | |||
928 | idetape_analyze_error(drive, tape->pc->buffer); | 931 | idetape_analyze_error(drive, tape->pc->buffer); |
929 | idetape_end_request(drive, 1, 0); | 932 | idetape_end_request(drive, 1, 0); |
930 | } else { | 933 | } else { |
931 | printk(KERN_ERR "ide-tape: Error in REQUEST SENSE itself - Aborting request!\n"); | 934 | printk(KERN_ERR "ide-tape: Error in REQUEST SENSE itself - " |
935 | "Aborting request!\n"); | ||
932 | idetape_end_request(drive, 0, 0); | 936 | idetape_end_request(drive, 0, 0); |
933 | } | 937 | } |
934 | return ide_stopped; | 938 | return ide_stopped; |
935 | } | 939 | } |
936 | 940 | ||
937 | static void idetape_create_request_sense_cmd (idetape_pc_t *pc) | 941 | static void idetape_create_request_sense_cmd(idetape_pc_t *pc) |
938 | { | 942 | { |
939 | idetape_init_pc(pc); | 943 | idetape_init_pc(pc); |
940 | pc->c[0] = REQUEST_SENSE; | 944 | pc->c[0] = REQUEST_SENSE; |
941 | pc->c[4] = 20; | 945 | pc->c[4] = 20; |
942 | pc->request_transfer = 20; | 946 | pc->request_transfer = 20; |
@@ -965,7 +969,8 @@ static void idetape_init_rq(struct request *rq, u8 cmd) | |||
965 | * handling functions should queue request to the lower level part and wait for | 969 | * handling functions should queue request to the lower level part and wait for |
966 | * their completion using idetape_queue_pc_tail or idetape_queue_rw_tail. | 970 | * their completion using idetape_queue_pc_tail or idetape_queue_rw_tail. |
967 | */ | 971 | */ |
968 | static void idetape_queue_pc_head (ide_drive_t *drive, idetape_pc_t *pc,struct request *rq) | 972 | static void idetape_queue_pc_head(ide_drive_t *drive, idetape_pc_t *pc, |
973 | struct request *rq) | ||
969 | { | 974 | { |
970 | struct ide_tape_obj *tape = drive->driver_data; | 975 | struct ide_tape_obj *tape = drive->driver_data; |
971 | 976 | ||
@@ -999,7 +1004,7 @@ static ide_startstop_t idetape_retry_pc (ide_drive_t *drive) | |||
999 | * Postpone the current request so that ide.c will be able to service requests | 1004 | * Postpone the current request so that ide.c will be able to service requests |
1000 | * from another device on the same hwgroup while we are polling for DSC. | 1005 | * from another device on the same hwgroup while we are polling for DSC. |
1001 | */ | 1006 | */ |
1002 | static void idetape_postpone_request (ide_drive_t *drive) | 1007 | static void idetape_postpone_request(ide_drive_t *drive) |
1003 | { | 1008 | { |
1004 | idetape_tape_t *tape = drive->driver_data; | 1009 | idetape_tape_t *tape = drive->driver_data; |
1005 | 1010 | ||
@@ -1027,7 +1032,7 @@ static ide_startstop_t idetape_pc_intr(ide_drive_t *drive) | |||
1027 | idetape_io_buf *iobuf; | 1032 | idetape_io_buf *iobuf; |
1028 | unsigned int temp; | 1033 | unsigned int temp; |
1029 | #if SIMULATE_ERRORS | 1034 | #if SIMULATE_ERRORS |
1030 | static int error_sim_count = 0; | 1035 | static int error_sim_count; |
1031 | #endif | 1036 | #endif |
1032 | u16 bcount; | 1037 | u16 bcount; |
1033 | u8 stat, ireason; | 1038 | u8 stat, ireason; |
@@ -1228,8 +1233,9 @@ static ide_startstop_t idetape_transfer_pc(ide_drive_t *drive) | |||
1228 | ide_startstop_t startstop; | 1233 | ide_startstop_t startstop; |
1229 | u8 ireason; | 1234 | u8 ireason; |
1230 | 1235 | ||
1231 | if (ide_wait_stat(&startstop,drive,DRQ_STAT,BUSY_STAT,WAIT_READY)) { | 1236 | if (ide_wait_stat(&startstop, drive, DRQ_STAT, BUSY_STAT, WAIT_READY)) { |
1232 | printk(KERN_ERR "ide-tape: Strange, packet command initiated yet DRQ isn't asserted\n"); | 1237 | printk(KERN_ERR "ide-tape: Strange, packet command initiated " |
1238 | "yet DRQ isn't asserted\n"); | ||
1233 | return startstop; | 1239 | return startstop; |
1234 | } | 1240 | } |
1235 | ireason = hwif->INB(IDE_IREASON_REG); | 1241 | ireason = hwif->INB(IDE_IREASON_REG); |
@@ -1336,7 +1342,7 @@ static ide_startstop_t idetape_issue_pc(ide_drive_t *drive, idetape_pc_t *pc) | |||
1336 | } | 1342 | } |
1337 | } | 1343 | } |
1338 | 1344 | ||
1339 | static ide_startstop_t idetape_pc_callback (ide_drive_t *drive) | 1345 | static ide_startstop_t idetape_pc_callback(ide_drive_t *drive) |
1340 | { | 1346 | { |
1341 | idetape_tape_t *tape = drive->driver_data; | 1347 | idetape_tape_t *tape = drive->driver_data; |
1342 | 1348 | ||
@@ -1347,7 +1353,7 @@ static ide_startstop_t idetape_pc_callback (ide_drive_t *drive) | |||
1347 | } | 1353 | } |
1348 | 1354 | ||
1349 | /* A mode sense command is used to "sense" tape parameters. */ | 1355 | /* A mode sense command is used to "sense" tape parameters. */ |
1350 | static void idetape_create_mode_sense_cmd (idetape_pc_t *pc, u8 page_code) | 1356 | static void idetape_create_mode_sense_cmd(idetape_pc_t *pc, u8 page_code) |
1351 | { | 1357 | { |
1352 | idetape_init_pc(pc); | 1358 | idetape_init_pc(pc); |
1353 | pc->c[0] = MODE_SENSE; | 1359 | pc->c[0] = MODE_SENSE; |
@@ -1378,39 +1384,56 @@ static void idetape_calculate_speeds(ide_drive_t *drive) | |||
1378 | { | 1384 | { |
1379 | idetape_tape_t *tape = drive->driver_data; | 1385 | idetape_tape_t *tape = drive->driver_data; |
1380 | 1386 | ||
1381 | if (time_after(jiffies, tape->controlled_pipeline_head_time + 120 * HZ)) { | 1387 | if (time_after(jiffies, |
1382 | tape->controlled_previous_pipeline_head = tape->controlled_last_pipeline_head; | 1388 | tape->controlled_pipeline_head_time + 120 * HZ)) { |
1383 | tape->controlled_previous_head_time = tape->controlled_pipeline_head_time; | 1389 | tape->controlled_previous_pipeline_head = |
1390 | tape->controlled_last_pipeline_head; | ||
1391 | tape->controlled_previous_head_time = | ||
1392 | tape->controlled_pipeline_head_time; | ||
1384 | tape->controlled_last_pipeline_head = tape->pipeline_head; | 1393 | tape->controlled_last_pipeline_head = tape->pipeline_head; |
1385 | tape->controlled_pipeline_head_time = jiffies; | 1394 | tape->controlled_pipeline_head_time = jiffies; |
1386 | } | 1395 | } |
1387 | if (time_after(jiffies, tape->controlled_pipeline_head_time + 60 * HZ)) | 1396 | if (time_after(jiffies, tape->controlled_pipeline_head_time + 60 * HZ)) |
1388 | tape->controlled_pipeline_head_speed = (tape->pipeline_head - tape->controlled_last_pipeline_head) * 32 * HZ / (jiffies - tape->controlled_pipeline_head_time); | 1397 | tape->controlled_pipeline_head_speed = (tape->pipeline_head - |
1398 | tape->controlled_last_pipeline_head) * 32 * HZ / | ||
1399 | (jiffies - tape->controlled_pipeline_head_time); | ||
1389 | else if (time_after(jiffies, tape->controlled_previous_head_time)) | 1400 | else if (time_after(jiffies, tape->controlled_previous_head_time)) |
1390 | tape->controlled_pipeline_head_speed = (tape->pipeline_head - tape->controlled_previous_pipeline_head) * 32 * HZ / (jiffies - tape->controlled_previous_head_time); | 1401 | tape->controlled_pipeline_head_speed = (tape->pipeline_head - |
1402 | tape->controlled_previous_pipeline_head) * 32 * | ||
1403 | HZ / (jiffies - tape->controlled_previous_head_time); | ||
1391 | 1404 | ||
1392 | if (tape->nr_pending_stages < tape->max_stages /*- 1 */) { | 1405 | if (tape->nr_pending_stages < tape->max_stages/*- 1 */) { |
1393 | /* -1 for read mode error recovery */ | 1406 | /* -1 for read mode error recovery */ |
1394 | if (time_after(jiffies, tape->uncontrolled_previous_head_time + 10 * HZ)) { | 1407 | if (time_after(jiffies, tape->uncontrolled_previous_head_time + |
1408 | 10 * HZ)) { | ||
1395 | tape->uncontrolled_pipeline_head_time = jiffies; | 1409 | tape->uncontrolled_pipeline_head_time = jiffies; |
1396 | tape->uncontrolled_pipeline_head_speed = (tape->pipeline_head - tape->uncontrolled_previous_pipeline_head) * 32 * HZ / (jiffies - tape->uncontrolled_previous_head_time); | 1410 | tape->uncontrolled_pipeline_head_speed = |
1411 | (tape->pipeline_head - | ||
1412 | tape->uncontrolled_previous_pipeline_head) * | ||
1413 | 32 * HZ / (jiffies - | ||
1414 | tape->uncontrolled_previous_head_time); | ||
1397 | } | 1415 | } |
1398 | } else { | 1416 | } else { |
1399 | tape->uncontrolled_previous_head_time = jiffies; | 1417 | tape->uncontrolled_previous_head_time = jiffies; |
1400 | tape->uncontrolled_previous_pipeline_head = tape->pipeline_head; | 1418 | tape->uncontrolled_previous_pipeline_head = tape->pipeline_head; |
1401 | if (time_after(jiffies, tape->uncontrolled_pipeline_head_time + 30 * HZ)) { | 1419 | if (time_after(jiffies, tape->uncontrolled_pipeline_head_time + |
1420 | 30 * HZ)) | ||
1402 | tape->uncontrolled_pipeline_head_time = jiffies; | 1421 | tape->uncontrolled_pipeline_head_time = jiffies; |
1403 | } | 1422 | |
1404 | } | 1423 | } |
1405 | tape->pipeline_head_speed = max(tape->uncontrolled_pipeline_head_speed, tape->controlled_pipeline_head_speed); | 1424 | tape->pipeline_head_speed = max(tape->uncontrolled_pipeline_head_speed, |
1425 | tape->controlled_pipeline_head_speed); | ||
1406 | 1426 | ||
1407 | if (tape->speed_control == 1) { | 1427 | if (tape->speed_control == 1) { |
1408 | if (tape->nr_pending_stages >= tape->max_stages / 2) | 1428 | if (tape->nr_pending_stages >= tape->max_stages / 2) |
1409 | tape->max_insert_speed = tape->pipeline_head_speed + | 1429 | tape->max_insert_speed = tape->pipeline_head_speed + |
1410 | (1100 - tape->pipeline_head_speed) * 2 * (tape->nr_pending_stages - tape->max_stages / 2) / tape->max_stages; | 1430 | (1100 - tape->pipeline_head_speed) * 2 * |
1431 | (tape->nr_pending_stages - tape->max_stages / 2) | ||
1432 | / tape->max_stages; | ||
1411 | else | 1433 | else |
1412 | tape->max_insert_speed = 500 + | 1434 | tape->max_insert_speed = 500 + |
1413 | (tape->pipeline_head_speed - 500) * 2 * tape->nr_pending_stages / tape->max_stages; | 1435 | (tape->pipeline_head_speed - 500) * 2 * |
1436 | tape->nr_pending_stages / tape->max_stages; | ||
1414 | 1437 | ||
1415 | if (tape->nr_pending_stages >= tape->max_stages * 99 / 100) | 1438 | if (tape->nr_pending_stages >= tape->max_stages * 99 / 100) |
1416 | tape->max_insert_speed = 5000; | 1439 | tape->max_insert_speed = 5000; |
@@ -1420,7 +1443,7 @@ static void idetape_calculate_speeds(ide_drive_t *drive) | |||
1420 | tape->max_insert_speed = max(tape->max_insert_speed, 500); | 1443 | tape->max_insert_speed = max(tape->max_insert_speed, 500); |
1421 | } | 1444 | } |
1422 | 1445 | ||
1423 | static ide_startstop_t idetape_media_access_finished (ide_drive_t *drive) | 1446 | static ide_startstop_t idetape_media_access_finished(ide_drive_t *drive) |
1424 | { | 1447 | { |
1425 | idetape_tape_t *tape = drive->driver_data; | 1448 | idetape_tape_t *tape = drive->driver_data; |
1426 | idetape_pc_t *pc = tape->pc; | 1449 | idetape_pc_t *pc = tape->pc; |
@@ -1447,7 +1470,7 @@ static ide_startstop_t idetape_media_access_finished (ide_drive_t *drive) | |||
1447 | return pc->callback(drive); | 1470 | return pc->callback(drive); |
1448 | } | 1471 | } |
1449 | 1472 | ||
1450 | static ide_startstop_t idetape_rw_callback (ide_drive_t *drive) | 1473 | static ide_startstop_t idetape_rw_callback(ide_drive_t *drive) |
1451 | { | 1474 | { |
1452 | idetape_tape_t *tape = drive->driver_data; | 1475 | idetape_tape_t *tape = drive->driver_data; |
1453 | struct request *rq = HWGROUP(drive)->rq; | 1476 | struct request *rq = HWGROUP(drive)->rq; |
@@ -1463,9 +1486,11 @@ static ide_startstop_t idetape_rw_callback (ide_drive_t *drive) | |||
1463 | tape->insert_size = 0; | 1486 | tape->insert_size = 0; |
1464 | } | 1487 | } |
1465 | if (time_after(jiffies, tape->insert_time)) | 1488 | if (time_after(jiffies, tape->insert_time)) |
1466 | tape->insert_speed = tape->insert_size / 1024 * HZ / (jiffies - tape->insert_time); | 1489 | tape->insert_speed = tape->insert_size / 1024 * HZ / |
1490 | (jiffies - tape->insert_time); | ||
1467 | if (time_after_eq(jiffies, tape->avg_time + HZ)) { | 1491 | if (time_after_eq(jiffies, tape->avg_time + HZ)) { |
1468 | tape->avg_speed = tape->avg_size * HZ / (jiffies - tape->avg_time) / 1024; | 1492 | tape->avg_speed = tape->avg_size * HZ / |
1493 | (jiffies - tape->avg_time) / 1024; | ||
1469 | tape->avg_size = 0; | 1494 | tape->avg_size = 0; |
1470 | tape->avg_time = jiffies; | 1495 | tape->avg_time = jiffies; |
1471 | } | 1496 | } |
@@ -1481,7 +1506,8 @@ static ide_startstop_t idetape_rw_callback (ide_drive_t *drive) | |||
1481 | return ide_stopped; | 1506 | return ide_stopped; |
1482 | } | 1507 | } |
1483 | 1508 | ||
1484 | static void idetape_create_read_cmd(idetape_tape_t *tape, idetape_pc_t *pc, unsigned int length, struct idetape_bh *bh) | 1509 | static void idetape_create_read_cmd(idetape_tape_t *tape, idetape_pc_t *pc, |
1510 | unsigned int length, struct idetape_bh *bh) | ||
1485 | { | 1511 | { |
1486 | idetape_init_pc(pc); | 1512 | idetape_init_pc(pc); |
1487 | pc->c[0] = READ_6; | 1513 | pc->c[0] = READ_6; |
@@ -1520,7 +1546,8 @@ static void idetape_create_read_buffer_cmd(idetape_tape_t *tape, | |||
1520 | pc->buffer_size = size; | 1546 | pc->buffer_size = size; |
1521 | } | 1547 | } |
1522 | 1548 | ||
1523 | static void idetape_create_write_cmd(idetape_tape_t *tape, idetape_pc_t *pc, unsigned int length, struct idetape_bh *bh) | 1549 | static void idetape_create_write_cmd(idetape_tape_t *tape, idetape_pc_t *pc, |
1550 | unsigned int length, struct idetape_bh *bh) | ||
1524 | { | 1551 | { |
1525 | idetape_init_pc(pc); | 1552 | idetape_init_pc(pc); |
1526 | pc->c[0] = WRITE_6; | 1553 | pc->c[0] = WRITE_6; |
@@ -1559,10 +1586,9 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
1559 | } | 1586 | } |
1560 | 1587 | ||
1561 | /* Retry a failed packet command */ | 1588 | /* Retry a failed packet command */ |
1562 | if (tape->failed_pc != NULL && | 1589 | if (tape->failed_pc && tape->pc->c[0] == REQUEST_SENSE) |
1563 | tape->pc->c[0] == REQUEST_SENSE) { | ||
1564 | return idetape_issue_pc(drive, tape->failed_pc); | 1590 | return idetape_issue_pc(drive, tape->failed_pc); |
1565 | } | 1591 | |
1566 | if (postponed_rq != NULL) | 1592 | if (postponed_rq != NULL) |
1567 | if (rq != postponed_rq) { | 1593 | if (rq != postponed_rq) { |
1568 | printk(KERN_ERR "ide-tape: ide-tape.c bug - " | 1594 | printk(KERN_ERR "ide-tape: ide-tape.c bug - " |
@@ -1588,7 +1614,8 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
1588 | } | 1614 | } |
1589 | 1615 | ||
1590 | if (time_after(jiffies, tape->insert_time)) | 1616 | if (time_after(jiffies, tape->insert_time)) |
1591 | tape->insert_speed = tape->insert_size / 1024 * HZ / (jiffies - tape->insert_time); | 1617 | tape->insert_speed = tape->insert_size / 1024 * HZ / |
1618 | (jiffies - tape->insert_time); | ||
1592 | idetape_calculate_speeds(drive); | 1619 | idetape_calculate_speeds(drive); |
1593 | if (!test_and_clear_bit(IDETAPE_IGNORE_DSC, &tape->flags) && | 1620 | if (!test_and_clear_bit(IDETAPE_IGNORE_DSC, &tape->flags) && |
1594 | (stat & SEEK_STAT) == 0) { | 1621 | (stat & SEEK_STAT) == 0) { |
@@ -1605,7 +1632,9 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
1605 | } else { | 1632 | } else { |
1606 | return ide_do_reset(drive); | 1633 | return ide_do_reset(drive); |
1607 | } | 1634 | } |
1608 | } else if (time_after(jiffies, tape->dsc_polling_start + IDETAPE_DSC_MA_THRESHOLD)) | 1635 | } else if (time_after(jiffies, |
1636 | tape->dsc_polling_start + | ||
1637 | IDETAPE_DSC_MA_THRESHOLD)) | ||
1609 | tape->dsc_poll_freq = IDETAPE_DSC_MA_SLOW; | 1638 | tape->dsc_poll_freq = IDETAPE_DSC_MA_SLOW; |
1610 | idetape_postpone_request(drive); | 1639 | idetape_postpone_request(drive); |
1611 | return ide_stopped; | 1640 | return ide_stopped; |
@@ -1614,14 +1643,16 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
1614 | tape->buffer_head++; | 1643 | tape->buffer_head++; |
1615 | tape->postpone_cnt = 0; | 1644 | tape->postpone_cnt = 0; |
1616 | pc = idetape_next_pc_storage(drive); | 1645 | pc = idetape_next_pc_storage(drive); |
1617 | idetape_create_read_cmd(tape, pc, rq->current_nr_sectors, (struct idetape_bh *)rq->special); | 1646 | idetape_create_read_cmd(tape, pc, rq->current_nr_sectors, |
1647 | (struct idetape_bh *)rq->special); | ||
1618 | goto out; | 1648 | goto out; |
1619 | } | 1649 | } |
1620 | if (rq->cmd[0] & REQ_IDETAPE_WRITE) { | 1650 | if (rq->cmd[0] & REQ_IDETAPE_WRITE) { |
1621 | tape->buffer_head++; | 1651 | tape->buffer_head++; |
1622 | tape->postpone_cnt = 0; | 1652 | tape->postpone_cnt = 0; |
1623 | pc = idetape_next_pc_storage(drive); | 1653 | pc = idetape_next_pc_storage(drive); |
1624 | idetape_create_write_cmd(tape, pc, rq->current_nr_sectors, (struct idetape_bh *)rq->special); | 1654 | idetape_create_write_cmd(tape, pc, rq->current_nr_sectors, |
1655 | (struct idetape_bh *)rq->special); | ||
1625 | goto out; | 1656 | goto out; |
1626 | } | 1657 | } |
1627 | if (rq->cmd[0] & REQ_IDETAPE_READ_BUFFER) { | 1658 | if (rq->cmd[0] & REQ_IDETAPE_READ_BUFFER) { |
@@ -1647,7 +1678,7 @@ out: | |||
1647 | } | 1678 | } |
1648 | 1679 | ||
1649 | /* Pipeline related functions */ | 1680 | /* Pipeline related functions */ |
1650 | static inline int idetape_pipeline_active (idetape_tape_t *tape) | 1681 | static inline int idetape_pipeline_active(idetape_tape_t *tape) |
1651 | { | 1682 | { |
1652 | int rc1, rc2; | 1683 | int rc1, rc2; |
1653 | 1684 | ||
@@ -1668,22 +1699,26 @@ static inline int idetape_pipeline_active (idetape_tape_t *tape) | |||
1668 | * Pipeline stages are optional and are used to increase performance. If we | 1699 | * Pipeline stages are optional and are used to increase performance. If we |
1669 | * can't allocate them, we'll manage without them. | 1700 | * can't allocate them, we'll manage without them. |
1670 | */ | 1701 | */ |
1671 | static idetape_stage_t *__idetape_kmalloc_stage (idetape_tape_t *tape, int full, int clear) | 1702 | static idetape_stage_t *__idetape_kmalloc_stage(idetape_tape_t *tape, int full, |
1703 | int clear) | ||
1672 | { | 1704 | { |
1673 | idetape_stage_t *stage; | 1705 | idetape_stage_t *stage; |
1674 | struct idetape_bh *prev_bh, *bh; | 1706 | struct idetape_bh *prev_bh, *bh; |
1675 | int pages = tape->pages_per_stage; | 1707 | int pages = tape->pages_per_stage; |
1676 | char *b_data = NULL; | 1708 | char *b_data = NULL; |
1677 | 1709 | ||
1678 | if ((stage = kmalloc(sizeof (idetape_stage_t),GFP_KERNEL)) == NULL) | 1710 | stage = kmalloc(sizeof(idetape_stage_t), GFP_KERNEL); |
1711 | if (!stage) | ||
1679 | return NULL; | 1712 | return NULL; |
1680 | stage->next = NULL; | 1713 | stage->next = NULL; |
1681 | 1714 | ||
1682 | bh = stage->bh = kmalloc(sizeof(struct idetape_bh), GFP_KERNEL); | 1715 | stage->bh = kmalloc(sizeof(struct idetape_bh), GFP_KERNEL); |
1716 | bh = stage->bh; | ||
1683 | if (bh == NULL) | 1717 | if (bh == NULL) |
1684 | goto abort; | 1718 | goto abort; |
1685 | bh->b_reqnext = NULL; | 1719 | bh->b_reqnext = NULL; |
1686 | if ((bh->b_data = (char *) __get_free_page (GFP_KERNEL)) == NULL) | 1720 | bh->b_data = (char *) __get_free_page(GFP_KERNEL); |
1721 | if (!bh->b_data) | ||
1687 | goto abort; | 1722 | goto abort; |
1688 | if (clear) | 1723 | if (clear) |
1689 | memset(bh->b_data, 0, PAGE_SIZE); | 1724 | memset(bh->b_data, 0, PAGE_SIZE); |
@@ -1691,7 +1726,8 @@ static idetape_stage_t *__idetape_kmalloc_stage (idetape_tape_t *tape, int full, | |||
1691 | atomic_set(&bh->b_count, full ? bh->b_size : 0); | 1726 | atomic_set(&bh->b_count, full ? bh->b_size : 0); |
1692 | 1727 | ||
1693 | while (--pages) { | 1728 | while (--pages) { |
1694 | if ((b_data = (char *) __get_free_page (GFP_KERNEL)) == NULL) | 1729 | b_data = (char *) __get_free_page(GFP_KERNEL); |
1730 | if (!b_data) | ||
1695 | goto abort; | 1731 | goto abort; |
1696 | if (clear) | 1732 | if (clear) |
1697 | memset(b_data, 0, PAGE_SIZE); | 1733 | memset(b_data, 0, PAGE_SIZE); |
@@ -1709,7 +1745,8 @@ static idetape_stage_t *__idetape_kmalloc_stage (idetape_tape_t *tape, int full, | |||
1709 | continue; | 1745 | continue; |
1710 | } | 1746 | } |
1711 | prev_bh = bh; | 1747 | prev_bh = bh; |
1712 | if ((bh = kmalloc(sizeof(struct idetape_bh), GFP_KERNEL)) == NULL) { | 1748 | bh = kmalloc(sizeof(struct idetape_bh), GFP_KERNEL); |
1749 | if (!bh) { | ||
1713 | free_page((unsigned long) b_data); | 1750 | free_page((unsigned long) b_data); |
1714 | goto abort; | 1751 | goto abort; |
1715 | } | 1752 | } |
@@ -1728,7 +1765,7 @@ abort: | |||
1728 | return NULL; | 1765 | return NULL; |
1729 | } | 1766 | } |
1730 | 1767 | ||
1731 | static idetape_stage_t *idetape_kmalloc_stage (idetape_tape_t *tape) | 1768 | static idetape_stage_t *idetape_kmalloc_stage(idetape_tape_t *tape) |
1732 | { | 1769 | { |
1733 | idetape_stage_t *cache_stage = tape->cache_stage; | 1770 | idetape_stage_t *cache_stage = tape->cache_stage; |
1734 | 1771 | ||
@@ -1743,7 +1780,8 @@ static idetape_stage_t *idetape_kmalloc_stage (idetape_tape_t *tape) | |||
1743 | return __idetape_kmalloc_stage(tape, 0, 0); | 1780 | return __idetape_kmalloc_stage(tape, 0, 0); |
1744 | } | 1781 | } |
1745 | 1782 | ||
1746 | static int idetape_copy_stage_from_user (idetape_tape_t *tape, idetape_stage_t *stage, const char __user *buf, int n) | 1783 | static int idetape_copy_stage_from_user(idetape_tape_t *tape, |
1784 | idetape_stage_t *stage, const char __user *buf, int n) | ||
1747 | { | 1785 | { |
1748 | struct idetape_bh *bh = tape->bh; | 1786 | struct idetape_bh *bh = tape->bh; |
1749 | int count; | 1787 | int count; |
@@ -1751,12 +1789,15 @@ static int idetape_copy_stage_from_user (idetape_tape_t *tape, idetape_stage_t * | |||
1751 | 1789 | ||
1752 | while (n) { | 1790 | while (n) { |
1753 | if (bh == NULL) { | 1791 | if (bh == NULL) { |
1754 | printk(KERN_ERR "ide-tape: bh == NULL in " | 1792 | printk(KERN_ERR "ide-tape: bh == NULL in %s\n", |
1755 | "idetape_copy_stage_from_user\n"); | 1793 | __func__); |
1756 | return 1; | 1794 | return 1; |
1757 | } | 1795 | } |
1758 | count = min((unsigned int)(bh->b_size - atomic_read(&bh->b_count)), (unsigned int)n); | 1796 | count = min((unsigned int) |
1759 | if (copy_from_user(bh->b_data + atomic_read(&bh->b_count), buf, count)) | 1797 | (bh->b_size - atomic_read(&bh->b_count)), |
1798 | (unsigned int)n); | ||
1799 | if (copy_from_user(bh->b_data + atomic_read(&bh->b_count), buf, | ||
1800 | count)) | ||
1760 | ret = 1; | 1801 | ret = 1; |
1761 | n -= count; | 1802 | n -= count; |
1762 | atomic_add(count, &bh->b_count); | 1803 | atomic_add(count, &bh->b_count); |
@@ -1771,7 +1812,8 @@ static int idetape_copy_stage_from_user (idetape_tape_t *tape, idetape_stage_t * | |||
1771 | return ret; | 1812 | return ret; |
1772 | } | 1813 | } |
1773 | 1814 | ||
1774 | static int idetape_copy_stage_to_user (idetape_tape_t *tape, char __user *buf, idetape_stage_t *stage, int n) | 1815 | static int idetape_copy_stage_to_user(idetape_tape_t *tape, char __user *buf, |
1816 | idetape_stage_t *stage, int n) | ||
1775 | { | 1817 | { |
1776 | struct idetape_bh *bh = tape->bh; | 1818 | struct idetape_bh *bh = tape->bh; |
1777 | int count; | 1819 | int count; |
@@ -1779,8 +1821,8 @@ static int idetape_copy_stage_to_user (idetape_tape_t *tape, char __user *buf, i | |||
1779 | 1821 | ||
1780 | while (n) { | 1822 | while (n) { |
1781 | if (bh == NULL) { | 1823 | if (bh == NULL) { |
1782 | printk(KERN_ERR "ide-tape: bh == NULL in " | 1824 | printk(KERN_ERR "ide-tape: bh == NULL in %s\n", |
1783 | "idetape_copy_stage_to_user\n"); | 1825 | __func__); |
1784 | return 1; | 1826 | return 1; |
1785 | } | 1827 | } |
1786 | count = min(tape->b_count, n); | 1828 | count = min(tape->b_count, n); |
@@ -1791,7 +1833,8 @@ static int idetape_copy_stage_to_user (idetape_tape_t *tape, char __user *buf, i | |||
1791 | tape->b_count -= count; | 1833 | tape->b_count -= count; |
1792 | buf += count; | 1834 | buf += count; |
1793 | if (!tape->b_count) { | 1835 | if (!tape->b_count) { |
1794 | tape->bh = bh = bh->b_reqnext; | 1836 | bh = bh->b_reqnext; |
1837 | tape->bh = bh; | ||
1795 | if (bh) { | 1838 | if (bh) { |
1796 | tape->b_data = bh->b_data; | 1839 | tape->b_data = bh->b_data; |
1797 | tape->b_count = atomic_read(&bh->b_count); | 1840 | tape->b_count = atomic_read(&bh->b_count); |
@@ -1801,10 +1844,10 @@ static int idetape_copy_stage_to_user (idetape_tape_t *tape, char __user *buf, i | |||
1801 | return ret; | 1844 | return ret; |
1802 | } | 1845 | } |
1803 | 1846 | ||
1804 | static void idetape_init_merge_stage (idetape_tape_t *tape) | 1847 | static void idetape_init_merge_stage(idetape_tape_t *tape) |
1805 | { | 1848 | { |
1806 | struct idetape_bh *bh = tape->merge_stage->bh; | 1849 | struct idetape_bh *bh = tape->merge_stage->bh; |
1807 | 1850 | ||
1808 | tape->bh = bh; | 1851 | tape->bh = bh; |
1809 | if (tape->chrdev_dir == IDETAPE_DIR_WRITE) | 1852 | if (tape->chrdev_dir == IDETAPE_DIR_WRITE) |
1810 | atomic_set(&bh->b_count, 0); | 1853 | atomic_set(&bh->b_count, 0); |
@@ -1814,7 +1857,7 @@ static void idetape_init_merge_stage (idetape_tape_t *tape) | |||
1814 | } | 1857 | } |
1815 | } | 1858 | } |
1816 | 1859 | ||
1817 | static void idetape_switch_buffers (idetape_tape_t *tape, idetape_stage_t *stage) | 1860 | static void idetape_switch_buffers(idetape_tape_t *tape, idetape_stage_t *stage) |
1818 | { | 1861 | { |
1819 | struct idetape_bh *tmp; | 1862 | struct idetape_bh *tmp; |
1820 | 1863 | ||
@@ -1825,7 +1868,7 @@ static void idetape_switch_buffers (idetape_tape_t *tape, idetape_stage_t *stage | |||
1825 | } | 1868 | } |
1826 | 1869 | ||
1827 | /* Add a new stage at the end of the pipeline. */ | 1870 | /* Add a new stage at the end of the pipeline. */ |
1828 | static void idetape_add_stage_tail (ide_drive_t *drive,idetape_stage_t *stage) | 1871 | static void idetape_add_stage_tail(ide_drive_t *drive, idetape_stage_t *stage) |
1829 | { | 1872 | { |
1830 | idetape_tape_t *tape = drive->driver_data; | 1873 | idetape_tape_t *tape = drive->driver_data; |
1831 | unsigned long flags; | 1874 | unsigned long flags; |
@@ -1835,9 +1878,10 @@ static void idetape_add_stage_tail (ide_drive_t *drive,idetape_stage_t *stage) | |||
1835 | spin_lock_irqsave(&tape->lock, flags); | 1878 | spin_lock_irqsave(&tape->lock, flags); |
1836 | stage->next = NULL; | 1879 | stage->next = NULL; |
1837 | if (tape->last_stage != NULL) | 1880 | if (tape->last_stage != NULL) |
1838 | tape->last_stage->next=stage; | 1881 | tape->last_stage->next = stage; |
1839 | else | 1882 | else |
1840 | tape->first_stage = tape->next_stage=stage; | 1883 | tape->first_stage = stage; |
1884 | tape->next_stage = stage; | ||
1841 | tape->last_stage = stage; | 1885 | tape->last_stage = stage; |
1842 | if (tape->next_stage == NULL) | 1886 | if (tape->next_stage == NULL) |
1843 | tape->next_stage = tape->last_stage; | 1887 | tape->next_stage = tape->last_stage; |
@@ -1850,13 +1894,14 @@ static void idetape_add_stage_tail (ide_drive_t *drive,idetape_stage_t *stage) | |||
1850 | * caller should ensure that the request will not be serviced before we install | 1894 | * caller should ensure that the request will not be serviced before we install |
1851 | * the completion (usually by disabling interrupts). | 1895 | * the completion (usually by disabling interrupts). |
1852 | */ | 1896 | */ |
1853 | static void idetape_wait_for_request (ide_drive_t *drive, struct request *rq) | 1897 | static void idetape_wait_for_request(ide_drive_t *drive, struct request *rq) |
1854 | { | 1898 | { |
1855 | DECLARE_COMPLETION_ONSTACK(wait); | 1899 | DECLARE_COMPLETION_ONSTACK(wait); |
1856 | idetape_tape_t *tape = drive->driver_data; | 1900 | idetape_tape_t *tape = drive->driver_data; |
1857 | 1901 | ||
1858 | if (rq == NULL || !blk_special_request(rq)) { | 1902 | if (rq == NULL || !blk_special_request(rq)) { |
1859 | printk (KERN_ERR "ide-tape: bug: Trying to sleep on non-valid request\n"); | 1903 | printk(KERN_ERR "ide-tape: bug: Trying to sleep on non-valid" |
1904 | " request\n"); | ||
1860 | return; | 1905 | return; |
1861 | } | 1906 | } |
1862 | rq->end_io_data = &wait; | 1907 | rq->end_io_data = &wait; |
@@ -1905,7 +1950,8 @@ static ide_startstop_t idetape_read_position_callback(ide_drive_t *drive) | |||
1905 | * Write a filemark if write_filemark=1. Flush the device buffers without | 1950 | * Write a filemark if write_filemark=1. Flush the device buffers without |
1906 | * writing a filemark otherwise. | 1951 | * writing a filemark otherwise. |
1907 | */ | 1952 | */ |
1908 | static void idetape_create_write_filemark_cmd (ide_drive_t *drive, idetape_pc_t *pc,int write_filemark) | 1953 | static void idetape_create_write_filemark_cmd(ide_drive_t *drive, |
1954 | idetape_pc_t *pc, int write_filemark) | ||
1909 | { | 1955 | { |
1910 | idetape_init_pc(pc); | 1956 | idetape_init_pc(pc); |
1911 | pc->c[0] = WRITE_FILEMARKS; | 1957 | pc->c[0] = WRITE_FILEMARKS; |
@@ -1934,7 +1980,7 @@ static void idetape_create_test_unit_ready_cmd(idetape_pc_t *pc) | |||
1934 | * to the request list without waiting for it to be serviced! In that case, we | 1980 | * to the request list without waiting for it to be serviced! In that case, we |
1935 | * usually use idetape_queue_pc_head(). | 1981 | * usually use idetape_queue_pc_head(). |
1936 | */ | 1982 | */ |
1937 | static int __idetape_queue_pc_tail (ide_drive_t *drive, idetape_pc_t *pc) | 1983 | static int __idetape_queue_pc_tail(ide_drive_t *drive, idetape_pc_t *pc) |
1938 | { | 1984 | { |
1939 | struct ide_tape_obj *tape = drive->driver_data; | 1985 | struct ide_tape_obj *tape = drive->driver_data; |
1940 | struct request rq; | 1986 | struct request rq; |
@@ -1945,7 +1991,8 @@ static int __idetape_queue_pc_tail (ide_drive_t *drive, idetape_pc_t *pc) | |||
1945 | return ide_do_drive_cmd(drive, &rq, ide_wait); | 1991 | return ide_do_drive_cmd(drive, &rq, ide_wait); |
1946 | } | 1992 | } |
1947 | 1993 | ||
1948 | static void idetape_create_load_unload_cmd (ide_drive_t *drive, idetape_pc_t *pc,int cmd) | 1994 | static void idetape_create_load_unload_cmd(ide_drive_t *drive, idetape_pc_t *pc, |
1995 | int cmd) | ||
1949 | { | 1996 | { |
1950 | idetape_init_pc(pc); | 1997 | idetape_init_pc(pc); |
1951 | pc->c[0] = START_STOP; | 1998 | pc->c[0] = START_STOP; |
@@ -1972,7 +2019,8 @@ static int idetape_wait_ready(ide_drive_t *drive, unsigned long timeout) | |||
1972 | /* no media */ | 2019 | /* no media */ |
1973 | if (load_attempted) | 2020 | if (load_attempted) |
1974 | return -ENOMEDIUM; | 2021 | return -ENOMEDIUM; |
1975 | idetape_create_load_unload_cmd(drive, &pc, IDETAPE_LU_LOAD_MASK); | 2022 | idetape_create_load_unload_cmd(drive, &pc, |
2023 | IDETAPE_LU_LOAD_MASK); | ||
1976 | __idetape_queue_pc_tail(drive, &pc); | 2024 | __idetape_queue_pc_tail(drive, &pc); |
1977 | load_attempted = 1; | 2025 | load_attempted = 1; |
1978 | /* not about to be ready */ | 2026 | /* not about to be ready */ |
@@ -1984,24 +2032,25 @@ static int idetape_wait_ready(ide_drive_t *drive, unsigned long timeout) | |||
1984 | return -EIO; | 2032 | return -EIO; |
1985 | } | 2033 | } |
1986 | 2034 | ||
1987 | static int idetape_queue_pc_tail (ide_drive_t *drive,idetape_pc_t *pc) | 2035 | static int idetape_queue_pc_tail(ide_drive_t *drive, idetape_pc_t *pc) |
1988 | { | 2036 | { |
1989 | return __idetape_queue_pc_tail(drive, pc); | 2037 | return __idetape_queue_pc_tail(drive, pc); |
1990 | } | 2038 | } |
1991 | 2039 | ||
1992 | static int idetape_flush_tape_buffers (ide_drive_t *drive) | 2040 | static int idetape_flush_tape_buffers(ide_drive_t *drive) |
1993 | { | 2041 | { |
1994 | idetape_pc_t pc; | 2042 | idetape_pc_t pc; |
1995 | int rc; | 2043 | int rc; |
1996 | 2044 | ||
1997 | idetape_create_write_filemark_cmd(drive, &pc, 0); | 2045 | idetape_create_write_filemark_cmd(drive, &pc, 0); |
1998 | if ((rc = idetape_queue_pc_tail(drive, &pc))) | 2046 | rc = idetape_queue_pc_tail(drive, &pc); |
2047 | if (rc) | ||
1999 | return rc; | 2048 | return rc; |
2000 | idetape_wait_ready(drive, 60 * 5 * HZ); | 2049 | idetape_wait_ready(drive, 60 * 5 * HZ); |
2001 | return 0; | 2050 | return 0; |
2002 | } | 2051 | } |
2003 | 2052 | ||
2004 | static void idetape_create_read_position_cmd (idetape_pc_t *pc) | 2053 | static void idetape_create_read_position_cmd(idetape_pc_t *pc) |
2005 | { | 2054 | { |
2006 | idetape_init_pc(pc); | 2055 | idetape_init_pc(pc); |
2007 | pc->c[0] = READ_POSITION; | 2056 | pc->c[0] = READ_POSITION; |
@@ -2009,7 +2058,7 @@ static void idetape_create_read_position_cmd (idetape_pc_t *pc) | |||
2009 | pc->callback = &idetape_read_position_callback; | 2058 | pc->callback = &idetape_read_position_callback; |
2010 | } | 2059 | } |
2011 | 2060 | ||
2012 | static int idetape_read_position (ide_drive_t *drive) | 2061 | static int idetape_read_position(ide_drive_t *drive) |
2013 | { | 2062 | { |
2014 | idetape_tape_t *tape = drive->driver_data; | 2063 | idetape_tape_t *tape = drive->driver_data; |
2015 | idetape_pc_t pc; | 2064 | idetape_pc_t pc; |
@@ -2024,7 +2073,8 @@ static int idetape_read_position (ide_drive_t *drive) | |||
2024 | return position; | 2073 | return position; |
2025 | } | 2074 | } |
2026 | 2075 | ||
2027 | static void idetape_create_locate_cmd (ide_drive_t *drive, idetape_pc_t *pc, unsigned int block, u8 partition, int skip) | 2076 | static void idetape_create_locate_cmd(ide_drive_t *drive, idetape_pc_t *pc, |
2077 | unsigned int block, u8 partition, int skip) | ||
2028 | { | 2078 | { |
2029 | idetape_init_pc(pc); | 2079 | idetape_init_pc(pc); |
2030 | pc->c[0] = POSITION_TO_ELEMENT; | 2080 | pc->c[0] = POSITION_TO_ELEMENT; |
@@ -2035,7 +2085,8 @@ static void idetape_create_locate_cmd (ide_drive_t *drive, idetape_pc_t *pc, uns | |||
2035 | pc->callback = &idetape_pc_callback; | 2085 | pc->callback = &idetape_pc_callback; |
2036 | } | 2086 | } |
2037 | 2087 | ||
2038 | static int idetape_create_prevent_cmd (ide_drive_t *drive, idetape_pc_t *pc, int prevent) | 2088 | static int idetape_create_prevent_cmd(ide_drive_t *drive, idetape_pc_t *pc, |
2089 | int prevent) | ||
2039 | { | 2090 | { |
2040 | idetape_tape_t *tape = drive->driver_data; | 2091 | idetape_tape_t *tape = drive->driver_data; |
2041 | 2092 | ||
@@ -2050,7 +2101,7 @@ static int idetape_create_prevent_cmd (ide_drive_t *drive, idetape_pc_t *pc, int | |||
2050 | return 1; | 2101 | return 1; |
2051 | } | 2102 | } |
2052 | 2103 | ||
2053 | static int __idetape_discard_read_pipeline (ide_drive_t *drive) | 2104 | static int __idetape_discard_read_pipeline(ide_drive_t *drive) |
2054 | { | 2105 | { |
2055 | idetape_tape_t *tape = drive->driver_data; | 2106 | idetape_tape_t *tape = drive->driver_data; |
2056 | unsigned long flags; | 2107 | unsigned long flags; |
@@ -2086,7 +2137,7 @@ static int __idetape_discard_read_pipeline (ide_drive_t *drive) | |||
2086 | while (tape->first_stage != NULL) { | 2137 | while (tape->first_stage != NULL) { |
2087 | struct request *rq_ptr = &tape->first_stage->rq; | 2138 | struct request *rq_ptr = &tape->first_stage->rq; |
2088 | 2139 | ||
2089 | cnt += rq_ptr->nr_sectors - rq_ptr->current_nr_sectors; | 2140 | cnt += rq_ptr->nr_sectors - rq_ptr->current_nr_sectors; |
2090 | if (rq_ptr->errors == IDETAPE_ERROR_FILEMARK) | 2141 | if (rq_ptr->errors == IDETAPE_ERROR_FILEMARK) |
2091 | ++cnt; | 2142 | ++cnt; |
2092 | idetape_remove_stage_head(drive); | 2143 | idetape_remove_stage_head(drive); |
@@ -2102,7 +2153,8 @@ static int __idetape_discard_read_pipeline (ide_drive_t *drive) | |||
2102 | * all higher level operations, we queue the commands at the tail of the request | 2153 | * all higher level operations, we queue the commands at the tail of the request |
2103 | * queue and wait for their completion. | 2154 | * queue and wait for their completion. |
2104 | */ | 2155 | */ |
2105 | static int idetape_position_tape (ide_drive_t *drive, unsigned int block, u8 partition, int skip) | 2156 | static int idetape_position_tape(ide_drive_t *drive, unsigned int block, |
2157 | u8 partition, int skip) | ||
2106 | { | 2158 | { |
2107 | idetape_tape_t *tape = drive->driver_data; | 2159 | idetape_tape_t *tape = drive->driver_data; |
2108 | int retval; | 2160 | int retval; |
@@ -2120,7 +2172,8 @@ static int idetape_position_tape (ide_drive_t *drive, unsigned int block, u8 par | |||
2120 | return (idetape_queue_pc_tail(drive, &pc)); | 2172 | return (idetape_queue_pc_tail(drive, &pc)); |
2121 | } | 2173 | } |
2122 | 2174 | ||
2123 | static void idetape_discard_read_pipeline (ide_drive_t *drive, int restore_position) | 2175 | static void idetape_discard_read_pipeline(ide_drive_t *drive, |
2176 | int restore_position) | ||
2124 | { | 2177 | { |
2125 | idetape_tape_t *tape = drive->driver_data; | 2178 | idetape_tape_t *tape = drive->driver_data; |
2126 | int cnt; | 2179 | int cnt; |
@@ -2131,7 +2184,8 @@ static void idetape_discard_read_pipeline (ide_drive_t *drive, int restore_posit | |||
2131 | position = idetape_read_position(drive); | 2184 | position = idetape_read_position(drive); |
2132 | seek = position > cnt ? position - cnt : 0; | 2185 | seek = position > cnt ? position - cnt : 0; |
2133 | if (idetape_position_tape(drive, seek, 0, 0)) { | 2186 | if (idetape_position_tape(drive, seek, 0, 0)) { |
2134 | printk(KERN_INFO "ide-tape: %s: position_tape failed in discard_pipeline()\n", tape->name); | 2187 | printk(KERN_INFO "ide-tape: %s: position_tape failed in" |
2188 | " discard_pipeline()\n", tape->name); | ||
2135 | return; | 2189 | return; |
2136 | } | 2190 | } |
2137 | } | 2191 | } |
@@ -2141,7 +2195,8 @@ static void idetape_discard_read_pipeline (ide_drive_t *drive, int restore_posit | |||
2141 | * Generate a read/write request for the block device interface and wait for it | 2195 | * Generate a read/write request for the block device interface and wait for it |
2142 | * to be serviced. | 2196 | * to be serviced. |
2143 | */ | 2197 | */ |
2144 | static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int blocks, struct idetape_bh *bh) | 2198 | static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int blocks, |
2199 | struct idetape_bh *bh) | ||
2145 | { | 2200 | { |
2146 | idetape_tape_t *tape = drive->driver_data; | 2201 | idetape_tape_t *tape = drive->driver_data; |
2147 | struct request rq; | 2202 | struct request rq; |
@@ -2158,7 +2213,8 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int blocks, struct | |||
2158 | rq.rq_disk = tape->disk; | 2213 | rq.rq_disk = tape->disk; |
2159 | rq.special = (void *)bh; | 2214 | rq.special = (void *)bh; |
2160 | rq.sector = tape->first_frame; | 2215 | rq.sector = tape->first_frame; |
2161 | rq.nr_sectors = rq.current_nr_sectors = blocks; | 2216 | rq.nr_sectors = blocks; |
2217 | rq.current_nr_sectors = blocks; | ||
2162 | (void) ide_do_drive_cmd(drive, &rq, ide_wait); | 2218 | (void) ide_do_drive_cmd(drive, &rq, ide_wait); |
2163 | 2219 | ||
2164 | if ((cmd & (REQ_IDETAPE_READ | REQ_IDETAPE_WRITE)) == 0) | 2220 | if ((cmd & (REQ_IDETAPE_READ | REQ_IDETAPE_WRITE)) == 0) |
@@ -2185,15 +2241,16 @@ static void idetape_plug_pipeline(ide_drive_t *drive) | |||
2185 | } | 2241 | } |
2186 | } | 2242 | } |
2187 | 2243 | ||
2188 | static void idetape_create_inquiry_cmd (idetape_pc_t *pc) | 2244 | static void idetape_create_inquiry_cmd(idetape_pc_t *pc) |
2189 | { | 2245 | { |
2190 | idetape_init_pc(pc); | 2246 | idetape_init_pc(pc); |
2191 | pc->c[0] = INQUIRY; | 2247 | pc->c[0] = INQUIRY; |
2192 | pc->c[4] = pc->request_transfer = 254; | 2248 | pc->c[4] = 254; |
2249 | pc->request_transfer = 254; | ||
2193 | pc->callback = &idetape_pc_callback; | 2250 | pc->callback = &idetape_pc_callback; |
2194 | } | 2251 | } |
2195 | 2252 | ||
2196 | static void idetape_create_rewind_cmd (ide_drive_t *drive, idetape_pc_t *pc) | 2253 | static void idetape_create_rewind_cmd(ide_drive_t *drive, idetape_pc_t *pc) |
2197 | { | 2254 | { |
2198 | idetape_init_pc(pc); | 2255 | idetape_init_pc(pc); |
2199 | pc->c[0] = REZERO_UNIT; | 2256 | pc->c[0] = REZERO_UNIT; |
@@ -2201,7 +2258,7 @@ static void idetape_create_rewind_cmd (ide_drive_t *drive, idetape_pc_t *pc) | |||
2201 | pc->callback = &idetape_pc_callback; | 2258 | pc->callback = &idetape_pc_callback; |
2202 | } | 2259 | } |
2203 | 2260 | ||
2204 | static void idetape_create_erase_cmd (idetape_pc_t *pc) | 2261 | static void idetape_create_erase_cmd(idetape_pc_t *pc) |
2205 | { | 2262 | { |
2206 | idetape_init_pc(pc); | 2263 | idetape_init_pc(pc); |
2207 | pc->c[0] = ERASE; | 2264 | pc->c[0] = ERASE; |
@@ -2210,7 +2267,7 @@ static void idetape_create_erase_cmd (idetape_pc_t *pc) | |||
2210 | pc->callback = &idetape_pc_callback; | 2267 | pc->callback = &idetape_pc_callback; |
2211 | } | 2268 | } |
2212 | 2269 | ||
2213 | static void idetape_create_space_cmd (idetape_pc_t *pc,int count, u8 cmd) | 2270 | static void idetape_create_space_cmd(idetape_pc_t *pc, int count, u8 cmd) |
2214 | { | 2271 | { |
2215 | idetape_init_pc(pc); | 2272 | idetape_init_pc(pc); |
2216 | pc->c[0] = SPACE; | 2273 | pc->c[0] = SPACE; |
@@ -2220,7 +2277,7 @@ static void idetape_create_space_cmd (idetape_pc_t *pc,int count, u8 cmd) | |||
2220 | pc->callback = &idetape_pc_callback; | 2277 | pc->callback = &idetape_pc_callback; |
2221 | } | 2278 | } |
2222 | 2279 | ||
2223 | static void idetape_wait_first_stage (ide_drive_t *drive) | 2280 | static void idetape_wait_first_stage(ide_drive_t *drive) |
2224 | { | 2281 | { |
2225 | idetape_tape_t *tape = drive->driver_data; | 2282 | idetape_tape_t *tape = drive->driver_data; |
2226 | unsigned long flags; | 2283 | unsigned long flags; |
@@ -2244,7 +2301,7 @@ static void idetape_wait_first_stage (ide_drive_t *drive) | |||
2244 | * 3. If we still can't allocate a stage, fallback to non-pipelined operation | 2301 | * 3. If we still can't allocate a stage, fallback to non-pipelined operation |
2245 | * mode for this request. | 2302 | * mode for this request. |
2246 | */ | 2303 | */ |
2247 | static int idetape_add_chrdev_write_request (ide_drive_t *drive, int blocks) | 2304 | static int idetape_add_chrdev_write_request(ide_drive_t *drive, int blocks) |
2248 | { | 2305 | { |
2249 | idetape_tape_t *tape = drive->driver_data; | 2306 | idetape_tape_t *tape = drive->driver_data; |
2250 | idetape_stage_t *new_stage; | 2307 | idetape_stage_t *new_stage; |
@@ -2268,14 +2325,16 @@ static int idetape_add_chrdev_write_request (ide_drive_t *drive, int blocks) | |||
2268 | * The machine is short on memory. Fallback to non- | 2325 | * The machine is short on memory. Fallback to non- |
2269 | * pipelined operation mode for this request. | 2326 | * pipelined operation mode for this request. |
2270 | */ | 2327 | */ |
2271 | return idetape_queue_rw_tail(drive, REQ_IDETAPE_WRITE, blocks, tape->merge_stage->bh); | 2328 | return idetape_queue_rw_tail(drive, REQ_IDETAPE_WRITE, |
2329 | blocks, tape->merge_stage->bh); | ||
2272 | } | 2330 | } |
2273 | } | 2331 | } |
2274 | rq = &new_stage->rq; | 2332 | rq = &new_stage->rq; |
2275 | idetape_init_rq(rq, REQ_IDETAPE_WRITE); | 2333 | idetape_init_rq(rq, REQ_IDETAPE_WRITE); |
2276 | /* Doesn't actually matter - We always assume sequential access */ | 2334 | /* Doesn't actually matter - We always assume sequential access */ |
2277 | rq->sector = tape->first_frame; | 2335 | rq->sector = tape->first_frame; |
2278 | rq->nr_sectors = rq->current_nr_sectors = blocks; | 2336 | rq->current_nr_sectors = blocks; |
2337 | rq->nr_sectors = blocks; | ||
2279 | 2338 | ||
2280 | idetape_switch_buffers(tape, new_stage); | 2339 | idetape_switch_buffers(tape, new_stage); |
2281 | idetape_add_stage_tail(drive, new_stage); | 2340 | idetape_add_stage_tail(drive, new_stage); |
@@ -2311,7 +2370,7 @@ static int idetape_add_chrdev_write_request (ide_drive_t *drive, int blocks) | |||
2311 | * Wait until all pending pipeline requests are serviced. Typically called on | 2370 | * Wait until all pending pipeline requests are serviced. Typically called on |
2312 | * device close. | 2371 | * device close. |
2313 | */ | 2372 | */ |
2314 | static void idetape_wait_for_pipeline (ide_drive_t *drive) | 2373 | static void idetape_wait_for_pipeline(ide_drive_t *drive) |
2315 | { | 2374 | { |
2316 | idetape_tape_t *tape = drive->driver_data; | 2375 | idetape_tape_t *tape = drive->driver_data; |
2317 | unsigned long flags; | 2376 | unsigned long flags; |
@@ -2325,14 +2384,15 @@ static void idetape_wait_for_pipeline (ide_drive_t *drive) | |||
2325 | } | 2384 | } |
2326 | } | 2385 | } |
2327 | 2386 | ||
2328 | static void idetape_empty_write_pipeline (ide_drive_t *drive) | 2387 | static void idetape_empty_write_pipeline(ide_drive_t *drive) |
2329 | { | 2388 | { |
2330 | idetape_tape_t *tape = drive->driver_data; | 2389 | idetape_tape_t *tape = drive->driver_data; |
2331 | int blocks, min; | 2390 | int blocks, min; |
2332 | struct idetape_bh *bh; | 2391 | struct idetape_bh *bh; |
2333 | 2392 | ||
2334 | if (tape->chrdev_dir != IDETAPE_DIR_WRITE) { | 2393 | if (tape->chrdev_dir != IDETAPE_DIR_WRITE) { |
2335 | printk(KERN_ERR "ide-tape: bug: Trying to empty write pipeline, but we are not writing.\n"); | 2394 | printk(KERN_ERR "ide-tape: bug: Trying to empty write pipeline," |
2395 | " but we are not writing.\n"); | ||
2336 | return; | 2396 | return; |
2337 | } | 2397 | } |
2338 | if (tape->merge_stage_size > tape->stage_size) { | 2398 | if (tape->merge_stage_size > tape->stage_size) { |
@@ -2355,12 +2415,14 @@ static void idetape_empty_write_pipeline (ide_drive_t *drive) | |||
2355 | bh = tape->bh; | 2415 | bh = tape->bh; |
2356 | while (i) { | 2416 | while (i) { |
2357 | if (bh == NULL) { | 2417 | if (bh == NULL) { |
2358 | 2418 | printk(KERN_INFO "ide-tape: bug," | |
2359 | printk(KERN_INFO "ide-tape: bug, bh NULL\n"); | 2419 | " bh NULL\n"); |
2360 | break; | 2420 | break; |
2361 | } | 2421 | } |
2362 | min = min(i, (unsigned int)(bh->b_size - atomic_read(&bh->b_count))); | 2422 | min = min(i, (unsigned int)(bh->b_size - |
2363 | memset(bh->b_data + atomic_read(&bh->b_count), 0, min); | 2423 | atomic_read(&bh->b_count))); |
2424 | memset(bh->b_data + atomic_read(&bh->b_count), | ||
2425 | 0, min); | ||
2364 | atomic_add(min, &bh->b_count); | 2426 | atomic_add(min, &bh->b_count); |
2365 | i -= min; | 2427 | i -= min; |
2366 | bh = bh->b_reqnext; | 2428 | bh = bh->b_reqnext; |
@@ -2396,18 +2458,22 @@ static void idetape_empty_write_pipeline (ide_drive_t *drive) | |||
2396 | } | 2458 | } |
2397 | } | 2459 | } |
2398 | 2460 | ||
2399 | static void idetape_restart_speed_control (ide_drive_t *drive) | 2461 | static void idetape_restart_speed_control(ide_drive_t *drive) |
2400 | { | 2462 | { |
2401 | idetape_tape_t *tape = drive->driver_data; | 2463 | idetape_tape_t *tape = drive->driver_data; |
2402 | 2464 | ||
2403 | tape->restart_speed_control_req = 0; | 2465 | tape->restart_speed_control_req = 0; |
2404 | tape->pipeline_head = 0; | 2466 | tape->pipeline_head = 0; |
2405 | tape->controlled_last_pipeline_head = 0; | 2467 | tape->controlled_last_pipeline_head = 0; |
2406 | tape->controlled_previous_pipeline_head = tape->uncontrolled_previous_pipeline_head = 0; | 2468 | tape->controlled_previous_pipeline_head = 0; |
2407 | tape->pipeline_head_speed = tape->controlled_pipeline_head_speed = 5000; | 2469 | tape->uncontrolled_previous_pipeline_head = 0; |
2470 | tape->controlled_pipeline_head_speed = 5000; | ||
2471 | tape->pipeline_head_speed = 5000; | ||
2408 | tape->uncontrolled_pipeline_head_speed = 0; | 2472 | tape->uncontrolled_pipeline_head_speed = 0; |
2409 | tape->controlled_pipeline_head_time = tape->uncontrolled_pipeline_head_time = jiffies; | 2473 | tape->controlled_pipeline_head_time = |
2410 | tape->controlled_previous_head_time = tape->uncontrolled_previous_head_time = jiffies; | 2474 | tape->uncontrolled_pipeline_head_time = jiffies; |
2475 | tape->controlled_previous_head_time = | ||
2476 | tape->uncontrolled_previous_head_time = jiffies; | ||
2411 | } | 2477 | } |
2412 | 2478 | ||
2413 | static int idetape_init_read(ide_drive_t *drive, int max_stages) | 2479 | static int idetape_init_read(ide_drive_t *drive, int max_stages) |
@@ -2425,10 +2491,12 @@ static int idetape_init_read(ide_drive_t *drive, int max_stages) | |||
2425 | idetape_flush_tape_buffers(drive); | 2491 | idetape_flush_tape_buffers(drive); |
2426 | } | 2492 | } |
2427 | if (tape->merge_stage || tape->merge_stage_size) { | 2493 | if (tape->merge_stage || tape->merge_stage_size) { |
2428 | printk (KERN_ERR "ide-tape: merge_stage_size should be 0 now\n"); | 2494 | printk(KERN_ERR "ide-tape: merge_stage_size should be" |
2495 | " 0 now\n"); | ||
2429 | tape->merge_stage_size = 0; | 2496 | tape->merge_stage_size = 0; |
2430 | } | 2497 | } |
2431 | if ((tape->merge_stage = __idetape_kmalloc_stage(tape, 0, 0)) == NULL) | 2498 | tape->merge_stage = __idetape_kmalloc_stage(tape, 0, 0); |
2499 | if (!tape->merge_stage) | ||
2432 | return -ENOMEM; | 2500 | return -ENOMEM; |
2433 | tape->chrdev_dir = IDETAPE_DIR_READ; | 2501 | tape->chrdev_dir = IDETAPE_DIR_READ; |
2434 | 2502 | ||
@@ -2439,7 +2507,9 @@ static int idetape_init_read(ide_drive_t *drive, int max_stages) | |||
2439 | * drives (Seagate STT3401A) will return an error. | 2507 | * drives (Seagate STT3401A) will return an error. |
2440 | */ | 2508 | */ |
2441 | if (drive->dsc_overlap) { | 2509 | if (drive->dsc_overlap) { |
2442 | bytes_read = idetape_queue_rw_tail(drive, REQ_IDETAPE_READ, 0, tape->merge_stage->bh); | 2510 | bytes_read = idetape_queue_rw_tail(drive, |
2511 | REQ_IDETAPE_READ, 0, | ||
2512 | tape->merge_stage->bh); | ||
2443 | if (bytes_read < 0) { | 2513 | if (bytes_read < 0) { |
2444 | __idetape_kfree_stage(tape->merge_stage); | 2514 | __idetape_kfree_stage(tape->merge_stage); |
2445 | tape->merge_stage = NULL; | 2515 | tape->merge_stage = NULL; |
@@ -2452,7 +2522,8 @@ static int idetape_init_read(ide_drive_t *drive, int max_stages) | |||
2452 | idetape_restart_speed_control(drive); | 2522 | idetape_restart_speed_control(drive); |
2453 | idetape_init_rq(&rq, REQ_IDETAPE_READ); | 2523 | idetape_init_rq(&rq, REQ_IDETAPE_READ); |
2454 | rq.sector = tape->first_frame; | 2524 | rq.sector = tape->first_frame; |
2455 | rq.nr_sectors = rq.current_nr_sectors = blocks; | 2525 | rq.nr_sectors = blocks; |
2526 | rq.current_nr_sectors = blocks; | ||
2456 | if (!test_bit(IDETAPE_PIPELINE_ERROR, &tape->flags) && | 2527 | if (!test_bit(IDETAPE_PIPELINE_ERROR, &tape->flags) && |
2457 | tape->nr_stages < max_stages) { | 2528 | tape->nr_stages < max_stages) { |
2458 | new_stage = idetape_kmalloc_stage(tape); | 2529 | new_stage = idetape_kmalloc_stage(tape); |
@@ -2480,7 +2551,7 @@ static int idetape_init_read(ide_drive_t *drive, int max_stages) | |||
2480 | * Called from idetape_chrdev_read() to service a character device read request | 2551 | * Called from idetape_chrdev_read() to service a character device read request |
2481 | * and add read-ahead requests to our pipeline. | 2552 | * and add read-ahead requests to our pipeline. |
2482 | */ | 2553 | */ |
2483 | static int idetape_add_chrdev_read_request (ide_drive_t *drive,int blocks) | 2554 | static int idetape_add_chrdev_read_request(ide_drive_t *drive, int blocks) |
2484 | { | 2555 | { |
2485 | idetape_tape_t *tape = drive->driver_data; | 2556 | idetape_tape_t *tape = drive->driver_data; |
2486 | unsigned long flags; | 2557 | unsigned long flags; |
@@ -2505,8 +2576,8 @@ static int idetape_add_chrdev_read_request (ide_drive_t *drive,int blocks) | |||
2505 | rq_ptr = &tape->first_stage->rq; | 2576 | rq_ptr = &tape->first_stage->rq; |
2506 | bytes_read = tape->blk_size * (rq_ptr->nr_sectors - | 2577 | bytes_read = tape->blk_size * (rq_ptr->nr_sectors - |
2507 | rq_ptr->current_nr_sectors); | 2578 | rq_ptr->current_nr_sectors); |
2508 | rq_ptr->nr_sectors = rq_ptr->current_nr_sectors = 0; | 2579 | rq_ptr->nr_sectors = 0; |
2509 | 2580 | rq_ptr->current_nr_sectors = 0; | |
2510 | 2581 | ||
2511 | if (rq_ptr->errors == IDETAPE_ERROR_EOD) | 2582 | if (rq_ptr->errors == IDETAPE_ERROR_EOD) |
2512 | return 0; | 2583 | return 0; |
@@ -2521,13 +2592,14 @@ static int idetape_add_chrdev_read_request (ide_drive_t *drive,int blocks) | |||
2521 | idetape_calculate_speeds(drive); | 2592 | idetape_calculate_speeds(drive); |
2522 | } | 2593 | } |
2523 | if (bytes_read > blocks * tape->blk_size) { | 2594 | if (bytes_read > blocks * tape->blk_size) { |
2524 | printk(KERN_ERR "ide-tape: bug: trying to return more bytes than requested\n"); | 2595 | printk(KERN_ERR "ide-tape: bug: trying to return more bytes" |
2596 | " than requested\n"); | ||
2525 | bytes_read = blocks * tape->blk_size; | 2597 | bytes_read = blocks * tape->blk_size; |
2526 | } | 2598 | } |
2527 | return (bytes_read); | 2599 | return (bytes_read); |
2528 | } | 2600 | } |
2529 | 2601 | ||
2530 | static void idetape_pad_zeros (ide_drive_t *drive, int bcount) | 2602 | static void idetape_pad_zeros(ide_drive_t *drive, int bcount) |
2531 | { | 2603 | { |
2532 | idetape_tape_t *tape = drive->driver_data; | 2604 | idetape_tape_t *tape = drive->driver_data; |
2533 | struct idetape_bh *bh; | 2605 | struct idetape_bh *bh; |
@@ -2541,16 +2613,18 @@ static void idetape_pad_zeros (ide_drive_t *drive, int bcount) | |||
2541 | bcount -= count; | 2613 | bcount -= count; |
2542 | blocks = count / tape->blk_size; | 2614 | blocks = count / tape->blk_size; |
2543 | while (count) { | 2615 | while (count) { |
2544 | atomic_set(&bh->b_count, min(count, (unsigned int)bh->b_size)); | 2616 | atomic_set(&bh->b_count, |
2617 | min(count, (unsigned int)bh->b_size)); | ||
2545 | memset(bh->b_data, 0, atomic_read(&bh->b_count)); | 2618 | memset(bh->b_data, 0, atomic_read(&bh->b_count)); |
2546 | count -= atomic_read(&bh->b_count); | 2619 | count -= atomic_read(&bh->b_count); |
2547 | bh = bh->b_reqnext; | 2620 | bh = bh->b_reqnext; |
2548 | } | 2621 | } |
2549 | idetape_queue_rw_tail(drive, REQ_IDETAPE_WRITE, blocks, tape->merge_stage->bh); | 2622 | idetape_queue_rw_tail(drive, REQ_IDETAPE_WRITE, blocks, |
2623 | tape->merge_stage->bh); | ||
2550 | } | 2624 | } |
2551 | } | 2625 | } |
2552 | 2626 | ||
2553 | static int idetape_pipeline_size (ide_drive_t *drive) | 2627 | static int idetape_pipeline_size(ide_drive_t *drive) |
2554 | { | 2628 | { |
2555 | idetape_tape_t *tape = drive->driver_data; | 2629 | idetape_tape_t *tape = drive->driver_data; |
2556 | idetape_stage_t *stage; | 2630 | idetape_stage_t *stage; |
@@ -2575,7 +2649,7 @@ static int idetape_pipeline_size (ide_drive_t *drive) | |||
2575 | * Rewinds the tape to the Beginning Of the current Partition (BOP). We | 2649 | * Rewinds the tape to the Beginning Of the current Partition (BOP). We |
2576 | * currently support only one partition. | 2650 | * currently support only one partition. |
2577 | */ | 2651 | */ |
2578 | static int idetape_rewind_tape (ide_drive_t *drive) | 2652 | static int idetape_rewind_tape(ide_drive_t *drive) |
2579 | { | 2653 | { |
2580 | int retval; | 2654 | int retval; |
2581 | idetape_pc_t pc; | 2655 | idetape_pc_t pc; |
@@ -2597,7 +2671,8 @@ static int idetape_rewind_tape (ide_drive_t *drive) | |||
2597 | } | 2671 | } |
2598 | 2672 | ||
2599 | /* mtio.h compatible commands should be issued to the chrdev interface. */ | 2673 | /* mtio.h compatible commands should be issued to the chrdev interface. */ |
2600 | static int idetape_blkdev_ioctl(ide_drive_t *drive, unsigned int cmd, unsigned long arg) | 2674 | static int idetape_blkdev_ioctl(ide_drive_t *drive, unsigned int cmd, |
2675 | unsigned long arg) | ||
2601 | { | 2676 | { |
2602 | idetape_tape_t *tape = drive->driver_data; | 2677 | idetape_tape_t *tape = drive->driver_data; |
2603 | void __user *argp = (void __user *)arg; | 2678 | void __user *argp = (void __user *)arg; |
@@ -2611,20 +2686,20 @@ static int idetape_blkdev_ioctl(ide_drive_t *drive, unsigned int cmd, unsigned l | |||
2611 | debug_log(DBG_PROCS, "Enter %s\n", __func__); | 2686 | debug_log(DBG_PROCS, "Enter %s\n", __func__); |
2612 | 2687 | ||
2613 | switch (cmd) { | 2688 | switch (cmd) { |
2614 | case 0x0340: | 2689 | case 0x0340: |
2615 | if (copy_from_user(&config, argp, sizeof(config))) | 2690 | if (copy_from_user(&config, argp, sizeof(config))) |
2616 | return -EFAULT; | 2691 | return -EFAULT; |
2617 | tape->best_dsc_rw_freq = config.dsc_rw_frequency; | 2692 | tape->best_dsc_rw_freq = config.dsc_rw_frequency; |
2618 | tape->max_stages = config.nr_stages; | 2693 | tape->max_stages = config.nr_stages; |
2619 | break; | 2694 | break; |
2620 | case 0x0350: | 2695 | case 0x0350: |
2621 | config.dsc_rw_frequency = (int) tape->best_dsc_rw_freq; | 2696 | config.dsc_rw_frequency = (int) tape->best_dsc_rw_freq; |
2622 | config.nr_stages = tape->max_stages; | 2697 | config.nr_stages = tape->max_stages; |
2623 | if (copy_to_user(argp, &config, sizeof(config))) | 2698 | if (copy_to_user(argp, &config, sizeof(config))) |
2624 | return -EFAULT; | 2699 | return -EFAULT; |
2625 | break; | 2700 | break; |
2626 | default: | 2701 | default: |
2627 | return -EIO; | 2702 | return -EIO; |
2628 | } | 2703 | } |
2629 | return 0; | 2704 | return 0; |
2630 | } | 2705 | } |
@@ -2636,12 +2711,13 @@ static int idetape_blkdev_ioctl(ide_drive_t *drive, unsigned int cmd, unsigned l | |||
2636 | * support MTFSFM when the filemark is in our internal pipeline even if the tape | 2711 | * support MTFSFM when the filemark is in our internal pipeline even if the tape |
2637 | * doesn't support spacing over filemarks in the reverse direction. | 2712 | * doesn't support spacing over filemarks in the reverse direction. |
2638 | */ | 2713 | */ |
2639 | static int idetape_space_over_filemarks (ide_drive_t *drive,short mt_op,int mt_count) | 2714 | static int idetape_space_over_filemarks(ide_drive_t *drive, short mt_op, |
2715 | int mt_count) | ||
2640 | { | 2716 | { |
2641 | idetape_tape_t *tape = drive->driver_data; | 2717 | idetape_tape_t *tape = drive->driver_data; |
2642 | idetape_pc_t pc; | 2718 | idetape_pc_t pc; |
2643 | unsigned long flags; | 2719 | unsigned long flags; |
2644 | int retval,count=0; | 2720 | int retval, count = 0; |
2645 | int sprev = !!(tape->caps[4] & 0x20); | 2721 | int sprev = !!(tape->caps[4] & 0x20); |
2646 | 2722 | ||
2647 | if (mt_count == 0) | 2723 | if (mt_count == 0) |
@@ -2649,7 +2725,7 @@ static int idetape_space_over_filemarks (ide_drive_t *drive,short mt_op,int mt_c | |||
2649 | if (MTBSF == mt_op || MTBSFM == mt_op) { | 2725 | if (MTBSF == mt_op || MTBSFM == mt_op) { |
2650 | if (!sprev) | 2726 | if (!sprev) |
2651 | return -EIO; | 2727 | return -EIO; |
2652 | mt_count = - mt_count; | 2728 | mt_count = -mt_count; |
2653 | } | 2729 | } |
2654 | 2730 | ||
2655 | if (tape->chrdev_dir == IDETAPE_DIR_READ) { | 2731 | if (tape->chrdev_dir == IDETAPE_DIR_READ) { |
@@ -2682,7 +2758,8 @@ static int idetape_space_over_filemarks (ide_drive_t *drive,short mt_op,int mt_c | |||
2682 | tape->next_stage = tape->first_stage->next; | 2758 | tape->next_stage = tape->first_stage->next; |
2683 | } else | 2759 | } else |
2684 | spin_unlock_irqrestore(&tape->lock, flags); | 2760 | spin_unlock_irqrestore(&tape->lock, flags); |
2685 | if (tape->first_stage->rq.errors == IDETAPE_ERROR_FILEMARK) | 2761 | if (tape->first_stage->rq.errors == |
2762 | IDETAPE_ERROR_FILEMARK) | ||
2686 | ++count; | 2763 | ++count; |
2687 | idetape_remove_stage_head(drive); | 2764 | idetape_remove_stage_head(drive); |
2688 | } | 2765 | } |
@@ -2694,25 +2771,28 @@ static int idetape_space_over_filemarks (ide_drive_t *drive,short mt_op,int mt_c | |||
2694 | * the space command. | 2771 | * the space command. |
2695 | */ | 2772 | */ |
2696 | switch (mt_op) { | 2773 | switch (mt_op) { |
2697 | case MTFSF: | 2774 | case MTFSF: |
2698 | case MTBSF: | 2775 | case MTBSF: |
2699 | idetape_create_space_cmd(&pc,mt_count-count,IDETAPE_SPACE_OVER_FILEMARK); | 2776 | idetape_create_space_cmd(&pc, mt_count - count, |
2700 | return (idetape_queue_pc_tail(drive, &pc)); | 2777 | IDETAPE_SPACE_OVER_FILEMARK); |
2701 | case MTFSFM: | 2778 | return idetape_queue_pc_tail(drive, &pc); |
2702 | case MTBSFM: | 2779 | case MTFSFM: |
2703 | if (!sprev) | 2780 | case MTBSFM: |
2704 | return (-EIO); | 2781 | if (!sprev) |
2705 | retval = idetape_space_over_filemarks(drive, MTFSF, mt_count-count); | 2782 | return -EIO; |
2706 | if (retval) return (retval); | 2783 | retval = idetape_space_over_filemarks(drive, MTFSF, |
2707 | count = (MTBSFM == mt_op ? 1 : -1); | 2784 | mt_count - count); |
2708 | return (idetape_space_over_filemarks(drive, MTFSF, count)); | 2785 | if (retval) |
2709 | default: | 2786 | return retval; |
2710 | printk(KERN_ERR "ide-tape: MTIO operation %d not supported\n",mt_op); | 2787 | count = (MTBSFM == mt_op ? 1 : -1); |
2711 | return (-EIO); | 2788 | return idetape_space_over_filemarks(drive, MTFSF, count); |
2789 | default: | ||
2790 | printk(KERN_ERR "ide-tape: MTIO operation %d not supported\n", | ||
2791 | mt_op); | ||
2792 | return -EIO; | ||
2712 | } | 2793 | } |
2713 | } | 2794 | } |
2714 | 2795 | ||
2715 | |||
2716 | /* | 2796 | /* |
2717 | * Our character device read / write functions. | 2797 | * Our character device read / write functions. |
2718 | * | 2798 | * |
@@ -2728,12 +2808,12 @@ static int idetape_space_over_filemarks (ide_drive_t *drive,short mt_op,int mt_c | |||
2728 | * (slightly) increased driver overhead, but will no longer hit performance. | 2808 | * (slightly) increased driver overhead, but will no longer hit performance. |
2729 | * This is not applicable to Onstream. | 2809 | * This is not applicable to Onstream. |
2730 | */ | 2810 | */ |
2731 | static ssize_t idetape_chrdev_read (struct file *file, char __user *buf, | 2811 | static ssize_t idetape_chrdev_read(struct file *file, char __user *buf, |
2732 | size_t count, loff_t *ppos) | 2812 | size_t count, loff_t *ppos) |
2733 | { | 2813 | { |
2734 | struct ide_tape_obj *tape = ide_tape_f(file); | 2814 | struct ide_tape_obj *tape = ide_tape_f(file); |
2735 | ide_drive_t *drive = tape->drive; | 2815 | ide_drive_t *drive = tape->drive; |
2736 | ssize_t bytes_read,temp, actually_read = 0, rc; | 2816 | ssize_t bytes_read, temp, actually_read = 0, rc; |
2737 | ssize_t ret = 0; | 2817 | ssize_t ret = 0; |
2738 | u16 ctl = *(u16 *)&tape->caps[12]; | 2818 | u16 ctl = *(u16 *)&tape->caps[12]; |
2739 | 2819 | ||
@@ -2751,8 +2831,10 @@ static ssize_t idetape_chrdev_read (struct file *file, char __user *buf, | |||
2751 | if (count == 0) | 2831 | if (count == 0) |
2752 | return (0); | 2832 | return (0); |
2753 | if (tape->merge_stage_size) { | 2833 | if (tape->merge_stage_size) { |
2754 | actually_read = min((unsigned int)(tape->merge_stage_size), (unsigned int)count); | 2834 | actually_read = min((unsigned int)(tape->merge_stage_size), |
2755 | if (idetape_copy_stage_to_user(tape, buf, tape->merge_stage, actually_read)) | 2835 | (unsigned int)count); |
2836 | if (idetape_copy_stage_to_user(tape, buf, tape->merge_stage, | ||
2837 | actually_read)) | ||
2756 | ret = -EFAULT; | 2838 | ret = -EFAULT; |
2757 | buf += actually_read; | 2839 | buf += actually_read; |
2758 | tape->merge_stage_size -= actually_read; | 2840 | tape->merge_stage_size -= actually_read; |
@@ -2762,7 +2844,8 @@ static ssize_t idetape_chrdev_read (struct file *file, char __user *buf, | |||
2762 | bytes_read = idetape_add_chrdev_read_request(drive, ctl); | 2844 | bytes_read = idetape_add_chrdev_read_request(drive, ctl); |
2763 | if (bytes_read <= 0) | 2845 | if (bytes_read <= 0) |
2764 | goto finish; | 2846 | goto finish; |
2765 | if (idetape_copy_stage_to_user(tape, buf, tape->merge_stage, bytes_read)) | 2847 | if (idetape_copy_stage_to_user(tape, buf, tape->merge_stage, |
2848 | bytes_read)) | ||
2766 | ret = -EFAULT; | 2849 | ret = -EFAULT; |
2767 | buf += bytes_read; | 2850 | buf += bytes_read; |
2768 | count -= bytes_read; | 2851 | count -= bytes_read; |
@@ -2773,7 +2856,8 @@ static ssize_t idetape_chrdev_read (struct file *file, char __user *buf, | |||
2773 | if (bytes_read <= 0) | 2856 | if (bytes_read <= 0) |
2774 | goto finish; | 2857 | goto finish; |
2775 | temp = min((unsigned long)count, (unsigned long)bytes_read); | 2858 | temp = min((unsigned long)count, (unsigned long)bytes_read); |
2776 | if (idetape_copy_stage_to_user(tape, buf, tape->merge_stage, temp)) | 2859 | if (idetape_copy_stage_to_user(tape, buf, tape->merge_stage, |
2860 | temp)) | ||
2777 | ret = -EFAULT; | 2861 | ret = -EFAULT; |
2778 | actually_read += temp; | 2862 | actually_read += temp; |
2779 | tape->merge_stage_size = bytes_read-temp; | 2863 | tape->merge_stage_size = bytes_read-temp; |
@@ -2786,10 +2870,10 @@ finish: | |||
2786 | return 0; | 2870 | return 0; |
2787 | } | 2871 | } |
2788 | 2872 | ||
2789 | return (ret) ? ret : actually_read; | 2873 | return ret ? ret : actually_read; |
2790 | } | 2874 | } |
2791 | 2875 | ||
2792 | static ssize_t idetape_chrdev_write (struct file *file, const char __user *buf, | 2876 | static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf, |
2793 | size_t count, loff_t *ppos) | 2877 | size_t count, loff_t *ppos) |
2794 | { | 2878 | { |
2795 | struct ide_tape_obj *tape = ide_tape_f(file); | 2879 | struct ide_tape_obj *tape = ide_tape_f(file); |
@@ -2813,7 +2897,8 @@ static ssize_t idetape_chrdev_write (struct file *file, const char __user *buf, | |||
2813 | "should be 0 now\n"); | 2897 | "should be 0 now\n"); |
2814 | tape->merge_stage_size = 0; | 2898 | tape->merge_stage_size = 0; |
2815 | } | 2899 | } |
2816 | if ((tape->merge_stage = __idetape_kmalloc_stage(tape, 0, 0)) == NULL) | 2900 | tape->merge_stage = __idetape_kmalloc_stage(tape, 0, 0); |
2901 | if (!tape->merge_stage) | ||
2817 | return -ENOMEM; | 2902 | return -ENOMEM; |
2818 | tape->chrdev_dir = IDETAPE_DIR_WRITE; | 2903 | tape->chrdev_dir = IDETAPE_DIR_WRITE; |
2819 | idetape_init_merge_stage(tape); | 2904 | idetape_init_merge_stage(tape); |
@@ -2825,7 +2910,9 @@ static ssize_t idetape_chrdev_write (struct file *file, const char __user *buf, | |||
2825 | * drives (Seagate STT3401A) will return an error. | 2910 | * drives (Seagate STT3401A) will return an error. |
2826 | */ | 2911 | */ |
2827 | if (drive->dsc_overlap) { | 2912 | if (drive->dsc_overlap) { |
2828 | ssize_t retval = idetape_queue_rw_tail(drive, REQ_IDETAPE_WRITE, 0, tape->merge_stage->bh); | 2913 | ssize_t retval = idetape_queue_rw_tail(drive, |
2914 | REQ_IDETAPE_WRITE, 0, | ||
2915 | tape->merge_stage->bh); | ||
2829 | if (retval < 0) { | 2916 | if (retval < 0) { |
2830 | __idetape_kfree_stage(tape->merge_stage); | 2917 | __idetape_kfree_stage(tape->merge_stage); |
2831 | tape->merge_stage = NULL; | 2918 | tape->merge_stage = NULL; |
@@ -2840,11 +2927,14 @@ static ssize_t idetape_chrdev_write (struct file *file, const char __user *buf, | |||
2840 | idetape_restart_speed_control(drive); | 2927 | idetape_restart_speed_control(drive); |
2841 | if (tape->merge_stage_size) { | 2928 | if (tape->merge_stage_size) { |
2842 | if (tape->merge_stage_size >= tape->stage_size) { | 2929 | if (tape->merge_stage_size >= tape->stage_size) { |
2843 | printk(KERN_ERR "ide-tape: bug: merge buffer too big\n"); | 2930 | printk(KERN_ERR "ide-tape: bug: merge buf too big\n"); |
2844 | tape->merge_stage_size = 0; | 2931 | tape->merge_stage_size = 0; |
2845 | } | 2932 | } |
2846 | actually_written = min((unsigned int)(tape->stage_size - tape->merge_stage_size), (unsigned int)count); | 2933 | actually_written = min((unsigned int) |
2847 | if (idetape_copy_stage_from_user(tape, tape->merge_stage, buf, actually_written)) | 2934 | (tape->stage_size - tape->merge_stage_size), |
2935 | (unsigned int)count); | ||
2936 | if (idetape_copy_stage_from_user(tape, tape->merge_stage, buf, | ||
2937 | actually_written)) | ||
2848 | ret = -EFAULT; | 2938 | ret = -EFAULT; |
2849 | buf += actually_written; | 2939 | buf += actually_written; |
2850 | tape->merge_stage_size += actually_written; | 2940 | tape->merge_stage_size += actually_written; |
@@ -2860,7 +2950,8 @@ static ssize_t idetape_chrdev_write (struct file *file, const char __user *buf, | |||
2860 | } | 2950 | } |
2861 | while (count >= tape->stage_size) { | 2951 | while (count >= tape->stage_size) { |
2862 | ssize_t retval; | 2952 | ssize_t retval; |
2863 | if (idetape_copy_stage_from_user(tape, tape->merge_stage, buf, tape->stage_size)) | 2953 | if (idetape_copy_stage_from_user(tape, tape->merge_stage, buf, |
2954 | tape->stage_size)) | ||
2864 | ret = -EFAULT; | 2955 | ret = -EFAULT; |
2865 | buf += tape->stage_size; | 2956 | buf += tape->stage_size; |
2866 | count -= tape->stage_size; | 2957 | count -= tape->stage_size; |
@@ -2871,14 +2962,15 @@ static ssize_t idetape_chrdev_write (struct file *file, const char __user *buf, | |||
2871 | } | 2962 | } |
2872 | if (count) { | 2963 | if (count) { |
2873 | actually_written += count; | 2964 | actually_written += count; |
2874 | if (idetape_copy_stage_from_user(tape, tape->merge_stage, buf, count)) | 2965 | if (idetape_copy_stage_from_user(tape, tape->merge_stage, buf, |
2966 | count)) | ||
2875 | ret = -EFAULT; | 2967 | ret = -EFAULT; |
2876 | tape->merge_stage_size += count; | 2968 | tape->merge_stage_size += count; |
2877 | } | 2969 | } |
2878 | return (ret) ? ret : actually_written; | 2970 | return ret ? ret : actually_written; |
2879 | } | 2971 | } |
2880 | 2972 | ||
2881 | static int idetape_write_filemark (ide_drive_t *drive) | 2973 | static int idetape_write_filemark(ide_drive_t *drive) |
2882 | { | 2974 | { |
2883 | idetape_pc_t pc; | 2975 | idetape_pc_t pc; |
2884 | 2976 | ||
@@ -2909,110 +3001,117 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) | |||
2909 | { | 3001 | { |
2910 | idetape_tape_t *tape = drive->driver_data; | 3002 | idetape_tape_t *tape = drive->driver_data; |
2911 | idetape_pc_t pc; | 3003 | idetape_pc_t pc; |
2912 | int i,retval; | 3004 | int i, retval; |
2913 | 3005 | ||
2914 | debug_log(DBG_ERR, "Handling MTIOCTOP ioctl: mt_op=%d, mt_count=%d\n", | 3006 | debug_log(DBG_ERR, "Handling MTIOCTOP ioctl: mt_op=%d, mt_count=%d\n", |
2915 | mt_op, mt_count); | 3007 | mt_op, mt_count); |
3008 | |||
2916 | /* Commands which need our pipelined read-ahead stages. */ | 3009 | /* Commands which need our pipelined read-ahead stages. */ |
2917 | switch (mt_op) { | 3010 | switch (mt_op) { |
2918 | case MTFSF: | 3011 | case MTFSF: |
2919 | case MTFSFM: | 3012 | case MTFSFM: |
2920 | case MTBSF: | 3013 | case MTBSF: |
2921 | case MTBSFM: | 3014 | case MTBSFM: |
2922 | if (!mt_count) | 3015 | if (!mt_count) |
2923 | return (0); | 3016 | return 0; |
2924 | return (idetape_space_over_filemarks(drive,mt_op,mt_count)); | 3017 | return idetape_space_over_filemarks(drive, mt_op, mt_count); |
2925 | default: | 3018 | default: |
2926 | break; | 3019 | break; |
2927 | } | 3020 | } |
3021 | |||
2928 | switch (mt_op) { | 3022 | switch (mt_op) { |
2929 | case MTWEOF: | 3023 | case MTWEOF: |
2930 | if (tape->write_prot) | 3024 | if (tape->write_prot) |
2931 | return -EACCES; | 3025 | return -EACCES; |
2932 | idetape_discard_read_pipeline(drive, 1); | 3026 | idetape_discard_read_pipeline(drive, 1); |
2933 | for (i = 0; i < mt_count; i++) { | 3027 | for (i = 0; i < mt_count; i++) { |
2934 | retval = idetape_write_filemark(drive); | 3028 | retval = idetape_write_filemark(drive); |
2935 | if (retval) | 3029 | if (retval) |
2936 | return retval; | 3030 | return retval; |
2937 | } | 3031 | } |
2938 | return (0); | 3032 | return 0; |
2939 | case MTREW: | 3033 | case MTREW: |
2940 | idetape_discard_read_pipeline(drive, 0); | 3034 | idetape_discard_read_pipeline(drive, 0); |
2941 | if (idetape_rewind_tape(drive)) | 3035 | if (idetape_rewind_tape(drive)) |
3036 | return -EIO; | ||
3037 | return 0; | ||
3038 | case MTLOAD: | ||
3039 | idetape_discard_read_pipeline(drive, 0); | ||
3040 | idetape_create_load_unload_cmd(drive, &pc, | ||
3041 | IDETAPE_LU_LOAD_MASK); | ||
3042 | return idetape_queue_pc_tail(drive, &pc); | ||
3043 | case MTUNLOAD: | ||
3044 | case MTOFFL: | ||
3045 | /* | ||
3046 | * If door is locked, attempt to unlock before | ||
3047 | * attempting to eject. | ||
3048 | */ | ||
3049 | if (tape->door_locked) { | ||
3050 | if (idetape_create_prevent_cmd(drive, &pc, 0)) | ||
3051 | if (!idetape_queue_pc_tail(drive, &pc)) | ||
3052 | tape->door_locked = DOOR_UNLOCKED; | ||
3053 | } | ||
3054 | idetape_discard_read_pipeline(drive, 0); | ||
3055 | idetape_create_load_unload_cmd(drive, &pc, | ||
3056 | !IDETAPE_LU_LOAD_MASK); | ||
3057 | retval = idetape_queue_pc_tail(drive, &pc); | ||
3058 | if (!retval) | ||
3059 | clear_bit(IDETAPE_MEDIUM_PRESENT, &tape->flags); | ||
3060 | return retval; | ||
3061 | case MTNOP: | ||
3062 | idetape_discard_read_pipeline(drive, 0); | ||
3063 | return idetape_flush_tape_buffers(drive); | ||
3064 | case MTRETEN: | ||
3065 | idetape_discard_read_pipeline(drive, 0); | ||
3066 | idetape_create_load_unload_cmd(drive, &pc, | ||
3067 | IDETAPE_LU_RETENSION_MASK | IDETAPE_LU_LOAD_MASK); | ||
3068 | return idetape_queue_pc_tail(drive, &pc); | ||
3069 | case MTEOM: | ||
3070 | idetape_create_space_cmd(&pc, 0, IDETAPE_SPACE_TO_EOD); | ||
3071 | return idetape_queue_pc_tail(drive, &pc); | ||
3072 | case MTERASE: | ||
3073 | (void)idetape_rewind_tape(drive); | ||
3074 | idetape_create_erase_cmd(&pc); | ||
3075 | return idetape_queue_pc_tail(drive, &pc); | ||
3076 | case MTSETBLK: | ||
3077 | if (mt_count) { | ||
3078 | if (mt_count < tape->blk_size || | ||
3079 | mt_count % tape->blk_size) | ||
2942 | return -EIO; | 3080 | return -EIO; |
3081 | tape->user_bs_factor = mt_count / tape->blk_size; | ||
3082 | clear_bit(IDETAPE_DETECT_BS, &tape->flags); | ||
3083 | } else | ||
3084 | set_bit(IDETAPE_DETECT_BS, &tape->flags); | ||
3085 | return 0; | ||
3086 | case MTSEEK: | ||
3087 | idetape_discard_read_pipeline(drive, 0); | ||
3088 | return idetape_position_tape(drive, | ||
3089 | mt_count * tape->user_bs_factor, tape->partition, 0); | ||
3090 | case MTSETPART: | ||
3091 | idetape_discard_read_pipeline(drive, 0); | ||
3092 | return idetape_position_tape(drive, 0, mt_count, 0); | ||
3093 | case MTFSR: | ||
3094 | case MTBSR: | ||
3095 | case MTLOCK: | ||
3096 | if (!idetape_create_prevent_cmd(drive, &pc, 1)) | ||
2943 | return 0; | 3097 | return 0; |
2944 | case MTLOAD: | 3098 | retval = idetape_queue_pc_tail(drive, &pc); |
2945 | idetape_discard_read_pipeline(drive, 0); | 3099 | if (retval) |
2946 | idetape_create_load_unload_cmd(drive, &pc, IDETAPE_LU_LOAD_MASK); | ||
2947 | return (idetape_queue_pc_tail(drive, &pc)); | ||
2948 | case MTUNLOAD: | ||
2949 | case MTOFFL: | ||
2950 | /* | ||
2951 | * If door is locked, attempt to unlock before | ||
2952 | * attempting to eject. | ||
2953 | */ | ||
2954 | if (tape->door_locked) { | ||
2955 | if (idetape_create_prevent_cmd(drive, &pc, 0)) | ||
2956 | if (!idetape_queue_pc_tail(drive, &pc)) | ||
2957 | tape->door_locked = DOOR_UNLOCKED; | ||
2958 | } | ||
2959 | idetape_discard_read_pipeline(drive, 0); | ||
2960 | idetape_create_load_unload_cmd(drive, &pc,!IDETAPE_LU_LOAD_MASK); | ||
2961 | retval = idetape_queue_pc_tail(drive, &pc); | ||
2962 | if (!retval) | ||
2963 | clear_bit(IDETAPE_MEDIUM_PRESENT, &tape->flags); | ||
2964 | return retval; | 3100 | return retval; |
2965 | case MTNOP: | 3101 | tape->door_locked = DOOR_EXPLICITLY_LOCKED; |
2966 | idetape_discard_read_pipeline(drive, 0); | 3102 | return 0; |
2967 | return (idetape_flush_tape_buffers(drive)); | 3103 | case MTUNLOCK: |
2968 | case MTRETEN: | 3104 | if (!idetape_create_prevent_cmd(drive, &pc, 0)) |
2969 | idetape_discard_read_pipeline(drive, 0); | ||
2970 | idetape_create_load_unload_cmd(drive, &pc,IDETAPE_LU_RETENSION_MASK | IDETAPE_LU_LOAD_MASK); | ||
2971 | return (idetape_queue_pc_tail(drive, &pc)); | ||
2972 | case MTEOM: | ||
2973 | idetape_create_space_cmd(&pc, 0, IDETAPE_SPACE_TO_EOD); | ||
2974 | return (idetape_queue_pc_tail(drive, &pc)); | ||
2975 | case MTERASE: | ||
2976 | (void) idetape_rewind_tape(drive); | ||
2977 | idetape_create_erase_cmd(&pc); | ||
2978 | return (idetape_queue_pc_tail(drive, &pc)); | ||
2979 | case MTSETBLK: | ||
2980 | if (mt_count) { | ||
2981 | if (mt_count < tape->blk_size || | ||
2982 | mt_count % tape->blk_size) | ||
2983 | return -EIO; | ||
2984 | tape->user_bs_factor = mt_count / | ||
2985 | tape->blk_size; | ||
2986 | clear_bit(IDETAPE_DETECT_BS, &tape->flags); | ||
2987 | } else | ||
2988 | set_bit(IDETAPE_DETECT_BS, &tape->flags); | ||
2989 | return 0; | ||
2990 | case MTSEEK: | ||
2991 | idetape_discard_read_pipeline(drive, 0); | ||
2992 | return idetape_position_tape(drive, mt_count * tape->user_bs_factor, tape->partition, 0); | ||
2993 | case MTSETPART: | ||
2994 | idetape_discard_read_pipeline(drive, 0); | ||
2995 | return (idetape_position_tape(drive, 0, mt_count, 0)); | ||
2996 | case MTFSR: | ||
2997 | case MTBSR: | ||
2998 | case MTLOCK: | ||
2999 | if (!idetape_create_prevent_cmd(drive, &pc, 1)) | ||
3000 | return 0; | ||
3001 | retval = idetape_queue_pc_tail(drive, &pc); | ||
3002 | if (retval) return retval; | ||
3003 | tape->door_locked = DOOR_EXPLICITLY_LOCKED; | ||
3004 | return 0; | ||
3005 | case MTUNLOCK: | ||
3006 | if (!idetape_create_prevent_cmd(drive, &pc, 0)) | ||
3007 | return 0; | ||
3008 | retval = idetape_queue_pc_tail(drive, &pc); | ||
3009 | if (retval) return retval; | ||
3010 | tape->door_locked = DOOR_UNLOCKED; | ||
3011 | return 0; | 3105 | return 0; |
3012 | default: | 3106 | retval = idetape_queue_pc_tail(drive, &pc); |
3013 | printk(KERN_ERR "ide-tape: MTIO operation %d not " | 3107 | if (retval) |
3014 | "supported\n", mt_op); | 3108 | return retval; |
3015 | return (-EIO); | 3109 | tape->door_locked = DOOR_UNLOCKED; |
3110 | return 0; | ||
3111 | default: | ||
3112 | printk(KERN_ERR "ide-tape: MTIO operation %d not supported\n", | ||
3113 | mt_op); | ||
3114 | return -EIO; | ||
3016 | } | 3115 | } |
3017 | } | 3116 | } |
3018 | 3117 | ||
@@ -3042,37 +3141,38 @@ static int idetape_chrdev_ioctl(struct inode *inode, struct file *file, | |||
3042 | if (cmd == MTIOCGET || cmd == MTIOCPOS) { | 3141 | if (cmd == MTIOCGET || cmd == MTIOCPOS) { |
3043 | block_offset = idetape_pipeline_size(drive) / | 3142 | block_offset = idetape_pipeline_size(drive) / |
3044 | (tape->blk_size * tape->user_bs_factor); | 3143 | (tape->blk_size * tape->user_bs_factor); |
3045 | if ((position = idetape_read_position(drive)) < 0) | 3144 | position = idetape_read_position(drive); |
3145 | if (position < 0) | ||
3046 | return -EIO; | 3146 | return -EIO; |
3047 | } | 3147 | } |
3048 | switch (cmd) { | 3148 | switch (cmd) { |
3049 | case MTIOCTOP: | 3149 | case MTIOCTOP: |
3050 | if (copy_from_user(&mtop, argp, sizeof (struct mtop))) | 3150 | if (copy_from_user(&mtop, argp, sizeof(struct mtop))) |
3051 | return -EFAULT; | 3151 | return -EFAULT; |
3052 | return (idetape_mtioctop(drive,mtop.mt_op,mtop.mt_count)); | 3152 | return idetape_mtioctop(drive, mtop.mt_op, mtop.mt_count); |
3053 | case MTIOCGET: | 3153 | case MTIOCGET: |
3054 | memset(&mtget, 0, sizeof (struct mtget)); | 3154 | memset(&mtget, 0, sizeof(struct mtget)); |
3055 | mtget.mt_type = MT_ISSCSI2; | 3155 | mtget.mt_type = MT_ISSCSI2; |
3056 | mtget.mt_blkno = position / tape->user_bs_factor - block_offset; | 3156 | mtget.mt_blkno = position / tape->user_bs_factor - block_offset; |
3057 | mtget.mt_dsreg = | 3157 | mtget.mt_dsreg = |
3058 | ((tape->blk_size * tape->user_bs_factor) | 3158 | ((tape->blk_size * tape->user_bs_factor) |
3059 | << MT_ST_BLKSIZE_SHIFT) & MT_ST_BLKSIZE_MASK; | 3159 | << MT_ST_BLKSIZE_SHIFT) & MT_ST_BLKSIZE_MASK; |
3060 | 3160 | ||
3061 | if (tape->drv_write_prot) { | 3161 | if (tape->drv_write_prot) |
3062 | mtget.mt_gstat |= GMT_WR_PROT(0xffffffff); | 3162 | mtget.mt_gstat |= GMT_WR_PROT(0xffffffff); |
3063 | } | 3163 | |
3064 | if (copy_to_user(argp, &mtget, sizeof(struct mtget))) | 3164 | if (copy_to_user(argp, &mtget, sizeof(struct mtget))) |
3065 | return -EFAULT; | 3165 | return -EFAULT; |
3066 | return 0; | 3166 | return 0; |
3067 | case MTIOCPOS: | 3167 | case MTIOCPOS: |
3068 | mtpos.mt_blkno = position / tape->user_bs_factor - block_offset; | 3168 | mtpos.mt_blkno = position / tape->user_bs_factor - block_offset; |
3069 | if (copy_to_user(argp, &mtpos, sizeof(struct mtpos))) | 3169 | if (copy_to_user(argp, &mtpos, sizeof(struct mtpos))) |
3070 | return -EFAULT; | 3170 | return -EFAULT; |
3071 | return 0; | 3171 | return 0; |
3072 | default: | 3172 | default: |
3073 | if (tape->chrdev_dir == IDETAPE_DIR_READ) | 3173 | if (tape->chrdev_dir == IDETAPE_DIR_READ) |
3074 | idetape_discard_read_pipeline(drive, 1); | 3174 | idetape_discard_read_pipeline(drive, 1); |
3075 | return idetape_blkdev_ioctl(drive, cmd, arg); | 3175 | return idetape_blkdev_ioctl(drive, cmd, arg); |
3076 | } | 3176 | } |
3077 | } | 3177 | } |
3078 | 3178 | ||
@@ -3101,7 +3201,7 @@ static void ide_tape_get_bsize_from_bdesc(ide_drive_t *drive) | |||
3101 | tape->drv_write_prot = (pc.buffer[2] & 0x80) >> 7; | 3201 | tape->drv_write_prot = (pc.buffer[2] & 0x80) >> 7; |
3102 | } | 3202 | } |
3103 | 3203 | ||
3104 | static int idetape_chrdev_open (struct inode *inode, struct file *filp) | 3204 | static int idetape_chrdev_open(struct inode *inode, struct file *filp) |
3105 | { | 3205 | { |
3106 | unsigned int minor = iminor(inode), i = minor & ~0xc0; | 3206 | unsigned int minor = iminor(inode), i = minor & ~0xc0; |
3107 | ide_drive_t *drive; | 3207 | ide_drive_t *drive; |
@@ -3185,7 +3285,7 @@ out_put_tape: | |||
3185 | return retval; | 3285 | return retval; |
3186 | } | 3286 | } |
3187 | 3287 | ||
3188 | static void idetape_write_release (ide_drive_t *drive, unsigned int minor) | 3288 | static void idetape_write_release(ide_drive_t *drive, unsigned int minor) |
3189 | { | 3289 | { |
3190 | idetape_tape_t *tape = drive->driver_data; | 3290 | idetape_tape_t *tape = drive->driver_data; |
3191 | 3291 | ||
@@ -3202,7 +3302,7 @@ static void idetape_write_release (ide_drive_t *drive, unsigned int minor) | |||
3202 | idetape_flush_tape_buffers(drive); | 3302 | idetape_flush_tape_buffers(drive); |
3203 | } | 3303 | } |
3204 | 3304 | ||
3205 | static int idetape_chrdev_release (struct inode *inode, struct file *filp) | 3305 | static int idetape_chrdev_release(struct inode *inode, struct file *filp) |
3206 | { | 3306 | { |
3207 | struct ide_tape_obj *tape = ide_tape_f(filp); | 3307 | struct ide_tape_obj *tape = ide_tape_f(filp); |
3208 | ide_drive_t *drive = tape->drive; | 3308 | ide_drive_t *drive = tape->drive; |
@@ -3309,7 +3409,7 @@ static void idetape_get_inquiry_results(ide_drive_t *drive) | |||
3309 | * Ask the tape about its various parameters. In particular, we will adjust our | 3409 | * Ask the tape about its various parameters. In particular, we will adjust our |
3310 | * data transfer buffer size to the recommended value as returned by the tape. | 3410 | * data transfer buffer size to the recommended value as returned by the tape. |
3311 | */ | 3411 | */ |
3312 | static void idetape_get_mode_sense_results (ide_drive_t *drive) | 3412 | static void idetape_get_mode_sense_results(ide_drive_t *drive) |
3313 | { | 3413 | { |
3314 | idetape_tape_t *tape = drive->driver_data; | 3414 | idetape_tape_t *tape = drive->driver_data; |
3315 | idetape_pc_t pc; | 3415 | idetape_pc_t pc; |
@@ -3356,17 +3456,24 @@ static void idetape_get_mode_sense_results (ide_drive_t *drive) | |||
3356 | } | 3456 | } |
3357 | 3457 | ||
3358 | #ifdef CONFIG_IDE_PROC_FS | 3458 | #ifdef CONFIG_IDE_PROC_FS |
3359 | static void idetape_add_settings (ide_drive_t *drive) | 3459 | static void idetape_add_settings(ide_drive_t *drive) |
3360 | { | 3460 | { |
3361 | idetape_tape_t *tape = drive->driver_data; | 3461 | idetape_tape_t *tape = drive->driver_data; |
3362 | 3462 | ||
3363 | ide_add_setting(drive, "buffer", SETTING_READ, TYPE_SHORT, 0, 0xffff, | 3463 | ide_add_setting(drive, "buffer", SETTING_READ, TYPE_SHORT, 0, 0xffff, |
3364 | 1, 2, (u16 *)&tape->caps[16], NULL); | 3464 | 1, 2, (u16 *)&tape->caps[16], NULL); |
3365 | ide_add_setting(drive, "pipeline_min", SETTING_RW, TYPE_INT, 1, 0xffff, tape->stage_size / 1024, 1, &tape->min_pipeline, NULL); | 3465 | ide_add_setting(drive, "pipeline_min", SETTING_RW, TYPE_INT, 1, 0xffff, |
3366 | ide_add_setting(drive, "pipeline", SETTING_RW, TYPE_INT, 1, 0xffff, tape->stage_size / 1024, 1, &tape->max_stages, NULL); | 3466 | tape->stage_size / 1024, 1, &tape->min_pipeline, NULL); |
3367 | ide_add_setting(drive, "pipeline_max", SETTING_RW, TYPE_INT, 1, 0xffff, tape->stage_size / 1024, 1, &tape->max_pipeline, NULL); | 3467 | ide_add_setting(drive, "pipeline", SETTING_RW, TYPE_INT, 1, 0xffff, |
3368 | ide_add_setting(drive, "pipeline_used", SETTING_READ, TYPE_INT, 0, 0xffff, tape->stage_size / 1024, 1, &tape->nr_stages, NULL); | 3468 | tape->stage_size / 1024, 1, &tape->max_stages, NULL); |
3369 | ide_add_setting(drive, "pipeline_pending", SETTING_READ, TYPE_INT, 0, 0xffff, tape->stage_size / 1024, 1, &tape->nr_pending_stages, NULL); | 3469 | ide_add_setting(drive, "pipeline_max", SETTING_RW, TYPE_INT, 1, 0xffff, |
3470 | tape->stage_size / 1024, 1, &tape->max_pipeline, NULL); | ||
3471 | ide_add_setting(drive, "pipeline_used", SETTING_READ, TYPE_INT, 0, | ||
3472 | 0xffff, tape->stage_size / 1024, 1, &tape->nr_stages, | ||
3473 | NULL); | ||
3474 | ide_add_setting(drive, "pipeline_pending", SETTING_READ, TYPE_INT, 0, | ||
3475 | 0xffff, tape->stage_size / 1024, 1, | ||
3476 | &tape->nr_pending_stages, NULL); | ||
3370 | ide_add_setting(drive, "speed", SETTING_READ, TYPE_SHORT, 0, 0xffff, | 3477 | ide_add_setting(drive, "speed", SETTING_READ, TYPE_SHORT, 0, 0xffff, |
3371 | 1, 1, (u16 *)&tape->caps[14], NULL); | 3478 | 1, 1, (u16 *)&tape->caps[14], NULL); |
3372 | ide_add_setting(drive, "stage", SETTING_READ, TYPE_INT, 0, 0xffff, 1, | 3479 | ide_add_setting(drive, "stage", SETTING_READ, TYPE_INT, 0, 0xffff, 1, |
@@ -3374,10 +3481,16 @@ static void idetape_add_settings (ide_drive_t *drive) | |||
3374 | ide_add_setting(drive, "tdsc", SETTING_RW, TYPE_INT, IDETAPE_DSC_RW_MIN, | 3481 | ide_add_setting(drive, "tdsc", SETTING_RW, TYPE_INT, IDETAPE_DSC_RW_MIN, |
3375 | IDETAPE_DSC_RW_MAX, 1000, HZ, &tape->best_dsc_rw_freq, | 3482 | IDETAPE_DSC_RW_MAX, 1000, HZ, &tape->best_dsc_rw_freq, |
3376 | NULL); | 3483 | NULL); |
3377 | ide_add_setting(drive, "dsc_overlap", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, &drive->dsc_overlap, NULL); | 3484 | ide_add_setting(drive, "dsc_overlap", SETTING_RW, TYPE_BYTE, 0, 1, 1, |
3378 | ide_add_setting(drive, "pipeline_head_speed_c",SETTING_READ, TYPE_INT, 0, 0xffff, 1, 1, &tape->controlled_pipeline_head_speed, NULL); | 3485 | 1, &drive->dsc_overlap, NULL); |
3379 | ide_add_setting(drive, "pipeline_head_speed_u",SETTING_READ, TYPE_INT, 0, 0xffff, 1, 1, &tape->uncontrolled_pipeline_head_speed,NULL); | 3486 | ide_add_setting(drive, "pipeline_head_speed_c", SETTING_READ, TYPE_INT, |
3380 | ide_add_setting(drive, "avg_speed", SETTING_READ, TYPE_INT, 0, 0xffff, 1, 1, &tape->avg_speed, NULL); | 3487 | 0, 0xffff, 1, 1, &tape->controlled_pipeline_head_speed, |
3488 | NULL); | ||
3489 | ide_add_setting(drive, "pipeline_head_speed_u", SETTING_READ, TYPE_INT, | ||
3490 | 0, 0xffff, 1, 1, | ||
3491 | &tape->uncontrolled_pipeline_head_speed, NULL); | ||
3492 | ide_add_setting(drive, "avg_speed", SETTING_READ, TYPE_INT, 0, 0xffff, | ||
3493 | 1, 1, &tape->avg_speed, NULL); | ||
3381 | ide_add_setting(drive, "debug_mask", SETTING_RW, TYPE_INT, 0, 0xffff, 1, | 3494 | ide_add_setting(drive, "debug_mask", SETTING_RW, TYPE_INT, 0, 0xffff, 1, |
3382 | 1, &tape->debug_mask, NULL); | 3495 | 1, &tape->debug_mask, NULL); |
3383 | } | 3496 | } |
@@ -3396,7 +3509,7 @@ static inline void idetape_add_settings(ide_drive_t *drive) { ; } | |||
3396 | * Note that at this point ide.c already assigned us an irq, so that we can | 3509 | * Note that at this point ide.c already assigned us an irq, so that we can |
3397 | * queue requests here and wait for their completion. | 3510 | * queue requests here and wait for their completion. |
3398 | */ | 3511 | */ |
3399 | static void idetape_setup (ide_drive_t *drive, idetape_tape_t *tape, int minor) | 3512 | static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor) |
3400 | { | 3513 | { |
3401 | unsigned long t1, tmid, tn, t; | 3514 | unsigned long t1, tmid, tn, t; |
3402 | int speed; | 3515 | int speed; |
@@ -3429,7 +3542,9 @@ static void idetape_setup (ide_drive_t *drive, idetape_tape_t *tape, int minor) | |||
3429 | if (((gcw[0] & 0x60) >> 5) == 1) | 3542 | if (((gcw[0] & 0x60) >> 5) == 1) |
3430 | set_bit(IDETAPE_DRQ_INTERRUPT, &tape->flags); | 3543 | set_bit(IDETAPE_DRQ_INTERRUPT, &tape->flags); |
3431 | 3544 | ||
3432 | tape->min_pipeline = tape->max_pipeline = tape->max_stages = 10; | 3545 | tape->min_pipeline = 10; |
3546 | tape->max_pipeline = 10; | ||
3547 | tape->max_stages = 10; | ||
3433 | 3548 | ||
3434 | idetape_get_inquiry_results(drive); | 3549 | idetape_get_inquiry_results(drive); |
3435 | idetape_get_mode_sense_results(drive); | 3550 | idetape_get_mode_sense_results(drive); |
@@ -3455,13 +3570,20 @@ static void idetape_setup (ide_drive_t *drive, idetape_tape_t *tape, int minor) | |||
3455 | 3570 | ||
3456 | /* Limit memory use for pipeline to 10% of physical memory */ | 3571 | /* Limit memory use for pipeline to 10% of physical memory */ |
3457 | si_meminfo(&si); | 3572 | si_meminfo(&si); |
3458 | if (tape->max_stages * tape->stage_size > si.totalram * si.mem_unit / 10) | 3573 | if (tape->max_stages * tape->stage_size > |
3459 | tape->max_stages = si.totalram * si.mem_unit / (10 * tape->stage_size); | 3574 | si.totalram * si.mem_unit / 10) |
3575 | tape->max_stages = | ||
3576 | si.totalram * si.mem_unit / (10 * tape->stage_size); | ||
3577 | |||
3460 | tape->max_stages = min(tape->max_stages, IDETAPE_MAX_PIPELINE_STAGES); | 3578 | tape->max_stages = min(tape->max_stages, IDETAPE_MAX_PIPELINE_STAGES); |
3461 | tape->min_pipeline = min(tape->max_stages, IDETAPE_MIN_PIPELINE_STAGES); | 3579 | tape->min_pipeline = min(tape->max_stages, IDETAPE_MIN_PIPELINE_STAGES); |
3462 | tape->max_pipeline = min(tape->max_stages * 2, IDETAPE_MAX_PIPELINE_STAGES); | 3580 | tape->max_pipeline = |
3463 | if (tape->max_stages == 0) | 3581 | min(tape->max_stages * 2, IDETAPE_MAX_PIPELINE_STAGES); |
3464 | tape->max_stages = tape->min_pipeline = tape->max_pipeline = 1; | 3582 | if (tape->max_stages == 0) { |
3583 | tape->max_stages = 1; | ||
3584 | tape->min_pipeline = 1; | ||
3585 | tape->max_pipeline = 1; | ||
3586 | } | ||
3465 | 3587 | ||
3466 | t1 = (tape->stage_size * HZ) / (speed * 1000); | 3588 | t1 = (tape->stage_size * HZ) / (speed * 1000); |
3467 | tmid = (*(u16 *)&tape->caps[16] * 32 * HZ) / (speed * 125); | 3589 | tmid = (*(u16 *)&tape->caps[16] * 32 * HZ) / (speed * 125); |
@@ -3513,7 +3635,8 @@ static void ide_tape_release(struct kref *kref) | |||
3513 | drive->dsc_overlap = 0; | 3635 | drive->dsc_overlap = 0; |
3514 | drive->driver_data = NULL; | 3636 | drive->driver_data = NULL; |
3515 | device_destroy(idetape_sysfs_class, MKDEV(IDETAPE_MAJOR, tape->minor)); | 3637 | device_destroy(idetape_sysfs_class, MKDEV(IDETAPE_MAJOR, tape->minor)); |
3516 | device_destroy(idetape_sysfs_class, MKDEV(IDETAPE_MAJOR, tape->minor + 128)); | 3638 | device_destroy(idetape_sysfs_class, |
3639 | MKDEV(IDETAPE_MAJOR, tape->minor + 128)); | ||
3517 | idetape_devs[tape->minor] = NULL; | 3640 | idetape_devs[tape->minor] = NULL; |
3518 | g->private_data = NULL; | 3641 | g->private_data = NULL; |
3519 | put_disk(g); | 3642 | put_disk(g); |
@@ -3577,7 +3700,8 @@ static int idetape_open(struct inode *inode, struct file *filp) | |||
3577 | struct gendisk *disk = inode->i_bdev->bd_disk; | 3700 | struct gendisk *disk = inode->i_bdev->bd_disk; |
3578 | struct ide_tape_obj *tape; | 3701 | struct ide_tape_obj *tape; |
3579 | 3702 | ||
3580 | if (!(tape = ide_tape_get(disk))) | 3703 | tape = ide_tape_get(disk); |
3704 | if (!tape) | ||
3581 | return -ENXIO; | 3705 | return -ENXIO; |
3582 | 3706 | ||
3583 | return 0; | 3707 | return 0; |
@@ -3624,17 +3748,20 @@ static int ide_tape_probe(ide_drive_t *drive) | |||
3624 | goto failed; | 3748 | goto failed; |
3625 | if (drive->media != ide_tape) | 3749 | if (drive->media != ide_tape) |
3626 | goto failed; | 3750 | goto failed; |
3627 | if (!idetape_identify_device (drive)) { | 3751 | if (!idetape_identify_device(drive)) { |
3628 | printk(KERN_ERR "ide-tape: %s: not supported by this version of ide-tape\n", drive->name); | 3752 | printk(KERN_ERR "ide-tape: %s: not supported by this version of" |
3753 | " the driver\n", drive->name); | ||
3629 | goto failed; | 3754 | goto failed; |
3630 | } | 3755 | } |
3631 | if (drive->scsi) { | 3756 | if (drive->scsi) { |
3632 | printk("ide-tape: passing drive %s to ide-scsi emulation.\n", drive->name); | 3757 | printk(KERN_INFO "ide-tape: passing drive %s to ide-scsi" |
3758 | " emulation.\n", drive->name); | ||
3633 | goto failed; | 3759 | goto failed; |
3634 | } | 3760 | } |
3635 | tape = kzalloc(sizeof (idetape_tape_t), GFP_KERNEL); | 3761 | tape = kzalloc(sizeof(idetape_tape_t), GFP_KERNEL); |
3636 | if (tape == NULL) { | 3762 | if (tape == NULL) { |
3637 | printk(KERN_ERR "ide-tape: %s: Can't allocate a tape structure\n", drive->name); | 3763 | printk(KERN_ERR "ide-tape: %s: Can't allocate a tape struct\n", |
3764 | drive->name); | ||
3638 | goto failed; | 3765 | goto failed; |
3639 | } | 3766 | } |
3640 | 3767 | ||
@@ -3680,7 +3807,7 @@ failed: | |||
3680 | return -ENODEV; | 3807 | return -ENODEV; |
3681 | } | 3808 | } |
3682 | 3809 | ||
3683 | static void __exit idetape_exit (void) | 3810 | static void __exit idetape_exit(void) |
3684 | { | 3811 | { |
3685 | driver_unregister(&idetape_driver.gen_driver); | 3812 | driver_unregister(&idetape_driver.gen_driver); |
3686 | class_destroy(idetape_sysfs_class); | 3813 | class_destroy(idetape_sysfs_class); |
@@ -3699,7 +3826,8 @@ static int __init idetape_init(void) | |||
3699 | } | 3826 | } |
3700 | 3827 | ||
3701 | if (register_chrdev(IDETAPE_MAJOR, "ht", &idetape_fops)) { | 3828 | if (register_chrdev(IDETAPE_MAJOR, "ht", &idetape_fops)) { |
3702 | printk(KERN_ERR "ide-tape: Failed to register character device interface\n"); | 3829 | printk(KERN_ERR "ide-tape: Failed to register chrdev" |
3830 | " interface\n"); | ||
3703 | error = -EBUSY; | 3831 | error = -EBUSY; |
3704 | goto out_free_class; | 3832 | goto out_free_class; |
3705 | } | 3833 | } |