diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-18 11:39:24 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-18 11:39:24 -0400 |
| commit | 188da98800893691e47eea9335a234378e32aceb (patch) | |
| tree | 57dbf491d23676e011b4946ec1867a6d55a02eef /drivers/ide/ide-tape.c | |
| parent | 07fe944e87d79f8d7e1b090913fe9f2ace78f41d (diff) | |
| parent | 273b8385e5817a4765f82257004c5ec661a6a5b2 (diff) | |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6: (58 commits)
ide: remove ide_init_default_irq() macro
ide: move default IDE ports setup to ide_generic host driver
ide: remove obsoleted "idex=noprobe" kernel parameter (take 2)
ide: remove needless hwif->irq check from ide_hwif_configure()
ide: init hwif->{io_ports,irq} explicitly in legacy VLB host drivers
ide: limit legacy VLB host drivers to alpha, x86 and mips
cmd640: init hwif->{io_ports,irq} explicitly
cmd640: cleanup setup_device_ptrs()
ide: add ide-4drives host driver (take 3)
ide: remove ppc ifdef from init_ide_data()
ide: remove ide_default_io_ctl() macro
ide: remove CONFIG_IDE_ARCH_OBSOLETE_INIT
ide: add CONFIG_IDE_ARCH_OBSOLETE_DEFAULTS (take 2)
ppc/pmac: remove no longer needed IDE quirk
ppc: don't include <linux/ide.h>
ppc: remove ppc_ide_md
ppc/pplus: remove ppc_ide_md.ide_init_hwif hook
ppc/sandpoint: remove ppc_ide_md hooks
ppc/lopec: remove ppc_ide_md hooks
ppc/mpc8xx: remove ppc_ide_md hooks
...
Diffstat (limited to 'drivers/ide/ide-tape.c')
| -rw-r--r-- | drivers/ide/ide-tape.c | 536 |
1 files changed, 250 insertions, 286 deletions
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 0598ecfd5f37..f43fd070f1b6 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
| @@ -181,49 +181,63 @@ struct idetape_bh { | |||
| 181 | char *b_data; | 181 | char *b_data; |
| 182 | }; | 182 | }; |
| 183 | 183 | ||
| 184 | typedef struct idetape_packet_command_s { | 184 | /* Tape door status */ |
| 185 | /* Actual packet bytes */ | 185 | #define DOOR_UNLOCKED 0 |
| 186 | u8 c[12]; | 186 | #define DOOR_LOCKED 1 |
| 187 | /* On each retry, we increment retries */ | 187 | #define DOOR_EXPLICITLY_LOCKED 2 |
| 188 | int retries; | 188 | |
| 189 | /* Error code */ | 189 | /* Some defines for the SPACE command */ |
| 190 | int error; | 190 | #define IDETAPE_SPACE_OVER_FILEMARK 1 |
| 191 | /* Bytes to transfer */ | 191 | #define IDETAPE_SPACE_TO_EOD 3 |
| 192 | int request_transfer; | 192 | |
| 193 | /* Bytes actually transferred */ | 193 | /* Some defines for the LOAD UNLOAD command */ |
| 194 | int actually_transferred; | 194 | #define IDETAPE_LU_LOAD_MASK 1 |
| 195 | /* Size of our data buffer */ | 195 | #define IDETAPE_LU_RETENSION_MASK 2 |
| 196 | int buffer_size; | 196 | #define IDETAPE_LU_EOT_MASK 4 |
| 197 | struct idetape_bh *bh; | ||
| 198 | char *b_data; | ||
| 199 | int b_count; | ||
| 200 | /* Data buffer */ | ||
| 201 | u8 *buffer; | ||
| 202 | /* Pointer into the above buffer */ | ||
| 203 | u8 *current_position; | ||
| 204 | /* Called when this packet command is completed */ | ||
| 205 | ide_startstop_t (*callback) (ide_drive_t *); | ||
| 206 | /* Temporary buffer */ | ||
| 207 | u8 pc_buffer[IDETAPE_PC_BUFFER_SIZE]; | ||
| 208 | /* Status/Action bit flags: long for set_bit */ | ||
| 209 | unsigned long flags; | ||
| 210 | } idetape_pc_t; | ||
| 211 | 197 | ||
| 212 | /* | 198 | /* |
| 213 | * Packet command flag bits. | 199 | * Special requests for our block device strategy routine. |
| 200 | * | ||
| 201 | * In order to service a character device command, we add special requests to | ||
| 202 | * the tail of our block device request queue and wait for their completion. | ||
| 214 | */ | 203 | */ |
| 215 | /* Set when an error is considered normal - We won't retry */ | 204 | |
| 216 | #define PC_ABORT 0 | 205 | enum { |
| 217 | /* 1 When polling for DSC on a media access command */ | 206 | REQ_IDETAPE_PC1 = (1 << 0), /* packet command (first stage) */ |
| 218 | #define PC_WAIT_FOR_DSC 1 | 207 | REQ_IDETAPE_PC2 = (1 << 1), /* packet command (second stage) */ |
| 219 | /* 1 when we prefer to use DMA if possible */ | 208 | REQ_IDETAPE_READ = (1 << 2), |
| 220 | #define PC_DMA_RECOMMENDED 2 | 209 | REQ_IDETAPE_WRITE = (1 << 3), |
| 221 | /* 1 while DMA in progress */ | 210 | }; |
| 222 | #define PC_DMA_IN_PROGRESS 3 | 211 | |
| 223 | /* 1 when encountered problem during DMA */ | 212 | /* Error codes returned in rq->errors to the higher part of the driver. */ |
| 224 | #define PC_DMA_ERROR 4 | 213 | #define IDETAPE_ERROR_GENERAL 101 |
| 225 | /* Data direction */ | 214 | #define IDETAPE_ERROR_FILEMARK 102 |
| 226 | #define PC_WRITING 5 | 215 | #define IDETAPE_ERROR_EOD 103 |
| 216 | |||
| 217 | /* Structures related to the SELECT SENSE / MODE SENSE packet commands. */ | ||
| 218 | #define IDETAPE_BLOCK_DESCRIPTOR 0 | ||
| 219 | #define IDETAPE_CAPABILITIES_PAGE 0x2a | ||
| 220 | |||
| 221 | /* Tape flag bits values. */ | ||
| 222 | enum { | ||
| 223 | IDETAPE_FLAG_IGNORE_DSC = (1 << 0), | ||
| 224 | /* 0 When the tape position is unknown */ | ||
| 225 | IDETAPE_FLAG_ADDRESS_VALID = (1 << 1), | ||
| 226 | /* Device already opened */ | ||
| 227 | IDETAPE_FLAG_BUSY = (1 << 2), | ||
| 228 | /* Error detected in a pipeline stage */ | ||
| 229 | IDETAPE_FLAG_PIPELINE_ERR = (1 << 3), | ||
| 230 | /* Attempt to auto-detect the current user block size */ | ||
| 231 | IDETAPE_FLAG_DETECT_BS = (1 << 4), | ||
| 232 | /* Currently on a filemark */ | ||
| 233 | IDETAPE_FLAG_FILEMARK = (1 << 5), | ||
| 234 | /* DRQ interrupt device */ | ||
| 235 | IDETAPE_FLAG_DRQ_INTERRUPT = (1 << 6), | ||
| 236 | /* pipeline active */ | ||
| 237 | IDETAPE_FLAG_PIPELINE_ACTIVE = (1 << 7), | ||
| 238 | /* 0 = no tape is loaded, so we don't rewind after ejecting */ | ||
| 239 | IDETAPE_FLAG_MEDIUM_PRESENT = (1 << 8), | ||
| 240 | }; | ||
| 227 | 241 | ||
| 228 | /* A pipeline stage. */ | 242 | /* A pipeline stage. */ |
| 229 | typedef struct idetape_stage_s { | 243 | typedef struct idetape_stage_s { |
| @@ -258,11 +272,11 @@ typedef struct ide_tape_obj { | |||
| 258 | * retry, to get detailed information on what went wrong. | 272 | * retry, to get detailed information on what went wrong. |
| 259 | */ | 273 | */ |
| 260 | /* Current packet command */ | 274 | /* Current packet command */ |
| 261 | idetape_pc_t *pc; | 275 | struct ide_atapi_pc *pc; |
| 262 | /* Last failed packet command */ | 276 | /* Last failed packet command */ |
| 263 | idetape_pc_t *failed_pc; | 277 | struct ide_atapi_pc *failed_pc; |
| 264 | /* Packet command stack */ | 278 | /* Packet command stack */ |
| 265 | idetape_pc_t pc_stack[IDETAPE_PC_STACK]; | 279 | struct ide_atapi_pc pc_stack[IDETAPE_PC_STACK]; |
| 266 | /* Next free packet command storage space */ | 280 | /* Next free packet command storage space */ |
| 267 | int pc_stack_index; | 281 | int pc_stack_index; |
| 268 | struct request rq_stack[IDETAPE_PC_STACK]; | 282 | struct request rq_stack[IDETAPE_PC_STACK]; |
| @@ -446,58 +460,6 @@ static void ide_tape_put(struct ide_tape_obj *tape) | |||
| 446 | mutex_unlock(&idetape_ref_mutex); | 460 | mutex_unlock(&idetape_ref_mutex); |
| 447 | } | 461 | } |
| 448 | 462 | ||
| 449 | /* Tape door status */ | ||
| 450 | #define DOOR_UNLOCKED 0 | ||
| 451 | #define DOOR_LOCKED 1 | ||
| 452 | #define DOOR_EXPLICITLY_LOCKED 2 | ||
| 453 | |||
| 454 | /* | ||
| 455 | * Tape flag bits values. | ||
| 456 | */ | ||
| 457 | #define IDETAPE_IGNORE_DSC 0 | ||
| 458 | #define IDETAPE_ADDRESS_VALID 1 /* 0 When the tape position is unknown */ | ||
| 459 | #define IDETAPE_BUSY 2 /* Device already opened */ | ||
| 460 | #define IDETAPE_PIPELINE_ERROR 3 /* Error detected in a pipeline stage */ | ||
| 461 | #define IDETAPE_DETECT_BS 4 /* Attempt to auto-detect the current user block size */ | ||
| 462 | #define IDETAPE_FILEMARK 5 /* Currently on a filemark */ | ||
| 463 | #define IDETAPE_DRQ_INTERRUPT 6 /* DRQ interrupt device */ | ||
| 464 | #define IDETAPE_READ_ERROR 7 | ||
| 465 | #define IDETAPE_PIPELINE_ACTIVE 8 /* pipeline active */ | ||
| 466 | /* 0 = no tape is loaded, so we don't rewind after ejecting */ | ||
| 467 | #define IDETAPE_MEDIUM_PRESENT 9 | ||
| 468 | |||
| 469 | /* Some defines for the SPACE command */ | ||
| 470 | #define IDETAPE_SPACE_OVER_FILEMARK 1 | ||
| 471 | #define IDETAPE_SPACE_TO_EOD 3 | ||
| 472 | |||
| 473 | /* Some defines for the LOAD UNLOAD command */ | ||
| 474 | #define IDETAPE_LU_LOAD_MASK 1 | ||
| 475 | #define IDETAPE_LU_RETENSION_MASK 2 | ||
| 476 | #define IDETAPE_LU_EOT_MASK 4 | ||
| 477 | |||
| 478 | /* | ||
| 479 | * Special requests for our block device strategy routine. | ||
| 480 | * | ||
| 481 | * In order to service a character device command, we add special requests to | ||
| 482 | * the tail of our block device request queue and wait for their completion. | ||
| 483 | */ | ||
| 484 | |||
| 485 | enum { | ||
| 486 | REQ_IDETAPE_PC1 = (1 << 0), /* packet command (first stage) */ | ||
| 487 | REQ_IDETAPE_PC2 = (1 << 1), /* packet command (second stage) */ | ||
| 488 | REQ_IDETAPE_READ = (1 << 2), | ||
| 489 | REQ_IDETAPE_WRITE = (1 << 3), | ||
| 490 | }; | ||
| 491 | |||
| 492 | /* Error codes returned in rq->errors to the higher part of the driver. */ | ||
| 493 | #define IDETAPE_ERROR_GENERAL 101 | ||
| 494 | #define IDETAPE_ERROR_FILEMARK 102 | ||
| 495 | #define IDETAPE_ERROR_EOD 103 | ||
| 496 | |||
| 497 | /* Structures related to the SELECT SENSE / MODE SENSE packet commands. */ | ||
| 498 | #define IDETAPE_BLOCK_DESCRIPTOR 0 | ||
| 499 | #define IDETAPE_CAPABILITIES_PAGE 0x2a | ||
| 500 | |||
| 501 | /* | 463 | /* |
| 502 | * The variables below are used for the character device interface. Additional | 464 | * The variables below are used for the character device interface. Additional |
| 503 | * state variables are defined in our ide_drive_t structure. | 465 | * state variables are defined in our ide_drive_t structure. |
| @@ -518,17 +480,7 @@ static struct ide_tape_obj *ide_tape_chrdev_get(unsigned int i) | |||
| 518 | return tape; | 480 | return tape; |
| 519 | } | 481 | } |
| 520 | 482 | ||
| 521 | /* | 483 | static void idetape_input_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, |
| 522 | * Too bad. The drive wants to send us data which we are not ready to accept. | ||
| 523 | * Just throw it away. | ||
| 524 | */ | ||
| 525 | static void idetape_discard_data(ide_drive_t *drive, unsigned int bcount) | ||
| 526 | { | ||
| 527 | while (bcount--) | ||
| 528 | (void) HWIF(drive)->INB(IDE_DATA_REG); | ||
| 529 | } | ||
| 530 | |||
| 531 | static void idetape_input_buffers(ide_drive_t *drive, idetape_pc_t *pc, | ||
| 532 | unsigned int bcount) | 484 | unsigned int bcount) |
| 533 | { | 485 | { |
| 534 | struct idetape_bh *bh = pc->bh; | 486 | struct idetape_bh *bh = pc->bh; |
| @@ -538,7 +490,7 @@ static void idetape_input_buffers(ide_drive_t *drive, idetape_pc_t *pc, | |||
| 538 | if (bh == NULL) { | 490 | if (bh == NULL) { |
| 539 | printk(KERN_ERR "ide-tape: bh == NULL in " | 491 | printk(KERN_ERR "ide-tape: bh == NULL in " |
| 540 | "idetape_input_buffers\n"); | 492 | "idetape_input_buffers\n"); |
| 541 | idetape_discard_data(drive, bcount); | 493 | ide_atapi_discard_data(drive, bcount); |
| 542 | return; | 494 | return; |
| 543 | } | 495 | } |
| 544 | count = min( | 496 | count = min( |
| @@ -557,7 +509,7 @@ static void idetape_input_buffers(ide_drive_t *drive, idetape_pc_t *pc, | |||
| 557 | pc->bh = bh; | 509 | pc->bh = bh; |
| 558 | } | 510 | } |
| 559 | 511 | ||
| 560 | static void idetape_output_buffers(ide_drive_t *drive, idetape_pc_t *pc, | 512 | static void idetape_output_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, |
| 561 | unsigned int bcount) | 513 | unsigned int bcount) |
| 562 | { | 514 | { |
| 563 | struct idetape_bh *bh = pc->bh; | 515 | struct idetape_bh *bh = pc->bh; |
| @@ -585,13 +537,13 @@ static void idetape_output_buffers(ide_drive_t *drive, idetape_pc_t *pc, | |||
| 585 | } | 537 | } |
| 586 | } | 538 | } |
| 587 | 539 | ||
| 588 | static void idetape_update_buffers(idetape_pc_t *pc) | 540 | static void idetape_update_buffers(struct ide_atapi_pc *pc) |
| 589 | { | 541 | { |
| 590 | struct idetape_bh *bh = pc->bh; | 542 | struct idetape_bh *bh = pc->bh; |
| 591 | int count; | 543 | int count; |
| 592 | unsigned int bcount = pc->actually_transferred; | 544 | unsigned int bcount = pc->xferred; |
| 593 | 545 | ||
| 594 | if (test_bit(PC_WRITING, &pc->flags)) | 546 | if (pc->flags & PC_FLAG_WRITING) |
| 595 | return; | 547 | return; |
| 596 | while (bcount) { | 548 | while (bcount) { |
| 597 | if (bh == NULL) { | 549 | if (bh == NULL) { |
| @@ -614,7 +566,7 @@ static void idetape_update_buffers(idetape_pc_t *pc) | |||
| 614 | * driver. A storage space for a maximum of IDETAPE_PC_STACK packet | 566 | * driver. A storage space for a maximum of IDETAPE_PC_STACK packet |
| 615 | * commands is allocated at initialization time. | 567 | * commands is allocated at initialization time. |
| 616 | */ | 568 | */ |
| 617 | static idetape_pc_t *idetape_next_pc_storage(ide_drive_t *drive) | 569 | static struct ide_atapi_pc *idetape_next_pc_storage(ide_drive_t *drive) |
| 618 | { | 570 | { |
| 619 | idetape_tape_t *tape = drive->driver_data; | 571 | idetape_tape_t *tape = drive->driver_data; |
| 620 | 572 | ||
| @@ -649,14 +601,14 @@ static struct request *idetape_next_rq_storage(ide_drive_t *drive) | |||
| 649 | return (&tape->rq_stack[tape->rq_stack_index++]); | 601 | return (&tape->rq_stack[tape->rq_stack_index++]); |
| 650 | } | 602 | } |
| 651 | 603 | ||
| 652 | static void idetape_init_pc(idetape_pc_t *pc) | 604 | static void idetape_init_pc(struct ide_atapi_pc *pc) |
| 653 | { | 605 | { |
| 654 | memset(pc->c, 0, 12); | 606 | memset(pc->c, 0, 12); |
| 655 | pc->retries = 0; | 607 | pc->retries = 0; |
| 656 | pc->flags = 0; | 608 | pc->flags = 0; |
| 657 | pc->request_transfer = 0; | 609 | pc->req_xfer = 0; |
| 658 | pc->buffer = pc->pc_buffer; | 610 | pc->buf = pc->pc_buf; |
| 659 | pc->buffer_size = IDETAPE_PC_BUFFER_SIZE; | 611 | pc->buf_size = IDETAPE_PC_BUFFER_SIZE; |
| 660 | pc->bh = NULL; | 612 | pc->bh = NULL; |
| 661 | pc->b_data = NULL; | 613 | pc->b_data = NULL; |
| 662 | } | 614 | } |
| @@ -668,7 +620,7 @@ static void idetape_init_pc(idetape_pc_t *pc) | |||
| 668 | static void idetape_analyze_error(ide_drive_t *drive, u8 *sense) | 620 | static void idetape_analyze_error(ide_drive_t *drive, u8 *sense) |
| 669 | { | 621 | { |
| 670 | idetape_tape_t *tape = drive->driver_data; | 622 | idetape_tape_t *tape = drive->driver_data; |
| 671 | idetape_pc_t *pc = tape->failed_pc; | 623 | struct ide_atapi_pc *pc = tape->failed_pc; |
| 672 | 624 | ||
| 673 | tape->sense_key = sense[2] & 0xF; | 625 | tape->sense_key = sense[2] & 0xF; |
| 674 | tape->asc = sense[12]; | 626 | tape->asc = sense[12]; |
| @@ -677,9 +629,9 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 *sense) | |||
| 677 | debug_log(DBG_ERR, "pc = %x, sense key = %x, asc = %x, ascq = %x\n", | 629 | debug_log(DBG_ERR, "pc = %x, sense key = %x, asc = %x, ascq = %x\n", |
| 678 | pc->c[0], tape->sense_key, tape->asc, tape->ascq); | 630 | pc->c[0], tape->sense_key, tape->asc, tape->ascq); |
| 679 | 631 | ||
| 680 | /* Correct pc->actually_transferred by asking the tape. */ | 632 | /* Correct pc->xferred by asking the tape. */ |
| 681 | if (test_bit(PC_DMA_ERROR, &pc->flags)) { | 633 | if (pc->flags & PC_FLAG_DMA_ERROR) { |
| 682 | pc->actually_transferred = pc->request_transfer - | 634 | pc->xferred = pc->req_xfer - |
| 683 | tape->blk_size * | 635 | tape->blk_size * |
| 684 | be32_to_cpu(get_unaligned((u32 *)&sense[3])); | 636 | be32_to_cpu(get_unaligned((u32 *)&sense[3])); |
| 685 | idetape_update_buffers(pc); | 637 | idetape_update_buffers(pc); |
| @@ -697,27 +649,27 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 *sense) | |||
| 697 | /* don't report an error, everything's ok */ | 649 | /* don't report an error, everything's ok */ |
| 698 | pc->error = 0; | 650 | pc->error = 0; |
| 699 | /* don't retry read/write */ | 651 | /* don't retry read/write */ |
| 700 | set_bit(PC_ABORT, &pc->flags); | 652 | pc->flags |= PC_FLAG_ABORT; |
| 701 | } | 653 | } |
| 702 | } | 654 | } |
| 703 | if (pc->c[0] == READ_6 && (sense[2] & 0x80)) { | 655 | if (pc->c[0] == READ_6 && (sense[2] & 0x80)) { |
| 704 | pc->error = IDETAPE_ERROR_FILEMARK; | 656 | pc->error = IDETAPE_ERROR_FILEMARK; |
| 705 | set_bit(PC_ABORT, &pc->flags); | 657 | pc->flags |= PC_FLAG_ABORT; |
| 706 | } | 658 | } |
| 707 | if (pc->c[0] == WRITE_6) { | 659 | if (pc->c[0] == WRITE_6) { |
| 708 | if ((sense[2] & 0x40) || (tape->sense_key == 0xd | 660 | if ((sense[2] & 0x40) || (tape->sense_key == 0xd |
| 709 | && tape->asc == 0x0 && tape->ascq == 0x2)) { | 661 | && tape->asc == 0x0 && tape->ascq == 0x2)) { |
| 710 | pc->error = IDETAPE_ERROR_EOD; | 662 | pc->error = IDETAPE_ERROR_EOD; |
| 711 | set_bit(PC_ABORT, &pc->flags); | 663 | pc->flags |= PC_FLAG_ABORT; |
| 712 | } | 664 | } |
| 713 | } | 665 | } |
| 714 | if (pc->c[0] == READ_6 || pc->c[0] == WRITE_6) { | 666 | if (pc->c[0] == READ_6 || pc->c[0] == WRITE_6) { |
| 715 | if (tape->sense_key == 8) { | 667 | if (tape->sense_key == 8) { |
| 716 | pc->error = IDETAPE_ERROR_EOD; | 668 | pc->error = IDETAPE_ERROR_EOD; |
| 717 | set_bit(PC_ABORT, &pc->flags); | 669 | pc->flags |= PC_FLAG_ABORT; |
| 718 | } | 670 | } |
| 719 | if (!test_bit(PC_ABORT, &pc->flags) && | 671 | if (!(pc->flags & PC_FLAG_ABORT) && |
| 720 | pc->actually_transferred) | 672 | pc->xferred) |
| 721 | pc->retries = IDETAPE_MAX_PC_RETRIES + 1; | 673 | pc->retries = IDETAPE_MAX_PC_RETRIES + 1; |
| 722 | } | 674 | } |
| 723 | } | 675 | } |
| @@ -872,14 +824,16 @@ static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects) | |||
| 872 | if (rq->cmd[0] & REQ_IDETAPE_WRITE) { | 824 | if (rq->cmd[0] & REQ_IDETAPE_WRITE) { |
| 873 | remove_stage = 1; | 825 | remove_stage = 1; |
| 874 | if (error) { | 826 | if (error) { |
| 875 | set_bit(IDETAPE_PIPELINE_ERROR, &tape->flags); | 827 | set_bit(IDETAPE_FLAG_PIPELINE_ERR, |
| 828 | &tape->flags); | ||
| 876 | if (error == IDETAPE_ERROR_EOD) | 829 | if (error == IDETAPE_ERROR_EOD) |
| 877 | idetape_abort_pipeline(drive, | 830 | idetape_abort_pipeline(drive, |
| 878 | active_stage); | 831 | active_stage); |
| 879 | } | 832 | } |
| 880 | } else if (rq->cmd[0] & REQ_IDETAPE_READ) { | 833 | } else if (rq->cmd[0] & REQ_IDETAPE_READ) { |
| 881 | if (error == IDETAPE_ERROR_EOD) { | 834 | if (error == IDETAPE_ERROR_EOD) { |
| 882 | set_bit(IDETAPE_PIPELINE_ERROR, &tape->flags); | 835 | set_bit(IDETAPE_FLAG_PIPELINE_ERR, |
| 836 | &tape->flags); | ||
| 883 | idetape_abort_pipeline(drive, active_stage); | 837 | idetape_abort_pipeline(drive, active_stage); |
| 884 | } | 838 | } |
| 885 | } | 839 | } |
| @@ -912,7 +866,7 @@ static int idetape_end_request(ide_drive_t *drive, int uptodate, int nr_sects) | |||
| 912 | if (remove_stage) | 866 | if (remove_stage) |
| 913 | idetape_remove_stage_head(drive); | 867 | idetape_remove_stage_head(drive); |
| 914 | if (tape->active_data_rq == NULL) | 868 | if (tape->active_data_rq == NULL) |
| 915 | clear_bit(IDETAPE_PIPELINE_ACTIVE, &tape->flags); | 869 | clear_bit(IDETAPE_FLAG_PIPELINE_ACTIVE, &tape->flags); |
| 916 | spin_unlock_irqrestore(&tape->lock, flags); | 870 | spin_unlock_irqrestore(&tape->lock, flags); |
| 917 | return 0; | 871 | return 0; |
| 918 | } | 872 | } |
| @@ -924,7 +878,7 @@ static ide_startstop_t idetape_request_sense_callback(ide_drive_t *drive) | |||
| 924 | debug_log(DBG_PROCS, "Enter %s\n", __func__); | 878 | debug_log(DBG_PROCS, "Enter %s\n", __func__); |
| 925 | 879 | ||
| 926 | if (!tape->pc->error) { | 880 | if (!tape->pc->error) { |
| 927 | idetape_analyze_error(drive, tape->pc->buffer); | 881 | idetape_analyze_error(drive, tape->pc->buf); |
| 928 | idetape_end_request(drive, 1, 0); | 882 | idetape_end_request(drive, 1, 0); |
| 929 | } else { | 883 | } else { |
| 930 | printk(KERN_ERR "ide-tape: Error in REQUEST SENSE itself - " | 884 | printk(KERN_ERR "ide-tape: Error in REQUEST SENSE itself - " |
| @@ -934,13 +888,13 @@ static ide_startstop_t idetape_request_sense_callback(ide_drive_t *drive) | |||
| 934 | return ide_stopped; | 888 | return ide_stopped; |
| 935 | } | 889 | } |
| 936 | 890 | ||
| 937 | static void idetape_create_request_sense_cmd(idetape_pc_t *pc) | 891 | static void idetape_create_request_sense_cmd(struct ide_atapi_pc *pc) |
| 938 | { | 892 | { |
| 939 | idetape_init_pc(pc); | 893 | idetape_init_pc(pc); |
| 940 | pc->c[0] = REQUEST_SENSE; | 894 | pc->c[0] = REQUEST_SENSE; |
| 941 | pc->c[4] = 20; | 895 | pc->c[4] = 20; |
| 942 | pc->request_transfer = 20; | 896 | pc->req_xfer = 20; |
| 943 | pc->callback = &idetape_request_sense_callback; | 897 | pc->idetape_callback = &idetape_request_sense_callback; |
| 944 | } | 898 | } |
| 945 | 899 | ||
| 946 | static void idetape_init_rq(struct request *rq, u8 cmd) | 900 | static void idetape_init_rq(struct request *rq, u8 cmd) |
| @@ -965,7 +919,7 @@ static void idetape_init_rq(struct request *rq, u8 cmd) | |||
| 965 | * handling functions should queue request to the lower level part and wait for | 919 | * 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. | 920 | * their completion using idetape_queue_pc_tail or idetape_queue_rw_tail. |
| 967 | */ | 921 | */ |
| 968 | static void idetape_queue_pc_head(ide_drive_t *drive, idetape_pc_t *pc, | 922 | static void idetape_queue_pc_head(ide_drive_t *drive, struct ide_atapi_pc *pc, |
| 969 | struct request *rq) | 923 | struct request *rq) |
| 970 | { | 924 | { |
| 971 | struct ide_tape_obj *tape = drive->driver_data; | 925 | struct ide_tape_obj *tape = drive->driver_data; |
| @@ -984,14 +938,14 @@ static void idetape_queue_pc_head(ide_drive_t *drive, idetape_pc_t *pc, | |||
| 984 | static ide_startstop_t idetape_retry_pc (ide_drive_t *drive) | 938 | static ide_startstop_t idetape_retry_pc (ide_drive_t *drive) |
| 985 | { | 939 | { |
| 986 | idetape_tape_t *tape = drive->driver_data; | 940 | idetape_tape_t *tape = drive->driver_data; |
| 987 | idetape_pc_t *pc; | 941 | struct ide_atapi_pc *pc; |
| 988 | struct request *rq; | 942 | struct request *rq; |
| 989 | 943 | ||
| 990 | (void)ide_read_error(drive); | 944 | (void)ide_read_error(drive); |
| 991 | pc = idetape_next_pc_storage(drive); | 945 | pc = idetape_next_pc_storage(drive); |
| 992 | rq = idetape_next_rq_storage(drive); | 946 | rq = idetape_next_rq_storage(drive); |
| 993 | idetape_create_request_sense_cmd(pc); | 947 | idetape_create_request_sense_cmd(pc); |
| 994 | set_bit(IDETAPE_IGNORE_DSC, &tape->flags); | 948 | set_bit(IDETAPE_FLAG_IGNORE_DSC, &tape->flags); |
| 995 | idetape_queue_pc_head(drive, pc, rq); | 949 | idetape_queue_pc_head(drive, pc, rq); |
| 996 | return ide_stopped; | 950 | return ide_stopped; |
| 997 | } | 951 | } |
| @@ -1010,7 +964,7 @@ static void idetape_postpone_request(ide_drive_t *drive) | |||
| 1010 | ide_stall_queue(drive, tape->dsc_poll_freq); | 964 | ide_stall_queue(drive, tape->dsc_poll_freq); |
| 1011 | } | 965 | } |
| 1012 | 966 | ||
| 1013 | typedef void idetape_io_buf(ide_drive_t *, idetape_pc_t *, unsigned int); | 967 | typedef void idetape_io_buf(ide_drive_t *, struct ide_atapi_pc *, unsigned int); |
| 1014 | 968 | ||
| 1015 | /* | 969 | /* |
| 1016 | * This is the usual interrupt handler which will be called during a packet | 970 | * This is the usual interrupt handler which will be called during a packet |
| @@ -1023,7 +977,7 @@ static ide_startstop_t idetape_pc_intr(ide_drive_t *drive) | |||
| 1023 | { | 977 | { |
| 1024 | ide_hwif_t *hwif = drive->hwif; | 978 | ide_hwif_t *hwif = drive->hwif; |
| 1025 | idetape_tape_t *tape = drive->driver_data; | 979 | idetape_tape_t *tape = drive->driver_data; |
| 1026 | idetape_pc_t *pc = tape->pc; | 980 | struct ide_atapi_pc *pc = tape->pc; |
| 1027 | xfer_func_t *xferfunc; | 981 | xfer_func_t *xferfunc; |
| 1028 | idetape_io_buf *iobuf; | 982 | idetape_io_buf *iobuf; |
| 1029 | unsigned int temp; | 983 | unsigned int temp; |
| @@ -1038,7 +992,7 @@ static ide_startstop_t idetape_pc_intr(ide_drive_t *drive) | |||
| 1038 | /* Clear the interrupt */ | 992 | /* Clear the interrupt */ |
| 1039 | stat = ide_read_status(drive); | 993 | stat = ide_read_status(drive); |
| 1040 | 994 | ||
| 1041 | if (test_bit(PC_DMA_IN_PROGRESS, &pc->flags)) { | 995 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { |
| 1042 | if (hwif->ide_dma_end(drive) || (stat & ERR_STAT)) { | 996 | if (hwif->ide_dma_end(drive) || (stat & ERR_STAT)) { |
| 1043 | /* | 997 | /* |
| 1044 | * A DMA error is sometimes expected. For example, | 998 | * A DMA error is sometimes expected. For example, |
| @@ -1061,9 +1015,9 @@ static ide_startstop_t idetape_pc_intr(ide_drive_t *drive) | |||
| 1061 | * data transfer will occur, but no DMA error. | 1015 | * data transfer will occur, but no DMA error. |
| 1062 | * (AS, 19 Apr 2001) | 1016 | * (AS, 19 Apr 2001) |
| 1063 | */ | 1017 | */ |
| 1064 | set_bit(PC_DMA_ERROR, &pc->flags); | 1018 | pc->flags |= PC_FLAG_DMA_ERROR; |
| 1065 | } else { | 1019 | } else { |
| 1066 | pc->actually_transferred = pc->request_transfer; | 1020 | pc->xferred = pc->req_xfer; |
| 1067 | idetape_update_buffers(pc); | 1021 | idetape_update_buffers(pc); |
| 1068 | } | 1022 | } |
| 1069 | debug_log(DBG_PROCS, "DMA finished\n"); | 1023 | debug_log(DBG_PROCS, "DMA finished\n"); |
| @@ -1073,9 +1027,9 @@ static ide_startstop_t idetape_pc_intr(ide_drive_t *drive) | |||
| 1073 | /* No more interrupts */ | 1027 | /* No more interrupts */ |
| 1074 | if ((stat & DRQ_STAT) == 0) { | 1028 | if ((stat & DRQ_STAT) == 0) { |
| 1075 | debug_log(DBG_SENSE, "Packet command completed, %d bytes" | 1029 | debug_log(DBG_SENSE, "Packet command completed, %d bytes" |
| 1076 | " transferred\n", pc->actually_transferred); | 1030 | " transferred\n", pc->xferred); |
| 1077 | 1031 | ||
| 1078 | clear_bit(PC_DMA_IN_PROGRESS, &pc->flags); | 1032 | pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; |
| 1079 | local_irq_enable(); | 1033 | local_irq_enable(); |
| 1080 | 1034 | ||
| 1081 | #if SIMULATE_ERRORS | 1035 | #if SIMULATE_ERRORS |
| @@ -1088,7 +1042,7 @@ static ide_startstop_t idetape_pc_intr(ide_drive_t *drive) | |||
| 1088 | #endif | 1042 | #endif |
| 1089 | if ((stat & ERR_STAT) && pc->c[0] == REQUEST_SENSE) | 1043 | if ((stat & ERR_STAT) && pc->c[0] == REQUEST_SENSE) |
| 1090 | stat &= ~ERR_STAT; | 1044 | stat &= ~ERR_STAT; |
| 1091 | if ((stat & ERR_STAT) || test_bit(PC_DMA_ERROR, &pc->flags)) { | 1045 | if ((stat & ERR_STAT) || (pc->flags & PC_FLAG_DMA_ERROR)) { |
| 1092 | /* Error detected */ | 1046 | /* Error detected */ |
| 1093 | debug_log(DBG_ERR, "%s: I/O error\n", tape->name); | 1047 | debug_log(DBG_ERR, "%s: I/O error\n", tape->name); |
| 1094 | 1048 | ||
| @@ -1104,7 +1058,7 @@ static ide_startstop_t idetape_pc_intr(ide_drive_t *drive) | |||
| 1104 | return idetape_retry_pc(drive); | 1058 | return idetape_retry_pc(drive); |
| 1105 | } | 1059 | } |
| 1106 | pc->error = 0; | 1060 | pc->error = 0; |
| 1107 | if (test_bit(PC_WAIT_FOR_DSC, &pc->flags) && | 1061 | if ((pc->flags & PC_FLAG_WAIT_FOR_DSC) && |
| 1108 | (stat & SEEK_STAT) == 0) { | 1062 | (stat & SEEK_STAT) == 0) { |
| 1109 | /* Media access command */ | 1063 | /* Media access command */ |
| 1110 | tape->dsc_polling_start = jiffies; | 1064 | tape->dsc_polling_start = jiffies; |
| @@ -1117,9 +1071,11 @@ static ide_startstop_t idetape_pc_intr(ide_drive_t *drive) | |||
| 1117 | if (tape->failed_pc == pc) | 1071 | if (tape->failed_pc == pc) |
| 1118 | tape->failed_pc = NULL; | 1072 | tape->failed_pc = NULL; |
| 1119 | /* Command finished - Call the callback function */ | 1073 | /* Command finished - Call the callback function */ |
| 1120 | return pc->callback(drive); | 1074 | return pc->idetape_callback(drive); |
| 1121 | } | 1075 | } |
| 1122 | if (test_and_clear_bit(PC_DMA_IN_PROGRESS, &pc->flags)) { | 1076 | |
| 1077 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { | ||
| 1078 | pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; | ||
| 1123 | printk(KERN_ERR "ide-tape: The tape wants to issue more " | 1079 | printk(KERN_ERR "ide-tape: The tape wants to issue more " |
| 1124 | "interrupts in DMA mode\n"); | 1080 | "interrupts in DMA mode\n"); |
| 1125 | printk(KERN_ERR "ide-tape: DMA disabled, reverting to PIO\n"); | 1081 | printk(KERN_ERR "ide-tape: DMA disabled, reverting to PIO\n"); |
| @@ -1127,16 +1083,16 @@ static ide_startstop_t idetape_pc_intr(ide_drive_t *drive) | |||
| 1127 | return ide_do_reset(drive); | 1083 | return ide_do_reset(drive); |
| 1128 | } | 1084 | } |
| 1129 | /* Get the number of bytes to transfer on this interrupt. */ | 1085 | /* Get the number of bytes to transfer on this interrupt. */ |
| 1130 | bcount = (hwif->INB(IDE_BCOUNTH_REG) << 8) | | 1086 | bcount = (hwif->INB(hwif->io_ports[IDE_BCOUNTH_OFFSET]) << 8) | |
| 1131 | hwif->INB(IDE_BCOUNTL_REG); | 1087 | hwif->INB(hwif->io_ports[IDE_BCOUNTL_OFFSET]); |
| 1132 | 1088 | ||
| 1133 | ireason = hwif->INB(IDE_IREASON_REG); | 1089 | ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]); |
| 1134 | 1090 | ||
| 1135 | if (ireason & CD) { | 1091 | if (ireason & CD) { |
| 1136 | printk(KERN_ERR "ide-tape: CoD != 0 in %s\n", __func__); | 1092 | printk(KERN_ERR "ide-tape: CoD != 0 in %s\n", __func__); |
| 1137 | return ide_do_reset(drive); | 1093 | return ide_do_reset(drive); |
| 1138 | } | 1094 | } |
| 1139 | if (((ireason & IO) == IO) == test_bit(PC_WRITING, &pc->flags)) { | 1095 | if (((ireason & IO) == IO) == !!(pc->flags & PC_FLAG_WRITING)) { |
| 1140 | /* Hopefully, we will never get here */ | 1096 | /* Hopefully, we will never get here */ |
| 1141 | printk(KERN_ERR "ide-tape: We wanted to %s, ", | 1097 | printk(KERN_ERR "ide-tape: We wanted to %s, ", |
| 1142 | (ireason & IO) ? "Write" : "Read"); | 1098 | (ireason & IO) ? "Write" : "Read"); |
| @@ -1144,15 +1100,15 @@ static ide_startstop_t idetape_pc_intr(ide_drive_t *drive) | |||
| 1144 | (ireason & IO) ? "Read" : "Write"); | 1100 | (ireason & IO) ? "Read" : "Write"); |
| 1145 | return ide_do_reset(drive); | 1101 | return ide_do_reset(drive); |
| 1146 | } | 1102 | } |
| 1147 | if (!test_bit(PC_WRITING, &pc->flags)) { | 1103 | if (!(pc->flags & PC_FLAG_WRITING)) { |
| 1148 | /* Reading - Check that we have enough space */ | 1104 | /* Reading - Check that we have enough space */ |
| 1149 | temp = pc->actually_transferred + bcount; | 1105 | temp = pc->xferred + bcount; |
| 1150 | if (temp > pc->request_transfer) { | 1106 | if (temp > pc->req_xfer) { |
| 1151 | if (temp > pc->buffer_size) { | 1107 | if (temp > pc->buf_size) { |
| 1152 | printk(KERN_ERR "ide-tape: The tape wants to " | 1108 | printk(KERN_ERR "ide-tape: The tape wants to " |
| 1153 | "send us more data than expected " | 1109 | "send us more data than expected " |
| 1154 | "- discarding data\n"); | 1110 | "- discarding data\n"); |
| 1155 | idetape_discard_data(drive, bcount); | 1111 | ide_atapi_discard_data(drive, bcount); |
| 1156 | ide_set_handler(drive, &idetape_pc_intr, | 1112 | ide_set_handler(drive, &idetape_pc_intr, |
| 1157 | IDETAPE_WAIT_CMD, NULL); | 1113 | IDETAPE_WAIT_CMD, NULL); |
| 1158 | return ide_started; | 1114 | return ide_started; |
| @@ -1170,11 +1126,11 @@ static ide_startstop_t idetape_pc_intr(ide_drive_t *drive) | |||
| 1170 | if (pc->bh) | 1126 | if (pc->bh) |
| 1171 | iobuf(drive, pc, bcount); | 1127 | iobuf(drive, pc, bcount); |
| 1172 | else | 1128 | else |
| 1173 | xferfunc(drive, pc->current_position, bcount); | 1129 | xferfunc(drive, pc->cur_pos, bcount); |
| 1174 | 1130 | ||
| 1175 | /* Update the current position */ | 1131 | /* Update the current position */ |
| 1176 | pc->actually_transferred += bcount; | 1132 | pc->xferred += bcount; |
| 1177 | pc->current_position += bcount; | 1133 | pc->cur_pos += bcount; |
| 1178 | 1134 | ||
| 1179 | debug_log(DBG_SENSE, "[cmd %x] transferred %d bytes on that intr.\n", | 1135 | debug_log(DBG_SENSE, "[cmd %x] transferred %d bytes on that intr.\n", |
| 1180 | pc->c[0], bcount); | 1136 | pc->c[0], bcount); |
| @@ -1224,7 +1180,7 @@ static ide_startstop_t idetape_transfer_pc(ide_drive_t *drive) | |||
| 1224 | { | 1180 | { |
| 1225 | ide_hwif_t *hwif = drive->hwif; | 1181 | ide_hwif_t *hwif = drive->hwif; |
| 1226 | idetape_tape_t *tape = drive->driver_data; | 1182 | idetape_tape_t *tape = drive->driver_data; |
| 1227 | idetape_pc_t *pc = tape->pc; | 1183 | struct ide_atapi_pc *pc = tape->pc; |
| 1228 | int retries = 100; | 1184 | int retries = 100; |
| 1229 | ide_startstop_t startstop; | 1185 | ide_startstop_t startstop; |
| 1230 | u8 ireason; | 1186 | u8 ireason; |
| @@ -1234,12 +1190,12 @@ static ide_startstop_t idetape_transfer_pc(ide_drive_t *drive) | |||
| 1234 | "yet DRQ isn't asserted\n"); | 1190 | "yet DRQ isn't asserted\n"); |
| 1235 | return startstop; | 1191 | return startstop; |
| 1236 | } | 1192 | } |
| 1237 | ireason = hwif->INB(IDE_IREASON_REG); | 1193 | ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]); |
| 1238 | while (retries-- && ((ireason & CD) == 0 || (ireason & IO))) { | 1194 | while (retries-- && ((ireason & CD) == 0 || (ireason & IO))) { |
| 1239 | printk(KERN_ERR "ide-tape: (IO,CoD != (0,1) while issuing " | 1195 | printk(KERN_ERR "ide-tape: (IO,CoD != (0,1) while issuing " |
| 1240 | "a packet command, retrying\n"); | 1196 | "a packet command, retrying\n"); |
| 1241 | udelay(100); | 1197 | udelay(100); |
| 1242 | ireason = hwif->INB(IDE_IREASON_REG); | 1198 | ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]); |
| 1243 | if (retries == 0) { | 1199 | if (retries == 0) { |
| 1244 | printk(KERN_ERR "ide-tape: (IO,CoD != (0,1) while " | 1200 | printk(KERN_ERR "ide-tape: (IO,CoD != (0,1) while " |
| 1245 | "issuing a packet command, ignoring\n"); | 1201 | "issuing a packet command, ignoring\n"); |
| @@ -1256,7 +1212,7 @@ static ide_startstop_t idetape_transfer_pc(ide_drive_t *drive) | |||
| 1256 | ide_set_handler(drive, &idetape_pc_intr, IDETAPE_WAIT_CMD, NULL); | 1212 | ide_set_handler(drive, &idetape_pc_intr, IDETAPE_WAIT_CMD, NULL); |
| 1257 | #ifdef CONFIG_BLK_DEV_IDEDMA | 1213 | #ifdef CONFIG_BLK_DEV_IDEDMA |
| 1258 | /* Begin DMA, if necessary */ | 1214 | /* Begin DMA, if necessary */ |
| 1259 | if (test_bit(PC_DMA_IN_PROGRESS, &pc->flags)) | 1215 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) |
| 1260 | hwif->dma_start(drive); | 1216 | hwif->dma_start(drive); |
| 1261 | #endif | 1217 | #endif |
| 1262 | /* Send the actual packet */ | 1218 | /* Send the actual packet */ |
| @@ -1264,7 +1220,8 @@ static ide_startstop_t idetape_transfer_pc(ide_drive_t *drive) | |||
| 1264 | return ide_started; | 1220 | return ide_started; |
| 1265 | } | 1221 | } |
| 1266 | 1222 | ||
| 1267 | static ide_startstop_t idetape_issue_pc(ide_drive_t *drive, idetape_pc_t *pc) | 1223 | static ide_startstop_t idetape_issue_pc(ide_drive_t *drive, |
| 1224 | struct ide_atapi_pc *pc) | ||
| 1268 | { | 1225 | { |
| 1269 | ide_hwif_t *hwif = drive->hwif; | 1226 | ide_hwif_t *hwif = drive->hwif; |
| 1270 | idetape_tape_t *tape = drive->driver_data; | 1227 | idetape_tape_t *tape = drive->driver_data; |
| @@ -1283,13 +1240,13 @@ static ide_startstop_t idetape_issue_pc(ide_drive_t *drive, idetape_pc_t *pc) | |||
| 1283 | tape->pc = pc; | 1240 | tape->pc = pc; |
| 1284 | 1241 | ||
| 1285 | if (pc->retries > IDETAPE_MAX_PC_RETRIES || | 1242 | if (pc->retries > IDETAPE_MAX_PC_RETRIES || |
| 1286 | test_bit(PC_ABORT, &pc->flags)) { | 1243 | (pc->flags & PC_FLAG_ABORT)) { |
| 1287 | /* | 1244 | /* |
| 1288 | * We will "abort" retrying a packet command in case legitimate | 1245 | * We will "abort" retrying a packet command in case legitimate |
| 1289 | * error code was received (crossing a filemark, or end of the | 1246 | * error code was received (crossing a filemark, or end of the |
| 1290 | * media, for example). | 1247 | * media, for example). |
| 1291 | */ | 1248 | */ |
| 1292 | if (!test_bit(PC_ABORT, &pc->flags)) { | 1249 | if (!(pc->flags & PC_FLAG_ABORT)) { |
| 1293 | if (!(pc->c[0] == TEST_UNIT_READY && | 1250 | if (!(pc->c[0] == TEST_UNIT_READY && |
| 1294 | tape->sense_key == 2 && tape->asc == 4 && | 1251 | tape->sense_key == 2 && tape->asc == 4 && |
| 1295 | (tape->ascq == 1 || tape->ascq == 8))) { | 1252 | (tape->ascq == 1 || tape->ascq == 8))) { |
| @@ -1304,36 +1261,38 @@ static ide_startstop_t idetape_issue_pc(ide_drive_t *drive, idetape_pc_t *pc) | |||
| 1304 | pc->error = IDETAPE_ERROR_GENERAL; | 1261 | pc->error = IDETAPE_ERROR_GENERAL; |
| 1305 | } | 1262 | } |
| 1306 | tape->failed_pc = NULL; | 1263 | tape->failed_pc = NULL; |
| 1307 | return pc->callback(drive); | 1264 | return pc->idetape_callback(drive); |
| 1308 | } | 1265 | } |
| 1309 | debug_log(DBG_SENSE, "Retry #%d, cmd = %02X\n", pc->retries, pc->c[0]); | 1266 | debug_log(DBG_SENSE, "Retry #%d, cmd = %02X\n", pc->retries, pc->c[0]); |
| 1310 | 1267 | ||
| 1311 | pc->retries++; | 1268 | pc->retries++; |
| 1312 | /* We haven't transferred any data yet */ | 1269 | /* We haven't transferred any data yet */ |
| 1313 | pc->actually_transferred = 0; | 1270 | pc->xferred = 0; |
| 1314 | pc->current_position = pc->buffer; | 1271 | pc->cur_pos = pc->buf; |
| 1315 | /* Request to transfer the entire buffer at once */ | 1272 | /* Request to transfer the entire buffer at once */ |
| 1316 | bcount = pc->request_transfer; | 1273 | bcount = pc->req_xfer; |
| 1317 | 1274 | ||
| 1318 | if (test_and_clear_bit(PC_DMA_ERROR, &pc->flags)) { | 1275 | if (pc->flags & PC_FLAG_DMA_ERROR) { |
| 1276 | pc->flags &= ~PC_FLAG_DMA_ERROR; | ||
| 1319 | printk(KERN_WARNING "ide-tape: DMA disabled, " | 1277 | printk(KERN_WARNING "ide-tape: DMA disabled, " |
| 1320 | "reverting to PIO\n"); | 1278 | "reverting to PIO\n"); |
| 1321 | ide_dma_off(drive); | 1279 | ide_dma_off(drive); |
| 1322 | } | 1280 | } |
| 1323 | if (test_bit(PC_DMA_RECOMMENDED, &pc->flags) && drive->using_dma) | 1281 | if ((pc->flags & PC_FLAG_DMA_RECOMMENDED) && drive->using_dma) |
| 1324 | dma_ok = !hwif->dma_setup(drive); | 1282 | dma_ok = !hwif->dma_setup(drive); |
| 1325 | 1283 | ||
| 1326 | ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK | | 1284 | ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK | |
| 1327 | IDE_TFLAG_OUT_DEVICE, bcount, dma_ok); | 1285 | IDE_TFLAG_OUT_DEVICE, bcount, dma_ok); |
| 1328 | 1286 | ||
| 1329 | if (dma_ok) /* Will begin DMA later */ | 1287 | if (dma_ok) |
| 1330 | set_bit(PC_DMA_IN_PROGRESS, &pc->flags); | 1288 | /* Will begin DMA later */ |
| 1331 | if (test_bit(IDETAPE_DRQ_INTERRUPT, &tape->flags)) { | 1289 | pc->flags |= PC_FLAG_DMA_IN_PROGRESS; |
| 1290 | if (test_bit(IDETAPE_FLAG_DRQ_INTERRUPT, &tape->flags)) { | ||
| 1332 | ide_execute_command(drive, WIN_PACKETCMD, &idetape_transfer_pc, | 1291 | ide_execute_command(drive, WIN_PACKETCMD, &idetape_transfer_pc, |
| 1333 | IDETAPE_WAIT_CMD, NULL); | 1292 | IDETAPE_WAIT_CMD, NULL); |
| 1334 | return ide_started; | 1293 | return ide_started; |
| 1335 | } else { | 1294 | } else { |
| 1336 | hwif->OUTB(WIN_PACKETCMD, IDE_COMMAND_REG); | 1295 | hwif->OUTB(WIN_PACKETCMD, hwif->io_ports[IDE_COMMAND_OFFSET]); |
| 1337 | return idetape_transfer_pc(drive); | 1296 | return idetape_transfer_pc(drive); |
| 1338 | } | 1297 | } |
| 1339 | } | 1298 | } |
| @@ -1349,7 +1308,7 @@ static ide_startstop_t idetape_pc_callback(ide_drive_t *drive) | |||
| 1349 | } | 1308 | } |
| 1350 | 1309 | ||
| 1351 | /* A mode sense command is used to "sense" tape parameters. */ | 1310 | /* A mode sense command is used to "sense" tape parameters. */ |
| 1352 | static void idetape_create_mode_sense_cmd(idetape_pc_t *pc, u8 page_code) | 1311 | static void idetape_create_mode_sense_cmd(struct ide_atapi_pc *pc, u8 page_code) |
| 1353 | { | 1312 | { |
| 1354 | idetape_init_pc(pc); | 1313 | idetape_init_pc(pc); |
| 1355 | pc->c[0] = MODE_SENSE; | 1314 | pc->c[0] = MODE_SENSE; |
| @@ -1368,12 +1327,12 @@ static void idetape_create_mode_sense_cmd(idetape_pc_t *pc, u8 page_code) | |||
| 1368 | /* We will just discard data in that case */ | 1327 | /* We will just discard data in that case */ |
| 1369 | pc->c[4] = 255; | 1328 | pc->c[4] = 255; |
| 1370 | if (page_code == IDETAPE_BLOCK_DESCRIPTOR) | 1329 | if (page_code == IDETAPE_BLOCK_DESCRIPTOR) |
| 1371 | pc->request_transfer = 12; | 1330 | pc->req_xfer = 12; |
| 1372 | else if (page_code == IDETAPE_CAPABILITIES_PAGE) | 1331 | else if (page_code == IDETAPE_CAPABILITIES_PAGE) |
| 1373 | pc->request_transfer = 24; | 1332 | pc->req_xfer = 24; |
| 1374 | else | 1333 | else |
| 1375 | pc->request_transfer = 50; | 1334 | pc->req_xfer = 50; |
| 1376 | pc->callback = &idetape_pc_callback; | 1335 | pc->idetape_callback = &idetape_pc_callback; |
| 1377 | } | 1336 | } |
| 1378 | 1337 | ||
| 1379 | static void idetape_calculate_speeds(ide_drive_t *drive) | 1338 | static void idetape_calculate_speeds(ide_drive_t *drive) |
| @@ -1442,7 +1401,7 @@ static void idetape_calculate_speeds(ide_drive_t *drive) | |||
| 1442 | static ide_startstop_t idetape_media_access_finished(ide_drive_t *drive) | 1401 | static ide_startstop_t idetape_media_access_finished(ide_drive_t *drive) |
| 1443 | { | 1402 | { |
| 1444 | idetape_tape_t *tape = drive->driver_data; | 1403 | idetape_tape_t *tape = drive->driver_data; |
| 1445 | idetape_pc_t *pc = tape->pc; | 1404 | struct ide_atapi_pc *pc = tape->pc; |
| 1446 | u8 stat; | 1405 | u8 stat; |
| 1447 | 1406 | ||
| 1448 | stat = ide_read_status(drive); | 1407 | stat = ide_read_status(drive); |
| @@ -1463,14 +1422,14 @@ static ide_startstop_t idetape_media_access_finished(ide_drive_t *drive) | |||
| 1463 | pc->error = IDETAPE_ERROR_GENERAL; | 1422 | pc->error = IDETAPE_ERROR_GENERAL; |
| 1464 | tape->failed_pc = NULL; | 1423 | tape->failed_pc = NULL; |
| 1465 | } | 1424 | } |
| 1466 | return pc->callback(drive); | 1425 | return pc->idetape_callback(drive); |
| 1467 | } | 1426 | } |
| 1468 | 1427 | ||
| 1469 | static ide_startstop_t idetape_rw_callback(ide_drive_t *drive) | 1428 | static ide_startstop_t idetape_rw_callback(ide_drive_t *drive) |
| 1470 | { | 1429 | { |
| 1471 | idetape_tape_t *tape = drive->driver_data; | 1430 | idetape_tape_t *tape = drive->driver_data; |
| 1472 | struct request *rq = HWGROUP(drive)->rq; | 1431 | struct request *rq = HWGROUP(drive)->rq; |
| 1473 | int blocks = tape->pc->actually_transferred / tape->blk_size; | 1432 | int blocks = tape->pc->xferred / tape->blk_size; |
| 1474 | 1433 | ||
| 1475 | tape->avg_size += blocks * tape->blk_size; | 1434 | tape->avg_size += blocks * tape->blk_size; |
| 1476 | tape->insert_size += blocks * tape->blk_size; | 1435 | tape->insert_size += blocks * tape->blk_size; |
| @@ -1502,47 +1461,49 @@ static ide_startstop_t idetape_rw_callback(ide_drive_t *drive) | |||
| 1502 | return ide_stopped; | 1461 | return ide_stopped; |
| 1503 | } | 1462 | } |
| 1504 | 1463 | ||
| 1505 | static void idetape_create_read_cmd(idetape_tape_t *tape, idetape_pc_t *pc, | 1464 | static void idetape_create_read_cmd(idetape_tape_t *tape, |
| 1465 | struct ide_atapi_pc *pc, | ||
| 1506 | unsigned int length, struct idetape_bh *bh) | 1466 | unsigned int length, struct idetape_bh *bh) |
| 1507 | { | 1467 | { |
| 1508 | idetape_init_pc(pc); | 1468 | idetape_init_pc(pc); |
| 1509 | pc->c[0] = READ_6; | 1469 | pc->c[0] = READ_6; |
| 1510 | put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]); | 1470 | put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]); |
| 1511 | pc->c[1] = 1; | 1471 | pc->c[1] = 1; |
| 1512 | pc->callback = &idetape_rw_callback; | 1472 | pc->idetape_callback = &idetape_rw_callback; |
| 1513 | pc->bh = bh; | 1473 | pc->bh = bh; |
| 1514 | atomic_set(&bh->b_count, 0); | 1474 | atomic_set(&bh->b_count, 0); |
| 1515 | pc->buffer = NULL; | 1475 | pc->buf = NULL; |
| 1516 | pc->buffer_size = length * tape->blk_size; | 1476 | pc->buf_size = length * tape->blk_size; |
| 1517 | pc->request_transfer = pc->buffer_size; | 1477 | pc->req_xfer = pc->buf_size; |
| 1518 | if (pc->request_transfer == tape->stage_size) | 1478 | if (pc->req_xfer == tape->stage_size) |
| 1519 | set_bit(PC_DMA_RECOMMENDED, &pc->flags); | 1479 | pc->flags |= PC_FLAG_DMA_RECOMMENDED; |
| 1520 | } | 1480 | } |
| 1521 | 1481 | ||
| 1522 | static void idetape_create_write_cmd(idetape_tape_t *tape, idetape_pc_t *pc, | 1482 | static void idetape_create_write_cmd(idetape_tape_t *tape, |
| 1483 | struct ide_atapi_pc *pc, | ||
| 1523 | unsigned int length, struct idetape_bh *bh) | 1484 | unsigned int length, struct idetape_bh *bh) |
| 1524 | { | 1485 | { |
| 1525 | idetape_init_pc(pc); | 1486 | idetape_init_pc(pc); |
| 1526 | pc->c[0] = WRITE_6; | 1487 | pc->c[0] = WRITE_6; |
| 1527 | put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]); | 1488 | put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]); |
| 1528 | pc->c[1] = 1; | 1489 | pc->c[1] = 1; |
| 1529 | pc->callback = &idetape_rw_callback; | 1490 | pc->idetape_callback = &idetape_rw_callback; |
| 1530 | set_bit(PC_WRITING, &pc->flags); | 1491 | pc->flags |= PC_FLAG_WRITING; |
| 1531 | pc->bh = bh; | 1492 | pc->bh = bh; |
| 1532 | pc->b_data = bh->b_data; | 1493 | pc->b_data = bh->b_data; |
| 1533 | pc->b_count = atomic_read(&bh->b_count); | 1494 | pc->b_count = atomic_read(&bh->b_count); |
| 1534 | pc->buffer = NULL; | 1495 | pc->buf = NULL; |
| 1535 | pc->buffer_size = length * tape->blk_size; | 1496 | pc->buf_size = length * tape->blk_size; |
| 1536 | pc->request_transfer = pc->buffer_size; | 1497 | pc->req_xfer = pc->buf_size; |
| 1537 | if (pc->request_transfer == tape->stage_size) | 1498 | if (pc->req_xfer == tape->stage_size) |
| 1538 | set_bit(PC_DMA_RECOMMENDED, &pc->flags); | 1499 | pc->flags |= PC_FLAG_DMA_RECOMMENDED; |
| 1539 | } | 1500 | } |
| 1540 | 1501 | ||
| 1541 | static ide_startstop_t idetape_do_request(ide_drive_t *drive, | 1502 | static ide_startstop_t idetape_do_request(ide_drive_t *drive, |
| 1542 | struct request *rq, sector_t block) | 1503 | struct request *rq, sector_t block) |
| 1543 | { | 1504 | { |
| 1544 | idetape_tape_t *tape = drive->driver_data; | 1505 | idetape_tape_t *tape = drive->driver_data; |
| 1545 | idetape_pc_t *pc = NULL; | 1506 | struct ide_atapi_pc *pc = NULL; |
| 1546 | struct request *postponed_rq = tape->postponed_rq; | 1507 | struct request *postponed_rq = tape->postponed_rq; |
| 1547 | u8 stat; | 1508 | u8 stat; |
| 1548 | 1509 | ||
| @@ -1579,10 +1540,10 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
| 1579 | stat = ide_read_status(drive); | 1540 | stat = ide_read_status(drive); |
| 1580 | 1541 | ||
| 1581 | if (!drive->dsc_overlap && !(rq->cmd[0] & REQ_IDETAPE_PC2)) | 1542 | if (!drive->dsc_overlap && !(rq->cmd[0] & REQ_IDETAPE_PC2)) |
| 1582 | set_bit(IDETAPE_IGNORE_DSC, &tape->flags); | 1543 | set_bit(IDETAPE_FLAG_IGNORE_DSC, &tape->flags); |
| 1583 | 1544 | ||
| 1584 | if (drive->post_reset == 1) { | 1545 | if (drive->post_reset == 1) { |
| 1585 | set_bit(IDETAPE_IGNORE_DSC, &tape->flags); | 1546 | set_bit(IDETAPE_FLAG_IGNORE_DSC, &tape->flags); |
| 1586 | drive->post_reset = 0; | 1547 | drive->post_reset = 0; |
| 1587 | } | 1548 | } |
| 1588 | 1549 | ||
| @@ -1590,7 +1551,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
| 1590 | tape->insert_speed = tape->insert_size / 1024 * HZ / | 1551 | tape->insert_speed = tape->insert_size / 1024 * HZ / |
| 1591 | (jiffies - tape->insert_time); | 1552 | (jiffies - tape->insert_time); |
| 1592 | idetape_calculate_speeds(drive); | 1553 | idetape_calculate_speeds(drive); |
| 1593 | if (!test_and_clear_bit(IDETAPE_IGNORE_DSC, &tape->flags) && | 1554 | if (!test_and_clear_bit(IDETAPE_FLAG_IGNORE_DSC, &tape->flags) && |
| 1594 | (stat & SEEK_STAT) == 0) { | 1555 | (stat & SEEK_STAT) == 0) { |
| 1595 | if (postponed_rq == NULL) { | 1556 | if (postponed_rq == NULL) { |
| 1596 | tape->dsc_polling_start = jiffies; | 1557 | tape->dsc_polling_start = jiffies; |
| @@ -1629,7 +1590,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
| 1629 | goto out; | 1590 | goto out; |
| 1630 | } | 1591 | } |
| 1631 | if (rq->cmd[0] & REQ_IDETAPE_PC1) { | 1592 | if (rq->cmd[0] & REQ_IDETAPE_PC1) { |
| 1632 | pc = (idetape_pc_t *) rq->buffer; | 1593 | pc = (struct ide_atapi_pc *) rq->buffer; |
| 1633 | rq->cmd[0] &= ~(REQ_IDETAPE_PC1); | 1594 | rq->cmd[0] &= ~(REQ_IDETAPE_PC1); |
| 1634 | rq->cmd[0] |= REQ_IDETAPE_PC2; | 1595 | rq->cmd[0] |= REQ_IDETAPE_PC2; |
| 1635 | goto out; | 1596 | goto out; |
| @@ -1648,7 +1609,7 @@ static inline int idetape_pipeline_active(idetape_tape_t *tape) | |||
| 1648 | { | 1609 | { |
| 1649 | int rc1, rc2; | 1610 | int rc1, rc2; |
| 1650 | 1611 | ||
| 1651 | rc1 = test_bit(IDETAPE_PIPELINE_ACTIVE, &tape->flags); | 1612 | rc1 = test_bit(IDETAPE_FLAG_PIPELINE_ACTIVE, &tape->flags); |
| 1652 | rc2 = (tape->active_data_rq != NULL); | 1613 | rc2 = (tape->active_data_rq != NULL); |
| 1653 | return rc1; | 1614 | return rc1; |
| 1654 | } | 1615 | } |
| @@ -1881,7 +1842,7 @@ static void idetape_wait_for_request(ide_drive_t *drive, struct request *rq) | |||
| 1881 | static ide_startstop_t idetape_read_position_callback(ide_drive_t *drive) | 1842 | static ide_startstop_t idetape_read_position_callback(ide_drive_t *drive) |
| 1882 | { | 1843 | { |
| 1883 | idetape_tape_t *tape = drive->driver_data; | 1844 | idetape_tape_t *tape = drive->driver_data; |
| 1884 | u8 *readpos = tape->pc->buffer; | 1845 | u8 *readpos = tape->pc->buf; |
| 1885 | 1846 | ||
| 1886 | debug_log(DBG_PROCS, "Enter %s\n", __func__); | 1847 | debug_log(DBG_PROCS, "Enter %s\n", __func__); |
| 1887 | 1848 | ||
| @@ -1894,7 +1855,7 @@ static ide_startstop_t idetape_read_position_callback(ide_drive_t *drive) | |||
| 1894 | if (readpos[0] & 0x4) { | 1855 | if (readpos[0] & 0x4) { |
| 1895 | printk(KERN_INFO "ide-tape: Block location is unknown" | 1856 | printk(KERN_INFO "ide-tape: Block location is unknown" |
| 1896 | "to the tape\n"); | 1857 | "to the tape\n"); |
| 1897 | clear_bit(IDETAPE_ADDRESS_VALID, &tape->flags); | 1858 | clear_bit(IDETAPE_FLAG_ADDRESS_VALID, &tape->flags); |
| 1898 | idetape_end_request(drive, 0, 0); | 1859 | idetape_end_request(drive, 0, 0); |
| 1899 | } else { | 1860 | } else { |
| 1900 | debug_log(DBG_SENSE, "Block Location - %u\n", | 1861 | debug_log(DBG_SENSE, "Block Location - %u\n", |
| @@ -1903,7 +1864,7 @@ static ide_startstop_t idetape_read_position_callback(ide_drive_t *drive) | |||
| 1903 | tape->partition = readpos[1]; | 1864 | tape->partition = readpos[1]; |
| 1904 | tape->first_frame = | 1865 | tape->first_frame = |
| 1905 | be32_to_cpu(*(u32 *)&readpos[4]); | 1866 | be32_to_cpu(*(u32 *)&readpos[4]); |
| 1906 | set_bit(IDETAPE_ADDRESS_VALID, &tape->flags); | 1867 | set_bit(IDETAPE_FLAG_ADDRESS_VALID, &tape->flags); |
| 1907 | idetape_end_request(drive, 1, 0); | 1868 | idetape_end_request(drive, 1, 0); |
| 1908 | } | 1869 | } |
| 1909 | } else { | 1870 | } else { |
| @@ -1917,20 +1878,20 @@ static ide_startstop_t idetape_read_position_callback(ide_drive_t *drive) | |||
| 1917 | * writing a filemark otherwise. | 1878 | * writing a filemark otherwise. |
| 1918 | */ | 1879 | */ |
| 1919 | static void idetape_create_write_filemark_cmd(ide_drive_t *drive, | 1880 | static void idetape_create_write_filemark_cmd(ide_drive_t *drive, |
| 1920 | idetape_pc_t *pc, int write_filemark) | 1881 | struct ide_atapi_pc *pc, int write_filemark) |
| 1921 | { | 1882 | { |
| 1922 | idetape_init_pc(pc); | 1883 | idetape_init_pc(pc); |
| 1923 | pc->c[0] = WRITE_FILEMARKS; | 1884 | pc->c[0] = WRITE_FILEMARKS; |
| 1924 | pc->c[4] = write_filemark; | 1885 | pc->c[4] = write_filemark; |
| 1925 | set_bit(PC_WAIT_FOR_DSC, &pc->flags); | 1886 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; |
| 1926 | pc->callback = &idetape_pc_callback; | 1887 | pc->idetape_callback = &idetape_pc_callback; |
| 1927 | } | 1888 | } |
| 1928 | 1889 | ||
| 1929 | static void idetape_create_test_unit_ready_cmd(idetape_pc_t *pc) | 1890 | static void idetape_create_test_unit_ready_cmd(struct ide_atapi_pc *pc) |
| 1930 | { | 1891 | { |
| 1931 | idetape_init_pc(pc); | 1892 | idetape_init_pc(pc); |
| 1932 | pc->c[0] = TEST_UNIT_READY; | 1893 | pc->c[0] = TEST_UNIT_READY; |
| 1933 | pc->callback = &idetape_pc_callback; | 1894 | pc->idetape_callback = &idetape_pc_callback; |
| 1934 | } | 1895 | } |
| 1935 | 1896 | ||
| 1936 | /* | 1897 | /* |
| @@ -1946,7 +1907,7 @@ static void idetape_create_test_unit_ready_cmd(idetape_pc_t *pc) | |||
| 1946 | * to the request list without waiting for it to be serviced! In that case, we | 1907 | * to the request list without waiting for it to be serviced! In that case, we |
| 1947 | * usually use idetape_queue_pc_head(). | 1908 | * usually use idetape_queue_pc_head(). |
| 1948 | */ | 1909 | */ |
| 1949 | static int __idetape_queue_pc_tail(ide_drive_t *drive, idetape_pc_t *pc) | 1910 | static int __idetape_queue_pc_tail(ide_drive_t *drive, struct ide_atapi_pc *pc) |
| 1950 | { | 1911 | { |
| 1951 | struct ide_tape_obj *tape = drive->driver_data; | 1912 | struct ide_tape_obj *tape = drive->driver_data; |
| 1952 | struct request rq; | 1913 | struct request rq; |
| @@ -1957,24 +1918,24 @@ static int __idetape_queue_pc_tail(ide_drive_t *drive, idetape_pc_t *pc) | |||
| 1957 | return ide_do_drive_cmd(drive, &rq, ide_wait); | 1918 | return ide_do_drive_cmd(drive, &rq, ide_wait); |
| 1958 | } | 1919 | } |
| 1959 | 1920 | ||
| 1960 | static void idetape_create_load_unload_cmd(ide_drive_t *drive, idetape_pc_t *pc, | 1921 | static void idetape_create_load_unload_cmd(ide_drive_t *drive, |
| 1961 | int cmd) | 1922 | struct ide_atapi_pc *pc, int cmd) |
| 1962 | { | 1923 | { |
| 1963 | idetape_init_pc(pc); | 1924 | idetape_init_pc(pc); |
| 1964 | pc->c[0] = START_STOP; | 1925 | pc->c[0] = START_STOP; |
| 1965 | pc->c[4] = cmd; | 1926 | pc->c[4] = cmd; |
| 1966 | set_bit(PC_WAIT_FOR_DSC, &pc->flags); | 1927 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; |
| 1967 | pc->callback = &idetape_pc_callback; | 1928 | pc->idetape_callback = &idetape_pc_callback; |
| 1968 | } | 1929 | } |
| 1969 | 1930 | ||
| 1970 | static int idetape_wait_ready(ide_drive_t *drive, unsigned long timeout) | 1931 | static int idetape_wait_ready(ide_drive_t *drive, unsigned long timeout) |
| 1971 | { | 1932 | { |
| 1972 | idetape_tape_t *tape = drive->driver_data; | 1933 | idetape_tape_t *tape = drive->driver_data; |
| 1973 | idetape_pc_t pc; | 1934 | struct ide_atapi_pc pc; |
| 1974 | int load_attempted = 0; | 1935 | int load_attempted = 0; |
| 1975 | 1936 | ||
| 1976 | /* Wait for the tape to become ready */ | 1937 | /* Wait for the tape to become ready */ |
| 1977 | set_bit(IDETAPE_MEDIUM_PRESENT, &tape->flags); | 1938 | set_bit(IDETAPE_FLAG_MEDIUM_PRESENT, &tape->flags); |
| 1978 | timeout += jiffies; | 1939 | timeout += jiffies; |
| 1979 | while (time_before(jiffies, timeout)) { | 1940 | while (time_before(jiffies, timeout)) { |
| 1980 | idetape_create_test_unit_ready_cmd(&pc); | 1941 | idetape_create_test_unit_ready_cmd(&pc); |
| @@ -1998,14 +1959,14 @@ static int idetape_wait_ready(ide_drive_t *drive, unsigned long timeout) | |||
| 1998 | return -EIO; | 1959 | return -EIO; |
| 1999 | } | 1960 | } |
| 2000 | 1961 | ||
| 2001 | static int idetape_queue_pc_tail(ide_drive_t *drive, idetape_pc_t *pc) | 1962 | static int idetape_queue_pc_tail(ide_drive_t *drive, struct ide_atapi_pc *pc) |
| 2002 | { | 1963 | { |
| 2003 | return __idetape_queue_pc_tail(drive, pc); | 1964 | return __idetape_queue_pc_tail(drive, pc); |
| 2004 | } | 1965 | } |
| 2005 | 1966 | ||
| 2006 | static int idetape_flush_tape_buffers(ide_drive_t *drive) | 1967 | static int idetape_flush_tape_buffers(ide_drive_t *drive) |
| 2007 | { | 1968 | { |
| 2008 | idetape_pc_t pc; | 1969 | struct ide_atapi_pc pc; |
| 2009 | int rc; | 1970 | int rc; |
| 2010 | 1971 | ||
| 2011 | idetape_create_write_filemark_cmd(drive, &pc, 0); | 1972 | idetape_create_write_filemark_cmd(drive, &pc, 0); |
| @@ -2016,18 +1977,18 @@ static int idetape_flush_tape_buffers(ide_drive_t *drive) | |||
| 2016 | return 0; | 1977 | return 0; |
| 2017 | } | 1978 | } |
| 2018 | 1979 | ||
| 2019 | static void idetape_create_read_position_cmd(idetape_pc_t *pc) | 1980 | static void idetape_create_read_position_cmd(struct ide_atapi_pc *pc) |
| 2020 | { | 1981 | { |
| 2021 | idetape_init_pc(pc); | 1982 | idetape_init_pc(pc); |
| 2022 | pc->c[0] = READ_POSITION; | 1983 | pc->c[0] = READ_POSITION; |
| 2023 | pc->request_transfer = 20; | 1984 | pc->req_xfer = 20; |
| 2024 | pc->callback = &idetape_read_position_callback; | 1985 | pc->idetape_callback = &idetape_read_position_callback; |
| 2025 | } | 1986 | } |
| 2026 | 1987 | ||
| 2027 | static int idetape_read_position(ide_drive_t *drive) | 1988 | static int idetape_read_position(ide_drive_t *drive) |
| 2028 | { | 1989 | { |
| 2029 | idetape_tape_t *tape = drive->driver_data; | 1990 | idetape_tape_t *tape = drive->driver_data; |
| 2030 | idetape_pc_t pc; | 1991 | struct ide_atapi_pc pc; |
| 2031 | int position; | 1992 | int position; |
| 2032 | 1993 | ||
| 2033 | debug_log(DBG_PROCS, "Enter %s\n", __func__); | 1994 | debug_log(DBG_PROCS, "Enter %s\n", __func__); |
| @@ -2039,7 +2000,8 @@ static int idetape_read_position(ide_drive_t *drive) | |||
| 2039 | return position; | 2000 | return position; |
| 2040 | } | 2001 | } |
| 2041 | 2002 | ||
| 2042 | static void idetape_create_locate_cmd(ide_drive_t *drive, idetape_pc_t *pc, | 2003 | static void idetape_create_locate_cmd(ide_drive_t *drive, |
| 2004 | struct ide_atapi_pc *pc, | ||
| 2043 | unsigned int block, u8 partition, int skip) | 2005 | unsigned int block, u8 partition, int skip) |
| 2044 | { | 2006 | { |
| 2045 | idetape_init_pc(pc); | 2007 | idetape_init_pc(pc); |
| @@ -2047,12 +2009,12 @@ static void idetape_create_locate_cmd(ide_drive_t *drive, idetape_pc_t *pc, | |||
| 2047 | pc->c[1] = 2; | 2009 | pc->c[1] = 2; |
| 2048 | put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[3]); | 2010 | put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[3]); |
| 2049 | pc->c[8] = partition; | 2011 | pc->c[8] = partition; |
| 2050 | set_bit(PC_WAIT_FOR_DSC, &pc->flags); | 2012 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; |
| 2051 | pc->callback = &idetape_pc_callback; | 2013 | pc->idetape_callback = &idetape_pc_callback; |
| 2052 | } | 2014 | } |
| 2053 | 2015 | ||
| 2054 | static int idetape_create_prevent_cmd(ide_drive_t *drive, idetape_pc_t *pc, | 2016 | static int idetape_create_prevent_cmd(ide_drive_t *drive, |
| 2055 | int prevent) | 2017 | struct ide_atapi_pc *pc, int prevent) |
| 2056 | { | 2018 | { |
| 2057 | idetape_tape_t *tape = drive->driver_data; | 2019 | idetape_tape_t *tape = drive->driver_data; |
| 2058 | 2020 | ||
| @@ -2063,7 +2025,7 @@ static int idetape_create_prevent_cmd(ide_drive_t *drive, idetape_pc_t *pc, | |||
| 2063 | idetape_init_pc(pc); | 2025 | idetape_init_pc(pc); |
| 2064 | pc->c[0] = ALLOW_MEDIUM_REMOVAL; | 2026 | pc->c[0] = ALLOW_MEDIUM_REMOVAL; |
| 2065 | pc->c[4] = prevent; | 2027 | pc->c[4] = prevent; |
| 2066 | pc->callback = &idetape_pc_callback; | 2028 | pc->idetape_callback = &idetape_pc_callback; |
| 2067 | return 1; | 2029 | return 1; |
| 2068 | } | 2030 | } |
| 2069 | 2031 | ||
| @@ -2078,7 +2040,7 @@ static int __idetape_discard_read_pipeline(ide_drive_t *drive) | |||
| 2078 | 2040 | ||
| 2079 | /* Remove merge stage. */ | 2041 | /* Remove merge stage. */ |
| 2080 | cnt = tape->merge_stage_size / tape->blk_size; | 2042 | cnt = tape->merge_stage_size / tape->blk_size; |
| 2081 | if (test_and_clear_bit(IDETAPE_FILEMARK, &tape->flags)) | 2043 | if (test_and_clear_bit(IDETAPE_FLAG_FILEMARK, &tape->flags)) |
| 2082 | ++cnt; /* Filemarks count as 1 sector */ | 2044 | ++cnt; /* Filemarks count as 1 sector */ |
| 2083 | tape->merge_stage_size = 0; | 2045 | tape->merge_stage_size = 0; |
| 2084 | if (tape->merge_stage != NULL) { | 2046 | if (tape->merge_stage != NULL) { |
| @@ -2087,7 +2049,7 @@ static int __idetape_discard_read_pipeline(ide_drive_t *drive) | |||
| 2087 | } | 2049 | } |
| 2088 | 2050 | ||
| 2089 | /* Clear pipeline flags. */ | 2051 | /* Clear pipeline flags. */ |
| 2090 | clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags); | 2052 | clear_bit(IDETAPE_FLAG_PIPELINE_ERR, &tape->flags); |
| 2091 | tape->chrdev_dir = IDETAPE_DIR_NONE; | 2053 | tape->chrdev_dir = IDETAPE_DIR_NONE; |
| 2092 | 2054 | ||
| 2093 | /* Remove pipeline stages. */ | 2055 | /* Remove pipeline stages. */ |
| @@ -2124,7 +2086,7 @@ static int idetape_position_tape(ide_drive_t *drive, unsigned int block, | |||
| 2124 | { | 2086 | { |
| 2125 | idetape_tape_t *tape = drive->driver_data; | 2087 | idetape_tape_t *tape = drive->driver_data; |
| 2126 | int retval; | 2088 | int retval; |
| 2127 | idetape_pc_t pc; | 2089 | struct ide_atapi_pc pc; |
| 2128 | 2090 | ||
| 2129 | if (tape->chrdev_dir == IDETAPE_DIR_READ) | 2091 | if (tape->chrdev_dir == IDETAPE_DIR_READ) |
| 2130 | __idetape_discard_read_pipeline(drive); | 2092 | __idetape_discard_read_pipeline(drive); |
| @@ -2201,46 +2163,47 @@ static void idetape_plug_pipeline(ide_drive_t *drive) | |||
| 2201 | if (tape->next_stage == NULL) | 2163 | if (tape->next_stage == NULL) |
| 2202 | return; | 2164 | return; |
| 2203 | if (!idetape_pipeline_active(tape)) { | 2165 | if (!idetape_pipeline_active(tape)) { |
| 2204 | set_bit(IDETAPE_PIPELINE_ACTIVE, &tape->flags); | 2166 | set_bit(IDETAPE_FLAG_PIPELINE_ACTIVE, &tape->flags); |
| 2205 | idetape_activate_next_stage(drive); | 2167 | idetape_activate_next_stage(drive); |
| 2206 | (void) ide_do_drive_cmd(drive, tape->active_data_rq, ide_end); | 2168 | (void) ide_do_drive_cmd(drive, tape->active_data_rq, ide_end); |
| 2207 | } | 2169 | } |
| 2208 | } | 2170 | } |
| 2209 | 2171 | ||
| 2210 | static void idetape_create_inquiry_cmd(idetape_pc_t *pc) | 2172 | static void idetape_create_inquiry_cmd(struct ide_atapi_pc *pc) |
| 2211 | { | 2173 | { |
| 2212 | idetape_init_pc(pc); | 2174 | idetape_init_pc(pc); |
| 2213 | pc->c[0] = INQUIRY; | 2175 | pc->c[0] = INQUIRY; |
| 2214 | pc->c[4] = 254; | 2176 | pc->c[4] = 254; |
| 2215 | pc->request_transfer = 254; | 2177 | pc->req_xfer = 254; |
| 2216 | pc->callback = &idetape_pc_callback; | 2178 | pc->idetape_callback = &idetape_pc_callback; |
| 2217 | } | 2179 | } |
| 2218 | 2180 | ||
| 2219 | static void idetape_create_rewind_cmd(ide_drive_t *drive, idetape_pc_t *pc) | 2181 | static void idetape_create_rewind_cmd(ide_drive_t *drive, |
| 2182 | struct ide_atapi_pc *pc) | ||
| 2220 | { | 2183 | { |
| 2221 | idetape_init_pc(pc); | 2184 | idetape_init_pc(pc); |
| 2222 | pc->c[0] = REZERO_UNIT; | 2185 | pc->c[0] = REZERO_UNIT; |
| 2223 | set_bit(PC_WAIT_FOR_DSC, &pc->flags); | 2186 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; |
| 2224 | pc->callback = &idetape_pc_callback; | 2187 | pc->idetape_callback = &idetape_pc_callback; |
| 2225 | } | 2188 | } |
| 2226 | 2189 | ||
| 2227 | static void idetape_create_erase_cmd(idetape_pc_t *pc) | 2190 | static void idetape_create_erase_cmd(struct ide_atapi_pc *pc) |
| 2228 | { | 2191 | { |
| 2229 | idetape_init_pc(pc); | 2192 | idetape_init_pc(pc); |
| 2230 | pc->c[0] = ERASE; | 2193 | pc->c[0] = ERASE; |
| 2231 | pc->c[1] = 1; | 2194 | pc->c[1] = 1; |
| 2232 | set_bit(PC_WAIT_FOR_DSC, &pc->flags); | 2195 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; |
| 2233 | pc->callback = &idetape_pc_callback; | 2196 | pc->idetape_callback = &idetape_pc_callback; |
| 2234 | } | 2197 | } |
| 2235 | 2198 | ||
| 2236 | static void idetape_create_space_cmd(idetape_pc_t *pc, int count, u8 cmd) | 2199 | static void idetape_create_space_cmd(struct ide_atapi_pc *pc, int count, u8 cmd) |
| 2237 | { | 2200 | { |
| 2238 | idetape_init_pc(pc); | 2201 | idetape_init_pc(pc); |
| 2239 | pc->c[0] = SPACE; | 2202 | pc->c[0] = SPACE; |
| 2240 | put_unaligned(cpu_to_be32(count), (unsigned int *) &pc->c[1]); | 2203 | put_unaligned(cpu_to_be32(count), (unsigned int *) &pc->c[1]); |
| 2241 | pc->c[1] = cmd; | 2204 | pc->c[1] = cmd; |
| 2242 | set_bit(PC_WAIT_FOR_DSC, &pc->flags); | 2205 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; |
| 2243 | pc->callback = &idetape_pc_callback; | 2206 | pc->idetape_callback = &idetape_pc_callback; |
| 2244 | } | 2207 | } |
| 2245 | 2208 | ||
| 2246 | static void idetape_wait_first_stage(ide_drive_t *drive) | 2209 | static void idetape_wait_first_stage(ide_drive_t *drive) |
| @@ -2326,7 +2289,7 @@ static int idetape_add_chrdev_write_request(ide_drive_t *drive, int blocks) | |||
| 2326 | idetape_plug_pipeline(drive); | 2289 | idetape_plug_pipeline(drive); |
| 2327 | } | 2290 | } |
| 2328 | } | 2291 | } |
| 2329 | if (test_and_clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags)) | 2292 | if (test_and_clear_bit(IDETAPE_FLAG_PIPELINE_ERR, &tape->flags)) |
| 2330 | /* Return a deferred error */ | 2293 | /* Return a deferred error */ |
| 2331 | return -EIO; | 2294 | return -EIO; |
| 2332 | return blocks; | 2295 | return blocks; |
| @@ -2402,7 +2365,7 @@ static void idetape_empty_write_pipeline(ide_drive_t *drive) | |||
| 2402 | __idetape_kfree_stage(tape->merge_stage); | 2365 | __idetape_kfree_stage(tape->merge_stage); |
| 2403 | tape->merge_stage = NULL; | 2366 | tape->merge_stage = NULL; |
| 2404 | } | 2367 | } |
| 2405 | clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags); | 2368 | clear_bit(IDETAPE_FLAG_PIPELINE_ERR, &tape->flags); |
| 2406 | tape->chrdev_dir = IDETAPE_DIR_NONE; | 2369 | tape->chrdev_dir = IDETAPE_DIR_NONE; |
| 2407 | 2370 | ||
| 2408 | /* | 2371 | /* |
| @@ -2490,7 +2453,7 @@ static int idetape_init_read(ide_drive_t *drive, int max_stages) | |||
| 2490 | rq.sector = tape->first_frame; | 2453 | rq.sector = tape->first_frame; |
| 2491 | rq.nr_sectors = blocks; | 2454 | rq.nr_sectors = blocks; |
| 2492 | rq.current_nr_sectors = blocks; | 2455 | rq.current_nr_sectors = blocks; |
| 2493 | if (!test_bit(IDETAPE_PIPELINE_ERROR, &tape->flags) && | 2456 | if (!test_bit(IDETAPE_FLAG_PIPELINE_ERR, &tape->flags) && |
| 2494 | tape->nr_stages < max_stages) { | 2457 | tape->nr_stages < max_stages) { |
| 2495 | new_stage = idetape_kmalloc_stage(tape); | 2458 | new_stage = idetape_kmalloc_stage(tape); |
| 2496 | while (new_stage != NULL) { | 2459 | while (new_stage != NULL) { |
| @@ -2527,13 +2490,13 @@ static int idetape_add_chrdev_read_request(ide_drive_t *drive, int blocks) | |||
| 2527 | debug_log(DBG_PROCS, "Enter %s, %d blocks\n", __func__, blocks); | 2490 | debug_log(DBG_PROCS, "Enter %s, %d blocks\n", __func__, blocks); |
| 2528 | 2491 | ||
| 2529 | /* If we are at a filemark, return a read length of 0 */ | 2492 | /* If we are at a filemark, return a read length of 0 */ |
| 2530 | if (test_bit(IDETAPE_FILEMARK, &tape->flags)) | 2493 | if (test_bit(IDETAPE_FLAG_FILEMARK, &tape->flags)) |
| 2531 | return 0; | 2494 | return 0; |
| 2532 | 2495 | ||
| 2533 | /* Wait for the next block to reach the head of the pipeline. */ | 2496 | /* Wait for the next block to reach the head of the pipeline. */ |
| 2534 | idetape_init_read(drive, tape->max_stages); | 2497 | idetape_init_read(drive, tape->max_stages); |
| 2535 | if (tape->first_stage == NULL) { | 2498 | if (tape->first_stage == NULL) { |
| 2536 | if (test_bit(IDETAPE_PIPELINE_ERROR, &tape->flags)) | 2499 | if (test_bit(IDETAPE_FLAG_PIPELINE_ERR, &tape->flags)) |
| 2537 | return 0; | 2500 | return 0; |
| 2538 | return idetape_queue_rw_tail(drive, REQ_IDETAPE_READ, blocks, | 2501 | return idetape_queue_rw_tail(drive, REQ_IDETAPE_READ, blocks, |
| 2539 | tape->merge_stage->bh); | 2502 | tape->merge_stage->bh); |
| @@ -2550,7 +2513,7 @@ static int idetape_add_chrdev_read_request(ide_drive_t *drive, int blocks) | |||
| 2550 | else { | 2513 | else { |
| 2551 | idetape_switch_buffers(tape, tape->first_stage); | 2514 | idetape_switch_buffers(tape, tape->first_stage); |
| 2552 | if (rq_ptr->errors == IDETAPE_ERROR_FILEMARK) | 2515 | if (rq_ptr->errors == IDETAPE_ERROR_FILEMARK) |
| 2553 | set_bit(IDETAPE_FILEMARK, &tape->flags); | 2516 | set_bit(IDETAPE_FLAG_FILEMARK, &tape->flags); |
| 2554 | spin_lock_irqsave(&tape->lock, flags); | 2517 | spin_lock_irqsave(&tape->lock, flags); |
| 2555 | idetape_remove_stage_head(drive); | 2518 | idetape_remove_stage_head(drive); |
| 2556 | spin_unlock_irqrestore(&tape->lock, flags); | 2519 | spin_unlock_irqrestore(&tape->lock, flags); |
| @@ -2618,7 +2581,7 @@ static int idetape_pipeline_size(ide_drive_t *drive) | |||
| 2618 | static int idetape_rewind_tape(ide_drive_t *drive) | 2581 | static int idetape_rewind_tape(ide_drive_t *drive) |
| 2619 | { | 2582 | { |
| 2620 | int retval; | 2583 | int retval; |
| 2621 | idetape_pc_t pc; | 2584 | struct ide_atapi_pc pc; |
| 2622 | idetape_tape_t *tape; | 2585 | idetape_tape_t *tape; |
| 2623 | tape = drive->driver_data; | 2586 | tape = drive->driver_data; |
| 2624 | 2587 | ||
| @@ -2681,7 +2644,7 @@ static int idetape_space_over_filemarks(ide_drive_t *drive, short mt_op, | |||
| 2681 | int mt_count) | 2644 | int mt_count) |
| 2682 | { | 2645 | { |
| 2683 | idetape_tape_t *tape = drive->driver_data; | 2646 | idetape_tape_t *tape = drive->driver_data; |
| 2684 | idetape_pc_t pc; | 2647 | struct ide_atapi_pc pc; |
| 2685 | unsigned long flags; | 2648 | unsigned long flags; |
| 2686 | int retval, count = 0; | 2649 | int retval, count = 0; |
| 2687 | int sprev = !!(tape->caps[4] & 0x20); | 2650 | int sprev = !!(tape->caps[4] & 0x20); |
| @@ -2697,12 +2660,13 @@ static int idetape_space_over_filemarks(ide_drive_t *drive, short mt_op, | |||
| 2697 | if (tape->chrdev_dir == IDETAPE_DIR_READ) { | 2660 | if (tape->chrdev_dir == IDETAPE_DIR_READ) { |
| 2698 | /* its a read-ahead buffer, scan it for crossed filemarks. */ | 2661 | /* its a read-ahead buffer, scan it for crossed filemarks. */ |
| 2699 | tape->merge_stage_size = 0; | 2662 | tape->merge_stage_size = 0; |
| 2700 | if (test_and_clear_bit(IDETAPE_FILEMARK, &tape->flags)) | 2663 | if (test_and_clear_bit(IDETAPE_FLAG_FILEMARK, &tape->flags)) |
| 2701 | ++count; | 2664 | ++count; |
| 2702 | while (tape->first_stage != NULL) { | 2665 | while (tape->first_stage != NULL) { |
| 2703 | if (count == mt_count) { | 2666 | if (count == mt_count) { |
| 2704 | if (mt_op == MTFSFM) | 2667 | if (mt_op == MTFSFM) |
| 2705 | set_bit(IDETAPE_FILEMARK, &tape->flags); | 2668 | set_bit(IDETAPE_FLAG_FILEMARK, |
| 2669 | &tape->flags); | ||
| 2706 | return 0; | 2670 | return 0; |
| 2707 | } | 2671 | } |
| 2708 | spin_lock_irqsave(&tape->lock, flags); | 2672 | spin_lock_irqsave(&tape->lock, flags); |
| @@ -2786,7 +2750,7 @@ static ssize_t idetape_chrdev_read(struct file *file, char __user *buf, | |||
| 2786 | debug_log(DBG_CHRDEV, "Enter %s, count %Zd\n", __func__, count); | 2750 | debug_log(DBG_CHRDEV, "Enter %s, count %Zd\n", __func__, count); |
| 2787 | 2751 | ||
| 2788 | if (tape->chrdev_dir != IDETAPE_DIR_READ) { | 2752 | if (tape->chrdev_dir != IDETAPE_DIR_READ) { |
| 2789 | if (test_bit(IDETAPE_DETECT_BS, &tape->flags)) | 2753 | if (test_bit(IDETAPE_FLAG_DETECT_BS, &tape->flags)) |
| 2790 | if (count > tape->blk_size && | 2754 | if (count > tape->blk_size && |
| 2791 | (count % tape->blk_size) == 0) | 2755 | (count % tape->blk_size) == 0) |
| 2792 | tape->user_bs_factor = count / tape->blk_size; | 2756 | tape->user_bs_factor = count / tape->blk_size; |
| @@ -2829,7 +2793,7 @@ static ssize_t idetape_chrdev_read(struct file *file, char __user *buf, | |||
| 2829 | tape->merge_stage_size = bytes_read-temp; | 2793 | tape->merge_stage_size = bytes_read-temp; |
| 2830 | } | 2794 | } |
| 2831 | finish: | 2795 | finish: |
| 2832 | if (!actually_read && test_bit(IDETAPE_FILEMARK, &tape->flags)) { | 2796 | if (!actually_read && test_bit(IDETAPE_FLAG_FILEMARK, &tape->flags)) { |
| 2833 | debug_log(DBG_SENSE, "%s: spacing over filemark\n", tape->name); | 2797 | debug_log(DBG_SENSE, "%s: spacing over filemark\n", tape->name); |
| 2834 | 2798 | ||
| 2835 | idetape_space_over_filemarks(drive, MTFSF, 1); | 2799 | idetape_space_over_filemarks(drive, MTFSF, 1); |
| @@ -2938,7 +2902,7 @@ static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf, | |||
| 2938 | 2902 | ||
| 2939 | static int idetape_write_filemark(ide_drive_t *drive) | 2903 | static int idetape_write_filemark(ide_drive_t *drive) |
| 2940 | { | 2904 | { |
| 2941 | idetape_pc_t pc; | 2905 | struct ide_atapi_pc pc; |
| 2942 | 2906 | ||
| 2943 | /* Write a filemark */ | 2907 | /* Write a filemark */ |
| 2944 | idetape_create_write_filemark_cmd(drive, &pc, 1); | 2908 | idetape_create_write_filemark_cmd(drive, &pc, 1); |
| @@ -2966,7 +2930,7 @@ static int idetape_write_filemark(ide_drive_t *drive) | |||
| 2966 | static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) | 2930 | static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) |
| 2967 | { | 2931 | { |
| 2968 | idetape_tape_t *tape = drive->driver_data; | 2932 | idetape_tape_t *tape = drive->driver_data; |
| 2969 | idetape_pc_t pc; | 2933 | struct ide_atapi_pc pc; |
| 2970 | int i, retval; | 2934 | int i, retval; |
| 2971 | 2935 | ||
| 2972 | debug_log(DBG_ERR, "Handling MTIOCTOP ioctl: mt_op=%d, mt_count=%d\n", | 2936 | debug_log(DBG_ERR, "Handling MTIOCTOP ioctl: mt_op=%d, mt_count=%d\n", |
| @@ -3022,7 +2986,7 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) | |||
| 3022 | !IDETAPE_LU_LOAD_MASK); | 2986 | !IDETAPE_LU_LOAD_MASK); |
| 3023 | retval = idetape_queue_pc_tail(drive, &pc); | 2987 | retval = idetape_queue_pc_tail(drive, &pc); |
| 3024 | if (!retval) | 2988 | if (!retval) |
| 3025 | clear_bit(IDETAPE_MEDIUM_PRESENT, &tape->flags); | 2989 | clear_bit(IDETAPE_FLAG_MEDIUM_PRESENT, &tape->flags); |
| 3026 | return retval; | 2990 | return retval; |
| 3027 | case MTNOP: | 2991 | case MTNOP: |
| 3028 | idetape_discard_read_pipeline(drive, 0); | 2992 | idetape_discard_read_pipeline(drive, 0); |
| @@ -3045,9 +3009,9 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) | |||
| 3045 | mt_count % tape->blk_size) | 3009 | mt_count % tape->blk_size) |
| 3046 | return -EIO; | 3010 | return -EIO; |
| 3047 | tape->user_bs_factor = mt_count / tape->blk_size; | 3011 | tape->user_bs_factor = mt_count / tape->blk_size; |
| 3048 | clear_bit(IDETAPE_DETECT_BS, &tape->flags); | 3012 | clear_bit(IDETAPE_FLAG_DETECT_BS, &tape->flags); |
| 3049 | } else | 3013 | } else |
| 3050 | set_bit(IDETAPE_DETECT_BS, &tape->flags); | 3014 | set_bit(IDETAPE_FLAG_DETECT_BS, &tape->flags); |
| 3051 | return 0; | 3015 | return 0; |
| 3052 | case MTSEEK: | 3016 | case MTSEEK: |
| 3053 | idetape_discard_read_pipeline(drive, 0); | 3017 | idetape_discard_read_pipeline(drive, 0); |
| @@ -3149,7 +3113,7 @@ static int idetape_chrdev_ioctl(struct inode *inode, struct file *file, | |||
| 3149 | static void ide_tape_get_bsize_from_bdesc(ide_drive_t *drive) | 3113 | static void ide_tape_get_bsize_from_bdesc(ide_drive_t *drive) |
| 3150 | { | 3114 | { |
| 3151 | idetape_tape_t *tape = drive->driver_data; | 3115 | idetape_tape_t *tape = drive->driver_data; |
| 3152 | idetape_pc_t pc; | 3116 | struct ide_atapi_pc pc; |
| 3153 | 3117 | ||
| 3154 | idetape_create_mode_sense_cmd(&pc, IDETAPE_BLOCK_DESCRIPTOR); | 3118 | idetape_create_mode_sense_cmd(&pc, IDETAPE_BLOCK_DESCRIPTOR); |
| 3155 | if (idetape_queue_pc_tail(drive, &pc)) { | 3119 | if (idetape_queue_pc_tail(drive, &pc)) { |
| @@ -3161,10 +3125,10 @@ static void ide_tape_get_bsize_from_bdesc(ide_drive_t *drive) | |||
| 3161 | } | 3125 | } |
| 3162 | return; | 3126 | return; |
| 3163 | } | 3127 | } |
| 3164 | tape->blk_size = (pc.buffer[4 + 5] << 16) + | 3128 | tape->blk_size = (pc.buf[4 + 5] << 16) + |
| 3165 | (pc.buffer[4 + 6] << 8) + | 3129 | (pc.buf[4 + 6] << 8) + |
| 3166 | pc.buffer[4 + 7]; | 3130 | pc.buf[4 + 7]; |
| 3167 | tape->drv_write_prot = (pc.buffer[2] & 0x80) >> 7; | 3131 | tape->drv_write_prot = (pc.buf[2] & 0x80) >> 7; |
| 3168 | } | 3132 | } |
| 3169 | 3133 | ||
| 3170 | static int idetape_chrdev_open(struct inode *inode, struct file *filp) | 3134 | static int idetape_chrdev_open(struct inode *inode, struct file *filp) |
| @@ -3172,7 +3136,7 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp) | |||
| 3172 | unsigned int minor = iminor(inode), i = minor & ~0xc0; | 3136 | unsigned int minor = iminor(inode), i = minor & ~0xc0; |
| 3173 | ide_drive_t *drive; | 3137 | ide_drive_t *drive; |
| 3174 | idetape_tape_t *tape; | 3138 | idetape_tape_t *tape; |
| 3175 | idetape_pc_t pc; | 3139 | struct ide_atapi_pc pc; |
| 3176 | int retval; | 3140 | int retval; |
| 3177 | 3141 | ||
| 3178 | if (i >= MAX_HWIFS * MAX_DRIVES) | 3142 | if (i >= MAX_HWIFS * MAX_DRIVES) |
| @@ -3195,24 +3159,24 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp) | |||
| 3195 | 3159 | ||
| 3196 | filp->private_data = tape; | 3160 | filp->private_data = tape; |
| 3197 | 3161 | ||
| 3198 | if (test_and_set_bit(IDETAPE_BUSY, &tape->flags)) { | 3162 | if (test_and_set_bit(IDETAPE_FLAG_BUSY, &tape->flags)) { |
| 3199 | retval = -EBUSY; | 3163 | retval = -EBUSY; |
| 3200 | goto out_put_tape; | 3164 | goto out_put_tape; |
| 3201 | } | 3165 | } |
| 3202 | 3166 | ||
| 3203 | retval = idetape_wait_ready(drive, 60 * HZ); | 3167 | retval = idetape_wait_ready(drive, 60 * HZ); |
| 3204 | if (retval) { | 3168 | if (retval) { |
| 3205 | clear_bit(IDETAPE_BUSY, &tape->flags); | 3169 | clear_bit(IDETAPE_FLAG_BUSY, &tape->flags); |
| 3206 | printk(KERN_ERR "ide-tape: %s: drive not ready\n", tape->name); | 3170 | printk(KERN_ERR "ide-tape: %s: drive not ready\n", tape->name); |
| 3207 | goto out_put_tape; | 3171 | goto out_put_tape; |
| 3208 | } | 3172 | } |
| 3209 | 3173 | ||
| 3210 | idetape_read_position(drive); | 3174 | idetape_read_position(drive); |
| 3211 | if (!test_bit(IDETAPE_ADDRESS_VALID, &tape->flags)) | 3175 | if (!test_bit(IDETAPE_FLAG_ADDRESS_VALID, &tape->flags)) |
| 3212 | (void)idetape_rewind_tape(drive); | 3176 | (void)idetape_rewind_tape(drive); |
| 3213 | 3177 | ||
| 3214 | if (tape->chrdev_dir != IDETAPE_DIR_READ) | 3178 | if (tape->chrdev_dir != IDETAPE_DIR_READ) |
| 3215 | clear_bit(IDETAPE_PIPELINE_ERROR, &tape->flags); | 3179 | clear_bit(IDETAPE_FLAG_PIPELINE_ERR, &tape->flags); |
| 3216 | 3180 | ||
| 3217 | /* Read block size and write protect status from drive. */ | 3181 | /* Read block size and write protect status from drive. */ |
| 3218 | ide_tape_get_bsize_from_bdesc(drive); | 3182 | ide_tape_get_bsize_from_bdesc(drive); |
| @@ -3227,7 +3191,7 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp) | |||
| 3227 | if (tape->write_prot) { | 3191 | if (tape->write_prot) { |
| 3228 | if ((filp->f_flags & O_ACCMODE) == O_WRONLY || | 3192 | if ((filp->f_flags & O_ACCMODE) == O_WRONLY || |
| 3229 | (filp->f_flags & O_ACCMODE) == O_RDWR) { | 3193 | (filp->f_flags & O_ACCMODE) == O_RDWR) { |
| 3230 | clear_bit(IDETAPE_BUSY, &tape->flags); | 3194 | clear_bit(IDETAPE_FLAG_BUSY, &tape->flags); |
| 3231 | retval = -EROFS; | 3195 | retval = -EROFS; |
| 3232 | goto out_put_tape; | 3196 | goto out_put_tape; |
| 3233 | } | 3197 | } |
| @@ -3272,7 +3236,7 @@ static int idetape_chrdev_release(struct inode *inode, struct file *filp) | |||
| 3272 | { | 3236 | { |
| 3273 | struct ide_tape_obj *tape = ide_tape_f(filp); | 3237 | struct ide_tape_obj *tape = ide_tape_f(filp); |
| 3274 | ide_drive_t *drive = tape->drive; | 3238 | ide_drive_t *drive = tape->drive; |
| 3275 | idetape_pc_t pc; | 3239 | struct ide_atapi_pc pc; |
| 3276 | unsigned int minor = iminor(inode); | 3240 | unsigned int minor = iminor(inode); |
| 3277 | 3241 | ||
| 3278 | lock_kernel(); | 3242 | lock_kernel(); |
| @@ -3292,7 +3256,7 @@ static int idetape_chrdev_release(struct inode *inode, struct file *filp) | |||
| 3292 | __idetape_kfree_stage(tape->cache_stage); | 3256 | __idetape_kfree_stage(tape->cache_stage); |
| 3293 | tape->cache_stage = NULL; | 3257 | tape->cache_stage = NULL; |
| 3294 | } | 3258 | } |
| 3295 | if (minor < 128 && test_bit(IDETAPE_MEDIUM_PRESENT, &tape->flags)) | 3259 | if (minor < 128 && test_bit(IDETAPE_FLAG_MEDIUM_PRESENT, &tape->flags)) |
| 3296 | (void) idetape_rewind_tape(drive); | 3260 | (void) idetape_rewind_tape(drive); |
| 3297 | if (tape->chrdev_dir == IDETAPE_DIR_NONE) { | 3261 | if (tape->chrdev_dir == IDETAPE_DIR_NONE) { |
| 3298 | if (tape->door_locked == DOOR_LOCKED) { | 3262 | if (tape->door_locked == DOOR_LOCKED) { |
| @@ -3302,7 +3266,7 @@ static int idetape_chrdev_release(struct inode *inode, struct file *filp) | |||
| 3302 | } | 3266 | } |
| 3303 | } | 3267 | } |
| 3304 | } | 3268 | } |
| 3305 | clear_bit(IDETAPE_BUSY, &tape->flags); | 3269 | clear_bit(IDETAPE_FLAG_BUSY, &tape->flags); |
| 3306 | ide_tape_put(tape); | 3270 | ide_tape_put(tape); |
| 3307 | unlock_kernel(); | 3271 | unlock_kernel(); |
| 3308 | return 0; | 3272 | return 0; |
| @@ -3350,7 +3314,7 @@ static int idetape_identify_device(ide_drive_t *drive) | |||
| 3350 | static void idetape_get_inquiry_results(ide_drive_t *drive) | 3314 | static void idetape_get_inquiry_results(ide_drive_t *drive) |
| 3351 | { | 3315 | { |
| 3352 | idetape_tape_t *tape = drive->driver_data; | 3316 | idetape_tape_t *tape = drive->driver_data; |
| 3353 | idetape_pc_t pc; | 3317 | struct ide_atapi_pc pc; |
| 3354 | char fw_rev[6], vendor_id[10], product_id[18]; | 3318 | char fw_rev[6], vendor_id[10], product_id[18]; |
| 3355 | 3319 | ||
| 3356 | idetape_create_inquiry_cmd(&pc); | 3320 | idetape_create_inquiry_cmd(&pc); |
| @@ -3359,9 +3323,9 @@ static void idetape_get_inquiry_results(ide_drive_t *drive) | |||
| 3359 | tape->name); | 3323 | tape->name); |
| 3360 | return; | 3324 | return; |
| 3361 | } | 3325 | } |
| 3362 | memcpy(vendor_id, &pc.buffer[8], 8); | 3326 | memcpy(vendor_id, &pc.buf[8], 8); |
| 3363 | memcpy(product_id, &pc.buffer[16], 16); | 3327 | memcpy(product_id, &pc.buf[16], 16); |
| 3364 | memcpy(fw_rev, &pc.buffer[32], 4); | 3328 | memcpy(fw_rev, &pc.buf[32], 4); |
| 3365 | 3329 | ||
| 3366 | ide_fixstring(vendor_id, 10, 0); | 3330 | ide_fixstring(vendor_id, 10, 0); |
| 3367 | ide_fixstring(product_id, 18, 0); | 3331 | ide_fixstring(product_id, 18, 0); |
| @@ -3378,7 +3342,7 @@ static void idetape_get_inquiry_results(ide_drive_t *drive) | |||
| 3378 | static void idetape_get_mode_sense_results(ide_drive_t *drive) | 3342 | static void idetape_get_mode_sense_results(ide_drive_t *drive) |
| 3379 | { | 3343 | { |
| 3380 | idetape_tape_t *tape = drive->driver_data; | 3344 | idetape_tape_t *tape = drive->driver_data; |
| 3381 | idetape_pc_t pc; | 3345 | struct ide_atapi_pc pc; |
| 3382 | u8 *caps; | 3346 | u8 *caps; |
| 3383 | u8 speed, max_speed; | 3347 | u8 speed, max_speed; |
| 3384 | 3348 | ||
| @@ -3392,7 +3356,7 @@ static void idetape_get_mode_sense_results(ide_drive_t *drive) | |||
| 3392 | put_unaligned(6*52, (u16 *)&tape->caps[16]); | 3356 | put_unaligned(6*52, (u16 *)&tape->caps[16]); |
| 3393 | return; | 3357 | return; |
| 3394 | } | 3358 | } |
| 3395 | caps = pc.buffer + 4 + pc.buffer[3]; | 3359 | caps = pc.buf + 4 + pc.buf[3]; |
| 3396 | 3360 | ||
| 3397 | /* convert to host order and save for later use */ | 3361 | /* convert to host order and save for later use */ |
| 3398 | speed = be16_to_cpu(*(u16 *)&caps[14]); | 3362 | speed = be16_to_cpu(*(u16 *)&caps[14]); |
| @@ -3506,7 +3470,7 @@ static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor) | |||
| 3506 | 3470 | ||
| 3507 | /* Command packet DRQ type */ | 3471 | /* Command packet DRQ type */ |
| 3508 | if (((gcw[0] & 0x60) >> 5) == 1) | 3472 | if (((gcw[0] & 0x60) >> 5) == 1) |
| 3509 | set_bit(IDETAPE_DRQ_INTERRUPT, &tape->flags); | 3473 | set_bit(IDETAPE_FLAG_DRQ_INTERRUPT, &tape->flags); |
| 3510 | 3474 | ||
| 3511 | tape->min_pipeline = 10; | 3475 | tape->min_pipeline = 10; |
| 3512 | tape->max_pipeline = 10; | 3476 | tape->max_pipeline = 10; |
