diff options
Diffstat (limited to 'drivers/ide/ide-tape.c')
| -rw-r--r-- | drivers/ide/ide-tape.c | 186 |
1 files changed, 85 insertions, 101 deletions
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 4b447a8a49d4..013dc595fab6 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
| @@ -279,10 +279,12 @@ static void ide_tape_put(struct ide_tape_obj *tape) | |||
| 279 | * called on each failed packet command retry to analyze the request sense. We | 279 | * called on each failed packet command retry to analyze the request sense. We |
| 280 | * currently do not utilize this information. | 280 | * currently do not utilize this information. |
| 281 | */ | 281 | */ |
| 282 | static void idetape_analyze_error(ide_drive_t *drive, u8 *sense) | 282 | static void idetape_analyze_error(ide_drive_t *drive) |
| 283 | { | 283 | { |
| 284 | idetape_tape_t *tape = drive->driver_data; | 284 | idetape_tape_t *tape = drive->driver_data; |
| 285 | struct ide_atapi_pc *pc = drive->failed_pc; | 285 | struct ide_atapi_pc *pc = drive->failed_pc; |
| 286 | struct request *rq = drive->hwif->rq; | ||
| 287 | u8 *sense = bio_data(rq->bio); | ||
| 286 | 288 | ||
| 287 | tape->sense_key = sense[2] & 0xF; | 289 | tape->sense_key = sense[2] & 0xF; |
| 288 | tape->asc = sense[12]; | 290 | tape->asc = sense[12]; |
| @@ -291,11 +293,9 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 *sense) | |||
| 291 | debug_log(DBG_ERR, "pc = %x, sense key = %x, asc = %x, ascq = %x\n", | 293 | debug_log(DBG_ERR, "pc = %x, sense key = %x, asc = %x, ascq = %x\n", |
| 292 | pc->c[0], tape->sense_key, tape->asc, tape->ascq); | 294 | pc->c[0], tape->sense_key, tape->asc, tape->ascq); |
| 293 | 295 | ||
| 294 | /* Correct pc->xferred by asking the tape. */ | 296 | /* correct remaining bytes to transfer */ |
| 295 | if (pc->flags & PC_FLAG_DMA_ERROR) | 297 | if (pc->flags & PC_FLAG_DMA_ERROR) |
| 296 | pc->xferred = pc->req_xfer - | 298 | rq->resid_len = tape->blk_size * get_unaligned_be32(&sense[3]); |
| 297 | tape->blk_size * | ||
| 298 | get_unaligned_be32(&sense[3]); | ||
| 299 | 299 | ||
| 300 | /* | 300 | /* |
| 301 | * If error was the result of a zero-length read or write command, | 301 | * If error was the result of a zero-length read or write command, |
| @@ -329,7 +329,7 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 *sense) | |||
| 329 | pc->flags |= PC_FLAG_ABORT; | 329 | pc->flags |= PC_FLAG_ABORT; |
| 330 | } | 330 | } |
| 331 | if (!(pc->flags & PC_FLAG_ABORT) && | 331 | if (!(pc->flags & PC_FLAG_ABORT) && |
| 332 | pc->xferred) | 332 | (blk_rq_bytes(rq) - rq->resid_len)) |
| 333 | pc->retries = IDETAPE_MAX_PC_RETRIES + 1; | 333 | pc->retries = IDETAPE_MAX_PC_RETRIES + 1; |
| 334 | } | 334 | } |
| 335 | } | 335 | } |
| @@ -354,12 +354,13 @@ static int ide_tape_callback(ide_drive_t *drive, int dsc) | |||
| 354 | 354 | ||
| 355 | if (pc->c[0] == REQUEST_SENSE) { | 355 | if (pc->c[0] == REQUEST_SENSE) { |
| 356 | if (uptodate) | 356 | if (uptodate) |
| 357 | idetape_analyze_error(drive, pc->buf); | 357 | idetape_analyze_error(drive); |
| 358 | else | 358 | else |
| 359 | printk(KERN_ERR "ide-tape: Error in REQUEST SENSE " | 359 | printk(KERN_ERR "ide-tape: Error in REQUEST SENSE " |
| 360 | "itself - Aborting request!\n"); | 360 | "itself - Aborting request!\n"); |
| 361 | } else if (pc->c[0] == READ_6 || pc->c[0] == WRITE_6) { | 361 | } else if (pc->c[0] == READ_6 || pc->c[0] == WRITE_6) { |
| 362 | int blocks = pc->xferred / tape->blk_size; | 362 | unsigned int blocks = |
| 363 | (blk_rq_bytes(rq) - rq->resid_len) / tape->blk_size; | ||
| 363 | 364 | ||
| 364 | tape->avg_size += blocks * tape->blk_size; | 365 | tape->avg_size += blocks * tape->blk_size; |
| 365 | 366 | ||
| @@ -371,38 +372,12 @@ static int ide_tape_callback(ide_drive_t *drive, int dsc) | |||
| 371 | } | 372 | } |
| 372 | 373 | ||
| 373 | tape->first_frame += blocks; | 374 | tape->first_frame += blocks; |
| 374 | rq->resid_len -= blocks * tape->blk_size; | ||
| 375 | 375 | ||
| 376 | if (pc->error) { | 376 | if (pc->error) { |
| 377 | uptodate = 0; | 377 | uptodate = 0; |
| 378 | err = pc->error; | 378 | err = pc->error; |
| 379 | } | 379 | } |
| 380 | } else if (pc->c[0] == READ_POSITION && uptodate) { | ||
| 381 | u8 *readpos = pc->buf; | ||
| 382 | |||
| 383 | debug_log(DBG_SENSE, "BOP - %s\n", | ||
| 384 | (readpos[0] & 0x80) ? "Yes" : "No"); | ||
| 385 | debug_log(DBG_SENSE, "EOP - %s\n", | ||
| 386 | (readpos[0] & 0x40) ? "Yes" : "No"); | ||
| 387 | |||
| 388 | if (readpos[0] & 0x4) { | ||
| 389 | printk(KERN_INFO "ide-tape: Block location is unknown" | ||
| 390 | "to the tape\n"); | ||
| 391 | clear_bit(ilog2(IDE_AFLAG_ADDRESS_VALID), | ||
| 392 | &drive->atapi_flags); | ||
| 393 | uptodate = 0; | ||
| 394 | err = IDE_DRV_ERROR_GENERAL; | ||
| 395 | } else { | ||
| 396 | debug_log(DBG_SENSE, "Block Location - %u\n", | ||
| 397 | be32_to_cpup((__be32 *)&readpos[4])); | ||
| 398 | |||
| 399 | tape->partition = readpos[1]; | ||
| 400 | tape->first_frame = be32_to_cpup((__be32 *)&readpos[4]); | ||
| 401 | set_bit(ilog2(IDE_AFLAG_ADDRESS_VALID), | ||
| 402 | &drive->atapi_flags); | ||
| 403 | } | ||
| 404 | } | 380 | } |
| 405 | |||
| 406 | rq->errors = err; | 381 | rq->errors = err; |
| 407 | 382 | ||
| 408 | return uptodate; | 383 | return uptodate; |
| @@ -477,6 +452,7 @@ static ide_startstop_t ide_tape_issue_pc(ide_drive_t *drive, | |||
| 477 | struct ide_atapi_pc *pc) | 452 | struct ide_atapi_pc *pc) |
| 478 | { | 453 | { |
| 479 | idetape_tape_t *tape = drive->driver_data; | 454 | idetape_tape_t *tape = drive->driver_data; |
| 455 | struct request *rq = drive->hwif->rq; | ||
| 480 | 456 | ||
| 481 | if (drive->failed_pc == NULL && pc->c[0] != REQUEST_SENSE) | 457 | if (drive->failed_pc == NULL && pc->c[0] != REQUEST_SENSE) |
| 482 | drive->failed_pc = pc; | 458 | drive->failed_pc = pc; |
| @@ -486,7 +462,6 @@ static ide_startstop_t ide_tape_issue_pc(ide_drive_t *drive, | |||
| 486 | 462 | ||
| 487 | if (pc->retries > IDETAPE_MAX_PC_RETRIES || | 463 | if (pc->retries > IDETAPE_MAX_PC_RETRIES || |
| 488 | (pc->flags & PC_FLAG_ABORT)) { | 464 | (pc->flags & PC_FLAG_ABORT)) { |
| 489 | unsigned int done = blk_rq_bytes(drive->hwif->rq); | ||
| 490 | 465 | ||
| 491 | /* | 466 | /* |
| 492 | * We will "abort" retrying a packet command in case legitimate | 467 | * We will "abort" retrying a packet command in case legitimate |
| @@ -510,7 +485,7 @@ static ide_startstop_t ide_tape_issue_pc(ide_drive_t *drive, | |||
| 510 | 485 | ||
| 511 | drive->failed_pc = NULL; | 486 | drive->failed_pc = NULL; |
| 512 | drive->pc_callback(drive, 0); | 487 | drive->pc_callback(drive, 0); |
| 513 | ide_complete_rq(drive, -EIO, done); | 488 | ide_complete_rq(drive, -EIO, blk_rq_bytes(rq)); |
| 514 | return ide_stopped; | 489 | return ide_stopped; |
| 515 | } | 490 | } |
| 516 | debug_log(DBG_SENSE, "Retry #%d, cmd = %02X\n", pc->retries, pc->c[0]); | 491 | debug_log(DBG_SENSE, "Retry #%d, cmd = %02X\n", pc->retries, pc->c[0]); |
| @@ -579,15 +554,13 @@ static void ide_tape_create_rw_cmd(idetape_tape_t *tape, | |||
| 579 | struct ide_atapi_pc *pc, struct request *rq, | 554 | struct ide_atapi_pc *pc, struct request *rq, |
| 580 | u8 opcode) | 555 | u8 opcode) |
| 581 | { | 556 | { |
| 582 | unsigned int length = blk_rq_sectors(rq); | 557 | unsigned int length = blk_rq_sectors(rq) / (tape->blk_size >> 9); |
| 583 | 558 | ||
| 584 | ide_init_pc(pc); | 559 | ide_init_pc(pc); |
| 585 | put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]); | 560 | put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]); |
| 586 | pc->c[1] = 1; | 561 | pc->c[1] = 1; |
| 587 | pc->buf = NULL; | 562 | |
| 588 | pc->buf_size = length * tape->blk_size; | 563 | if (blk_rq_bytes(rq) == tape->buffer_size) |
| 589 | pc->req_xfer = pc->buf_size; | ||
| 590 | if (pc->req_xfer == tape->buffer_size) | ||
| 591 | pc->flags |= PC_FLAG_DMA_OK; | 564 | pc->flags |= PC_FLAG_DMA_OK; |
| 592 | 565 | ||
| 593 | if (opcode == READ_6) | 566 | if (opcode == READ_6) |
| @@ -613,15 +586,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
| 613 | debug_log(DBG_SENSE, "sector: %llu, nr_sectors: %u\n" | 586 | debug_log(DBG_SENSE, "sector: %llu, nr_sectors: %u\n" |
| 614 | (unsigned long long)blk_rq_pos(rq), blk_rq_sectors(rq)); | 587 | (unsigned long long)blk_rq_pos(rq), blk_rq_sectors(rq)); |
| 615 | 588 | ||
| 616 | if (!(blk_special_request(rq) || blk_sense_request(rq))) { | 589 | BUG_ON(!(blk_special_request(rq) || blk_sense_request(rq))); |
| 617 | /* We do not support buffer cache originated requests. */ | ||
| 618 | printk(KERN_NOTICE "ide-tape: %s: Unsupported request in " | ||
| 619 | "request queue (%d)\n", drive->name, rq->cmd_type); | ||
| 620 | if (blk_fs_request(rq) == 0 && rq->errors == 0) | ||
| 621 | rq->errors = -EIO; | ||
| 622 | ide_complete_rq(drive, -EIO, ide_rq_bytes(rq)); | ||
| 623 | return ide_stopped; | ||
| 624 | } | ||
| 625 | 590 | ||
| 626 | /* Retry a failed packet command */ | 591 | /* Retry a failed packet command */ |
| 627 | if (drive->failed_pc && drive->pc->c[0] == REQUEST_SENSE) { | 592 | if (drive->failed_pc && drive->pc->c[0] == REQUEST_SENSE) { |
| @@ -713,7 +678,7 @@ out: | |||
| 713 | 678 | ||
| 714 | cmd.rq = rq; | 679 | cmd.rq = rq; |
| 715 | 680 | ||
| 716 | ide_init_sg_cmd(&cmd, pc->req_xfer); | 681 | ide_init_sg_cmd(&cmd, blk_rq_bytes(rq)); |
| 717 | ide_map_sg(drive, &cmd); | 682 | ide_map_sg(drive, &cmd); |
| 718 | 683 | ||
| 719 | return ide_tape_issue_pc(drive, &cmd, pc); | 684 | return ide_tape_issue_pc(drive, &cmd, pc); |
| @@ -767,33 +732,53 @@ static int idetape_flush_tape_buffers(ide_drive_t *drive) | |||
| 767 | int rc; | 732 | int rc; |
| 768 | 733 | ||
| 769 | idetape_create_write_filemark_cmd(drive, &pc, 0); | 734 | idetape_create_write_filemark_cmd(drive, &pc, 0); |
| 770 | rc = ide_queue_pc_tail(drive, tape->disk, &pc); | 735 | rc = ide_queue_pc_tail(drive, tape->disk, &pc, NULL, 0); |
| 771 | if (rc) | 736 | if (rc) |
| 772 | return rc; | 737 | return rc; |
| 773 | idetape_wait_ready(drive, 60 * 5 * HZ); | 738 | idetape_wait_ready(drive, 60 * 5 * HZ); |
| 774 | return 0; | 739 | return 0; |
| 775 | } | 740 | } |
| 776 | 741 | ||
| 777 | static void idetape_create_read_position_cmd(struct ide_atapi_pc *pc) | 742 | static int ide_tape_read_position(ide_drive_t *drive) |
| 778 | { | ||
| 779 | ide_init_pc(pc); | ||
| 780 | pc->c[0] = READ_POSITION; | ||
| 781 | pc->req_xfer = 20; | ||
| 782 | } | ||
| 783 | |||
| 784 | static int idetape_read_position(ide_drive_t *drive) | ||
| 785 | { | 743 | { |
| 786 | idetape_tape_t *tape = drive->driver_data; | 744 | idetape_tape_t *tape = drive->driver_data; |
| 787 | struct ide_atapi_pc pc; | 745 | struct ide_atapi_pc pc; |
| 788 | int position; | 746 | u8 buf[20]; |
| 789 | 747 | ||
| 790 | debug_log(DBG_PROCS, "Enter %s\n", __func__); | 748 | debug_log(DBG_PROCS, "Enter %s\n", __func__); |
| 791 | 749 | ||
| 792 | idetape_create_read_position_cmd(&pc); | 750 | /* prep cmd */ |
| 793 | if (ide_queue_pc_tail(drive, tape->disk, &pc)) | 751 | ide_init_pc(&pc); |
| 752 | pc.c[0] = READ_POSITION; | ||
| 753 | pc.req_xfer = 20; | ||
| 754 | |||
| 755 | if (ide_queue_pc_tail(drive, tape->disk, &pc, buf, pc.req_xfer)) | ||
| 794 | return -1; | 756 | return -1; |
| 795 | position = tape->first_frame; | 757 | |
| 796 | return position; | 758 | if (!pc.error) { |
| 759 | debug_log(DBG_SENSE, "BOP - %s\n", | ||
| 760 | (buf[0] & 0x80) ? "Yes" : "No"); | ||
| 761 | debug_log(DBG_SENSE, "EOP - %s\n", | ||
| 762 | (buf[0] & 0x40) ? "Yes" : "No"); | ||
| 763 | |||
| 764 | if (buf[0] & 0x4) { | ||
| 765 | printk(KERN_INFO "ide-tape: Block location is unknown" | ||
| 766 | "to the tape\n"); | ||
| 767 | clear_bit(ilog2(IDE_AFLAG_ADDRESS_VALID), | ||
| 768 | &drive->atapi_flags); | ||
| 769 | return -1; | ||
| 770 | } else { | ||
| 771 | debug_log(DBG_SENSE, "Block Location - %u\n", | ||
| 772 | be32_to_cpup((__be32 *)&buf[4])); | ||
| 773 | |||
| 774 | tape->partition = buf[1]; | ||
| 775 | tape->first_frame = be32_to_cpup((__be32 *)&buf[4]); | ||
| 776 | set_bit(ilog2(IDE_AFLAG_ADDRESS_VALID), | ||
| 777 | &drive->atapi_flags); | ||
| 778 | } | ||
| 779 | } | ||
| 780 | |||
| 781 | return tape->first_frame; | ||
| 797 | } | 782 | } |
| 798 | 783 | ||
| 799 | static void idetape_create_locate_cmd(ide_drive_t *drive, | 784 | static void idetape_create_locate_cmd(ide_drive_t *drive, |
| @@ -836,19 +821,21 @@ static int idetape_position_tape(ide_drive_t *drive, unsigned int block, | |||
| 836 | { | 821 | { |
| 837 | idetape_tape_t *tape = drive->driver_data; | 822 | idetape_tape_t *tape = drive->driver_data; |
| 838 | struct gendisk *disk = tape->disk; | 823 | struct gendisk *disk = tape->disk; |
| 839 | int retval; | 824 | int ret; |
| 840 | struct ide_atapi_pc pc; | 825 | struct ide_atapi_pc pc; |
| 841 | 826 | ||
| 842 | if (tape->chrdev_dir == IDETAPE_DIR_READ) | 827 | if (tape->chrdev_dir == IDETAPE_DIR_READ) |
| 843 | __ide_tape_discard_merge_buffer(drive); | 828 | __ide_tape_discard_merge_buffer(drive); |
| 844 | idetape_wait_ready(drive, 60 * 5 * HZ); | 829 | idetape_wait_ready(drive, 60 * 5 * HZ); |
| 845 | idetape_create_locate_cmd(drive, &pc, block, partition, skip); | 830 | idetape_create_locate_cmd(drive, &pc, block, partition, skip); |
| 846 | retval = ide_queue_pc_tail(drive, disk, &pc); | 831 | ret = ide_queue_pc_tail(drive, disk, &pc, NULL, 0); |
| 847 | if (retval) | 832 | if (ret) |
| 848 | return (retval); | 833 | return ret; |
| 849 | 834 | ||
| 850 | idetape_create_read_position_cmd(&pc); | 835 | ret = ide_tape_read_position(drive); |
| 851 | return ide_queue_pc_tail(drive, disk, &pc); | 836 | if (ret < 0) |
| 837 | return ret; | ||
| 838 | return 0; | ||
| 852 | } | 839 | } |
| 853 | 840 | ||
| 854 | static void ide_tape_discard_merge_buffer(ide_drive_t *drive, | 841 | static void ide_tape_discard_merge_buffer(ide_drive_t *drive, |
| @@ -859,7 +846,7 @@ static void ide_tape_discard_merge_buffer(ide_drive_t *drive, | |||
| 859 | 846 | ||
| 860 | __ide_tape_discard_merge_buffer(drive); | 847 | __ide_tape_discard_merge_buffer(drive); |
| 861 | if (restore_position) { | 848 | if (restore_position) { |
| 862 | position = idetape_read_position(drive); | 849 | position = ide_tape_read_position(drive); |
| 863 | seek = position > 0 ? position : 0; | 850 | seek = position > 0 ? position : 0; |
| 864 | if (idetape_position_tape(drive, seek, 0, 0)) { | 851 | if (idetape_position_tape(drive, seek, 0, 0)) { |
| 865 | printk(KERN_INFO "ide-tape: %s: position_tape failed in" | 852 | printk(KERN_INFO "ide-tape: %s: position_tape failed in" |
| @@ -1039,20 +1026,19 @@ static int idetape_rewind_tape(ide_drive_t *drive) | |||
| 1039 | { | 1026 | { |
| 1040 | struct ide_tape_obj *tape = drive->driver_data; | 1027 | struct ide_tape_obj *tape = drive->driver_data; |
| 1041 | struct gendisk *disk = tape->disk; | 1028 | struct gendisk *disk = tape->disk; |
| 1042 | int retval; | ||
| 1043 | struct ide_atapi_pc pc; | 1029 | struct ide_atapi_pc pc; |
| 1030 | int ret; | ||
| 1044 | 1031 | ||
| 1045 | debug_log(DBG_SENSE, "Enter %s\n", __func__); | 1032 | debug_log(DBG_SENSE, "Enter %s\n", __func__); |
| 1046 | 1033 | ||
| 1047 | idetape_create_rewind_cmd(drive, &pc); | 1034 | idetape_create_rewind_cmd(drive, &pc); |
| 1048 | retval = ide_queue_pc_tail(drive, disk, &pc); | 1035 | ret = ide_queue_pc_tail(drive, disk, &pc, NULL, 0); |
| 1049 | if (retval) | 1036 | if (ret) |
| 1050 | return retval; | 1037 | return ret; |
| 1051 | 1038 | ||
| 1052 | idetape_create_read_position_cmd(&pc); | 1039 | ret = ide_tape_read_position(drive); |
| 1053 | retval = ide_queue_pc_tail(drive, disk, &pc); | 1040 | if (ret < 0) |
| 1054 | if (retval) | 1041 | return ret; |
| 1055 | return retval; | ||
| 1056 | return 0; | 1042 | return 0; |
| 1057 | } | 1043 | } |
| 1058 | 1044 | ||
| @@ -1119,7 +1105,7 @@ static int idetape_space_over_filemarks(ide_drive_t *drive, short mt_op, | |||
| 1119 | case MTBSF: | 1105 | case MTBSF: |
| 1120 | idetape_create_space_cmd(&pc, mt_count - count, | 1106 | idetape_create_space_cmd(&pc, mt_count - count, |
| 1121 | IDETAPE_SPACE_OVER_FILEMARK); | 1107 | IDETAPE_SPACE_OVER_FILEMARK); |
| 1122 | return ide_queue_pc_tail(drive, disk, &pc); | 1108 | return ide_queue_pc_tail(drive, disk, &pc, NULL, 0); |
| 1123 | case MTFSFM: | 1109 | case MTFSFM: |
| 1124 | case MTBSFM: | 1110 | case MTBSFM: |
| 1125 | if (!sprev) | 1111 | if (!sprev) |
| @@ -1259,7 +1245,7 @@ static int idetape_write_filemark(ide_drive_t *drive) | |||
| 1259 | 1245 | ||
| 1260 | /* Write a filemark */ | 1246 | /* Write a filemark */ |
| 1261 | idetape_create_write_filemark_cmd(drive, &pc, 1); | 1247 | idetape_create_write_filemark_cmd(drive, &pc, 1); |
| 1262 | if (ide_queue_pc_tail(drive, tape->disk, &pc)) { | 1248 | if (ide_queue_pc_tail(drive, tape->disk, &pc, NULL, 0)) { |
| 1263 | printk(KERN_ERR "ide-tape: Couldn't write a filemark\n"); | 1249 | printk(KERN_ERR "ide-tape: Couldn't write a filemark\n"); |
| 1264 | return -EIO; | 1250 | return -EIO; |
| 1265 | } | 1251 | } |
| @@ -1345,11 +1331,11 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) | |||
| 1345 | IDETAPE_LU_RETENSION_MASK | IDETAPE_LU_LOAD_MASK); | 1331 | IDETAPE_LU_RETENSION_MASK | IDETAPE_LU_LOAD_MASK); |
| 1346 | case MTEOM: | 1332 | case MTEOM: |
| 1347 | idetape_create_space_cmd(&pc, 0, IDETAPE_SPACE_TO_EOD); | 1333 | idetape_create_space_cmd(&pc, 0, IDETAPE_SPACE_TO_EOD); |
| 1348 | return ide_queue_pc_tail(drive, disk, &pc); | 1334 | return ide_queue_pc_tail(drive, disk, &pc, NULL, 0); |
| 1349 | case MTERASE: | 1335 | case MTERASE: |
| 1350 | (void)idetape_rewind_tape(drive); | 1336 | (void)idetape_rewind_tape(drive); |
| 1351 | idetape_create_erase_cmd(&pc); | 1337 | idetape_create_erase_cmd(&pc); |
| 1352 | return ide_queue_pc_tail(drive, disk, &pc); | 1338 | return ide_queue_pc_tail(drive, disk, &pc, NULL, 0); |
| 1353 | case MTSETBLK: | 1339 | case MTSETBLK: |
| 1354 | if (mt_count) { | 1340 | if (mt_count) { |
| 1355 | if (mt_count < tape->blk_size || | 1341 | if (mt_count < tape->blk_size || |
| @@ -1415,7 +1401,7 @@ static int idetape_chrdev_ioctl(struct inode *inode, struct file *file, | |||
| 1415 | if (cmd == MTIOCGET || cmd == MTIOCPOS) { | 1401 | if (cmd == MTIOCGET || cmd == MTIOCPOS) { |
| 1416 | block_offset = tape->valid / | 1402 | block_offset = tape->valid / |
| 1417 | (tape->blk_size * tape->user_bs_factor); | 1403 | (tape->blk_size * tape->user_bs_factor); |
| 1418 | position = idetape_read_position(drive); | 1404 | position = ide_tape_read_position(drive); |
| 1419 | if (position < 0) | 1405 | if (position < 0) |
| 1420 | return -EIO; | 1406 | return -EIO; |
| 1421 | } | 1407 | } |
| @@ -1458,9 +1444,10 @@ static void ide_tape_get_bsize_from_bdesc(ide_drive_t *drive) | |||
| 1458 | { | 1444 | { |
| 1459 | idetape_tape_t *tape = drive->driver_data; | 1445 | idetape_tape_t *tape = drive->driver_data; |
| 1460 | struct ide_atapi_pc pc; | 1446 | struct ide_atapi_pc pc; |
| 1447 | u8 buf[12]; | ||
| 1461 | 1448 | ||
| 1462 | idetape_create_mode_sense_cmd(&pc, IDETAPE_BLOCK_DESCRIPTOR); | 1449 | idetape_create_mode_sense_cmd(&pc, IDETAPE_BLOCK_DESCRIPTOR); |
| 1463 | if (ide_queue_pc_tail(drive, tape->disk, &pc)) { | 1450 | if (ide_queue_pc_tail(drive, tape->disk, &pc, buf, pc.req_xfer)) { |
| 1464 | printk(KERN_ERR "ide-tape: Can't get block descriptor\n"); | 1451 | printk(KERN_ERR "ide-tape: Can't get block descriptor\n"); |
| 1465 | if (tape->blk_size == 0) { | 1452 | if (tape->blk_size == 0) { |
| 1466 | printk(KERN_WARNING "ide-tape: Cannot deal with zero " | 1453 | printk(KERN_WARNING "ide-tape: Cannot deal with zero " |
| @@ -1469,10 +1456,10 @@ static void ide_tape_get_bsize_from_bdesc(ide_drive_t *drive) | |||
| 1469 | } | 1456 | } |
| 1470 | return; | 1457 | return; |
| 1471 | } | 1458 | } |
| 1472 | tape->blk_size = (pc.buf[4 + 5] << 16) + | 1459 | tape->blk_size = (buf[4 + 5] << 16) + |
| 1473 | (pc.buf[4 + 6] << 8) + | 1460 | (buf[4 + 6] << 8) + |
| 1474 | pc.buf[4 + 7]; | 1461 | buf[4 + 7]; |
| 1475 | tape->drv_write_prot = (pc.buf[2] & 0x80) >> 7; | 1462 | tape->drv_write_prot = (buf[2] & 0x80) >> 7; |
| 1476 | } | 1463 | } |
| 1477 | 1464 | ||
| 1478 | static int idetape_chrdev_open(struct inode *inode, struct file *filp) | 1465 | static int idetape_chrdev_open(struct inode *inode, struct file *filp) |
| @@ -1517,7 +1504,7 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp) | |||
| 1517 | goto out_put_tape; | 1504 | goto out_put_tape; |
| 1518 | } | 1505 | } |
| 1519 | 1506 | ||
| 1520 | idetape_read_position(drive); | 1507 | ide_tape_read_position(drive); |
| 1521 | if (!test_bit(ilog2(IDE_AFLAG_ADDRESS_VALID), &drive->atapi_flags)) | 1508 | if (!test_bit(ilog2(IDE_AFLAG_ADDRESS_VALID), &drive->atapi_flags)) |
| 1522 | (void)idetape_rewind_tape(drive); | 1509 | (void)idetape_rewind_tape(drive); |
| 1523 | 1510 | ||
| @@ -1615,17 +1602,14 @@ static void idetape_get_inquiry_results(ide_drive_t *drive) | |||
| 1615 | char fw_rev[4], vendor_id[8], product_id[16]; | 1602 | char fw_rev[4], vendor_id[8], product_id[16]; |
| 1616 | 1603 | ||
| 1617 | idetape_create_inquiry_cmd(&pc); | 1604 | idetape_create_inquiry_cmd(&pc); |
| 1618 | pc.buf = &pc_buf[0]; | 1605 | if (ide_queue_pc_tail(drive, tape->disk, &pc, pc_buf, pc.req_xfer)) { |
| 1619 | pc.buf_size = sizeof(pc_buf); | ||
| 1620 | |||
| 1621 | if (ide_queue_pc_tail(drive, tape->disk, &pc)) { | ||
| 1622 | printk(KERN_ERR "ide-tape: %s: can't get INQUIRY results\n", | 1606 | printk(KERN_ERR "ide-tape: %s: can't get INQUIRY results\n", |
| 1623 | tape->name); | 1607 | tape->name); |
| 1624 | return; | 1608 | return; |
| 1625 | } | 1609 | } |
| 1626 | memcpy(vendor_id, &pc.buf[8], 8); | 1610 | memcpy(vendor_id, &pc_buf[8], 8); |
| 1627 | memcpy(product_id, &pc.buf[16], 16); | 1611 | memcpy(product_id, &pc_buf[16], 16); |
| 1628 | memcpy(fw_rev, &pc.buf[32], 4); | 1612 | memcpy(fw_rev, &pc_buf[32], 4); |
| 1629 | 1613 | ||
| 1630 | ide_fixstring(vendor_id, 8, 0); | 1614 | ide_fixstring(vendor_id, 8, 0); |
| 1631 | ide_fixstring(product_id, 16, 0); | 1615 | ide_fixstring(product_id, 16, 0); |
| @@ -1643,11 +1627,11 @@ static void idetape_get_mode_sense_results(ide_drive_t *drive) | |||
| 1643 | { | 1627 | { |
| 1644 | idetape_tape_t *tape = drive->driver_data; | 1628 | idetape_tape_t *tape = drive->driver_data; |
| 1645 | struct ide_atapi_pc pc; | 1629 | struct ide_atapi_pc pc; |
| 1646 | u8 *caps; | 1630 | u8 buf[24], *caps; |
| 1647 | u8 speed, max_speed; | 1631 | u8 speed, max_speed; |
| 1648 | 1632 | ||
| 1649 | idetape_create_mode_sense_cmd(&pc, IDETAPE_CAPABILITIES_PAGE); | 1633 | idetape_create_mode_sense_cmd(&pc, IDETAPE_CAPABILITIES_PAGE); |
| 1650 | if (ide_queue_pc_tail(drive, tape->disk, &pc)) { | 1634 | if (ide_queue_pc_tail(drive, tape->disk, &pc, buf, pc.req_xfer)) { |
| 1651 | printk(KERN_ERR "ide-tape: Can't get tape parameters - assuming" | 1635 | printk(KERN_ERR "ide-tape: Can't get tape parameters - assuming" |
| 1652 | " some default values\n"); | 1636 | " some default values\n"); |
| 1653 | tape->blk_size = 512; | 1637 | tape->blk_size = 512; |
| @@ -1656,7 +1640,7 @@ static void idetape_get_mode_sense_results(ide_drive_t *drive) | |||
| 1656 | put_unaligned(6*52, (u16 *)&tape->caps[16]); | 1640 | put_unaligned(6*52, (u16 *)&tape->caps[16]); |
| 1657 | return; | 1641 | return; |
| 1658 | } | 1642 | } |
| 1659 | caps = pc.buf + 4 + pc.buf[3]; | 1643 | caps = buf + 4 + buf[3]; |
| 1660 | 1644 | ||
| 1661 | /* convert to host order and save for later use */ | 1645 | /* convert to host order and save for later use */ |
| 1662 | speed = be16_to_cpup((__be16 *)&caps[14]); | 1646 | speed = be16_to_cpup((__be16 *)&caps[14]); |
