diff options
author | Borislav Petkov <bbpetkov@yahoo.de> | 2008-02-02 19:56:50 +0100 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-02-02 19:56:50 +0100 |
commit | 90699ce2b28ec263651a4a0935a4651c57d68303 (patch) | |
tree | e12fe0e52bf2b181345c1f0d80b2e5b88412bb3d /drivers/ide/ide-tape.c | |
parent | f011889d1df5c51daee3a93d3b3c4b134c751cc0 (diff) |
ide-tape: use generic scsi commands
Also, remove those which weren't used.
Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-tape.c')
-rw-r--r-- | drivers/ide/ide-tape.c | 79 |
1 files changed, 29 insertions, 50 deletions
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index e7f25ff978d..502ca06bcc0 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c @@ -36,6 +36,7 @@ #include <linux/completion.h> #include <linux/bitops.h> #include <linux/mutex.h> +#include <scsi/scsi.h> #include <asm/byteorder.h> #include <asm/irq.h> @@ -517,27 +518,6 @@ static void ide_tape_put(struct ide_tape_obj *tape) #define IDETAPE_MEDIUM_PRESENT 9 /* - * Supported ATAPI tape drives packet commands - */ -#define IDETAPE_TEST_UNIT_READY_CMD 0x00 -#define IDETAPE_REWIND_CMD 0x01 -#define IDETAPE_REQUEST_SENSE_CMD 0x03 -#define IDETAPE_READ_CMD 0x08 -#define IDETAPE_WRITE_CMD 0x0a -#define IDETAPE_WRITE_FILEMARK_CMD 0x10 -#define IDETAPE_SPACE_CMD 0x11 -#define IDETAPE_INQUIRY_CMD 0x12 -#define IDETAPE_ERASE_CMD 0x19 -#define IDETAPE_MODE_SENSE_CMD 0x1a -#define IDETAPE_MODE_SELECT_CMD 0x15 -#define IDETAPE_LOAD_UNLOAD_CMD 0x1b -#define IDETAPE_PREVENT_CMD 0x1e -#define IDETAPE_LOCATE_CMD 0x2b -#define IDETAPE_READ_POSITION_CMD 0x34 -#define IDETAPE_READ_BUFFER_CMD 0x3c -#define IDETAPE_SET_SPEED_CMD 0xbb - -/* * Some defines for the READ BUFFER command */ #define IDETAPE_RETRIEVE_FAULTY_BLOCK 6 @@ -841,7 +821,7 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 *sense) * with sense key=5, asc=0x22, ascq=0, let it slide. Some drives * (i.e. Seagate STT3401A Travan) don't support 0-length read/writes. */ - if ((pc->c[0] == IDETAPE_READ_CMD || pc->c[0] == IDETAPE_WRITE_CMD) + if ((pc->c[0] == READ_6 || pc->c[0] == WRITE_6) /* length == 0 */ && pc->c[4] == 0 && pc->c[3] == 0 && pc->c[2] == 0) { if (tape->sense_key == 5) { @@ -851,18 +831,18 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 *sense) set_bit(PC_ABORT, &pc->flags); } } - if (pc->c[0] == IDETAPE_READ_CMD && (sense[2] & 0x80)) { + if (pc->c[0] == READ_6 && (sense[2] & 0x80)) { pc->error = IDETAPE_ERROR_FILEMARK; set_bit(PC_ABORT, &pc->flags); } - if (pc->c[0] == IDETAPE_WRITE_CMD) { + if (pc->c[0] == WRITE_6) { if ((sense[2] & 0x40) || (tape->sense_key == 0xd && tape->asc == 0x0 && tape->ascq == 0x2)) { pc->error = IDETAPE_ERROR_EOD; set_bit(PC_ABORT, &pc->flags); } } - if (pc->c[0] == IDETAPE_READ_CMD || pc->c[0] == IDETAPE_WRITE_CMD) { + if (pc->c[0] == READ_6 || pc->c[0] == WRITE_6) { if (tape->sense_key == 8) { pc->error = IDETAPE_ERROR_EOD; set_bit(PC_ABORT, &pc->flags); @@ -1111,7 +1091,7 @@ static ide_startstop_t idetape_request_sense_callback (ide_drive_t *drive) static void idetape_create_request_sense_cmd (idetape_pc_t *pc) { idetape_init_pc(pc); - pc->c[0] = IDETAPE_REQUEST_SENSE_CMD; + pc->c[0] = REQUEST_SENSE; pc->c[4] = 20; pc->request_transfer = 20; pc->callback = &idetape_request_sense_callback; @@ -1264,15 +1244,14 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive) local_irq_enable(); #if SIMULATE_ERRORS - if ((pc->c[0] == IDETAPE_WRITE_CMD || - pc->c[0] == IDETAPE_READ_CMD) && + if ((pc->c[0] == WRITE_6 || pc->c[0] == READ_6) && (++error_sim_count % 100) == 0) { printk(KERN_INFO "ide-tape: %s: simulating error\n", tape->name); stat |= ERR_STAT; } #endif - if ((stat & ERR_STAT) && pc->c[0] == IDETAPE_REQUEST_SENSE_CMD) + if ((stat & ERR_STAT) && pc->c[0] == REQUEST_SENSE) stat &= ~ERR_STAT; if ((stat & ERR_STAT) || test_bit(PC_DMA_ERROR, &pc->flags)) { /* Error detected */ @@ -1281,7 +1260,7 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive) printk(KERN_INFO "ide-tape: %s: I/O error\n", tape->name); #endif /* IDETAPE_DEBUG_LOG */ - if (pc->c[0] == IDETAPE_REQUEST_SENSE_CMD) { + if (pc->c[0] == REQUEST_SENSE) { printk(KERN_ERR "ide-tape: I/O error in request sense command\n"); return ide_do_reset(drive); } @@ -1469,13 +1448,13 @@ static ide_startstop_t idetape_issue_packet_command (ide_drive_t *drive, idetape int dma_ok = 0; u16 bcount; - if (tape->pc->c[0] == IDETAPE_REQUEST_SENSE_CMD && - pc->c[0] == IDETAPE_REQUEST_SENSE_CMD) { + if (tape->pc->c[0] == REQUEST_SENSE && + pc->c[0] == REQUEST_SENSE) { printk(KERN_ERR "ide-tape: possible ide-tape.c bug - " "Two request sense in serial were issued\n"); } - if (tape->failed_pc == NULL && pc->c[0] != IDETAPE_REQUEST_SENSE_CMD) + if (tape->failed_pc == NULL && pc->c[0] != REQUEST_SENSE) tape->failed_pc = pc; /* Set the current packet command */ tape->pc = pc; @@ -1488,7 +1467,7 @@ static ide_startstop_t idetape_issue_packet_command (ide_drive_t *drive, idetape * filemark, or end of the media, for example). */ if (!test_bit(PC_ABORT, &pc->flags)) { - if (!(pc->c[0] == IDETAPE_TEST_UNIT_READY_CMD && + if (!(pc->c[0] == TEST_UNIT_READY && tape->sense_key == 2 && tape->asc == 4 && (tape->ascq == 1 || tape->ascq == 8))) { printk(KERN_ERR "ide-tape: %s: I/O error, " @@ -1561,7 +1540,7 @@ static ide_startstop_t idetape_pc_callback (ide_drive_t *drive) static void idetape_create_mode_sense_cmd (idetape_pc_t *pc, u8 page_code) { idetape_init_pc(pc); - pc->c[0] = IDETAPE_MODE_SENSE_CMD; + pc->c[0] = MODE_SENSE; if (page_code != IDETAPE_BLOCK_DESCRIPTOR) pc->c[1] = 8; /* DBD = 1 - Don't return block descriptors */ pc->c[2] = page_code; @@ -1642,7 +1621,7 @@ static ide_startstop_t idetape_media_access_finished (ide_drive_t *drive) if (stat & SEEK_STAT) { if (stat & ERR_STAT) { /* Error detected */ - if (pc->c[0] != IDETAPE_TEST_UNIT_READY_CMD) + if (pc->c[0] != TEST_UNIT_READY) printk(KERN_ERR "ide-tape: %s: I/O error, ", tape->name); /* Retry operation */ @@ -1699,7 +1678,7 @@ static ide_startstop_t idetape_rw_callback (ide_drive_t *drive) static void idetape_create_read_cmd(idetape_tape_t *tape, idetape_pc_t *pc, unsigned int length, struct idetape_bh *bh) { idetape_init_pc(pc); - pc->c[0] = IDETAPE_READ_CMD; + pc->c[0] = READ_6; put_unaligned(htonl(length), (unsigned int *) &pc->c[1]); pc->c[1] = 1; pc->callback = &idetape_rw_callback; @@ -1717,7 +1696,7 @@ static void idetape_create_read_buffer_cmd(idetape_tape_t *tape, idetape_pc_t *p struct idetape_bh *p = bh; idetape_init_pc(pc); - pc->c[0] = IDETAPE_READ_BUFFER_CMD; + pc->c[0] = READ_BUFFER; pc->c[1] = IDETAPE_RETRIEVE_FAULTY_BLOCK; pc->c[7] = size >> 8; pc->c[8] = size & 0xff; @@ -1735,7 +1714,7 @@ static void idetape_create_read_buffer_cmd(idetape_tape_t *tape, idetape_pc_t *p static void idetape_create_write_cmd(idetape_tape_t *tape, idetape_pc_t *pc, unsigned int length, struct idetape_bh *bh) { idetape_init_pc(pc); - pc->c[0] = IDETAPE_WRITE_CMD; + pc->c[0] = WRITE_6; put_unaligned(htonl(length), (unsigned int *) &pc->c[1]); pc->c[1] = 1; pc->callback = &idetape_rw_callback; @@ -1781,7 +1760,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, * Retry a failed packet command */ if (tape->failed_pc != NULL && - tape->pc->c[0] == IDETAPE_REQUEST_SENSE_CMD) { + tape->pc->c[0] == REQUEST_SENSE) { return idetape_issue_packet_command(drive, tape->failed_pc); } if (postponed_rq != NULL) @@ -2152,7 +2131,7 @@ static ide_startstop_t idetape_read_position_callback (ide_drive_t *drive) static void idetape_create_write_filemark_cmd (ide_drive_t *drive, idetape_pc_t *pc,int write_filemark) { idetape_init_pc(pc); - pc->c[0] = IDETAPE_WRITE_FILEMARK_CMD; + pc->c[0] = WRITE_FILEMARKS; pc->c[4] = write_filemark; set_bit(PC_WAIT_FOR_DSC, &pc->flags); pc->callback = &idetape_pc_callback; @@ -2161,7 +2140,7 @@ static void idetape_create_write_filemark_cmd (ide_drive_t *drive, idetape_pc_t static void idetape_create_test_unit_ready_cmd(idetape_pc_t *pc) { idetape_init_pc(pc); - pc->c[0] = IDETAPE_TEST_UNIT_READY_CMD; + pc->c[0] = TEST_UNIT_READY; pc->callback = &idetape_pc_callback; } @@ -2199,7 +2178,7 @@ static int __idetape_queue_pc_tail (ide_drive_t *drive, idetape_pc_t *pc) static void idetape_create_load_unload_cmd (ide_drive_t *drive, idetape_pc_t *pc,int cmd) { idetape_init_pc(pc); - pc->c[0] = IDETAPE_LOAD_UNLOAD_CMD; + pc->c[0] = START_STOP; pc->c[4] = cmd; set_bit(PC_WAIT_FOR_DSC, &pc->flags); pc->callback = &idetape_pc_callback; @@ -2256,7 +2235,7 @@ static int idetape_flush_tape_buffers (ide_drive_t *drive) static void idetape_create_read_position_cmd (idetape_pc_t *pc) { idetape_init_pc(pc); - pc->c[0] = IDETAPE_READ_POSITION_CMD; + pc->c[0] = READ_POSITION; pc->request_transfer = 20; pc->callback = &idetape_read_position_callback; } @@ -2282,7 +2261,7 @@ static int idetape_read_position (ide_drive_t *drive) static void idetape_create_locate_cmd (ide_drive_t *drive, idetape_pc_t *pc, unsigned int block, u8 partition, int skip) { idetape_init_pc(pc); - pc->c[0] = IDETAPE_LOCATE_CMD; + pc->c[0] = POSITION_TO_ELEMENT; pc->c[1] = 2; put_unaligned(htonl(block), (unsigned int *) &pc->c[3]); pc->c[8] = partition; @@ -2299,7 +2278,7 @@ static int idetape_create_prevent_cmd (ide_drive_t *drive, idetape_pc_t *pc, int return 0; idetape_init_pc(pc); - pc->c[0] = IDETAPE_PREVENT_CMD; + pc->c[0] = ALLOW_MEDIUM_REMOVAL; pc->c[4] = prevent; pc->callback = &idetape_pc_callback; return 1; @@ -2450,7 +2429,7 @@ static void idetape_insert_pipeline_into_queue (ide_drive_t *drive) static void idetape_create_inquiry_cmd (idetape_pc_t *pc) { idetape_init_pc(pc); - pc->c[0] = IDETAPE_INQUIRY_CMD; + pc->c[0] = INQUIRY; pc->c[4] = pc->request_transfer = 254; pc->callback = &idetape_pc_callback; } @@ -2458,7 +2437,7 @@ static void idetape_create_inquiry_cmd (idetape_pc_t *pc) static void idetape_create_rewind_cmd (ide_drive_t *drive, idetape_pc_t *pc) { idetape_init_pc(pc); - pc->c[0] = IDETAPE_REWIND_CMD; + pc->c[0] = REZERO_UNIT; set_bit(PC_WAIT_FOR_DSC, &pc->flags); pc->callback = &idetape_pc_callback; } @@ -2466,7 +2445,7 @@ static void idetape_create_rewind_cmd (ide_drive_t *drive, idetape_pc_t *pc) static void idetape_create_erase_cmd (idetape_pc_t *pc) { idetape_init_pc(pc); - pc->c[0] = IDETAPE_ERASE_CMD; + pc->c[0] = ERASE; pc->c[1] = 1; set_bit(PC_WAIT_FOR_DSC, &pc->flags); pc->callback = &idetape_pc_callback; @@ -2475,7 +2454,7 @@ static void idetape_create_erase_cmd (idetape_pc_t *pc) static void idetape_create_space_cmd (idetape_pc_t *pc,int count, u8 cmd) { idetape_init_pc(pc); - pc->c[0] = IDETAPE_SPACE_CMD; + pc->c[0] = SPACE; put_unaligned(htonl(count), (unsigned int *) &pc->c[1]); pc->c[1] = cmd; set_bit(PC_WAIT_FOR_DSC, &pc->flags); |