aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBorislav Petkov <bbpetkov@yahoo.de>2008-02-02 13:56:50 -0500
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-02-02 13:56:50 -0500
commit90699ce2b28ec263651a4a0935a4651c57d68303 (patch)
treee12fe0e52bf2b181345c1f0d80b2e5b88412bb3d
parentf011889d1df5c51daee3a93d3b3c4b134c751cc0 (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>
-rw-r--r--drivers/ide/ide-tape.c79
1 files changed, 29 insertions, 50 deletions
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index e7f25ff978d9..502ca06bcc08 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -36,6 +36,7 @@
36#include <linux/completion.h> 36#include <linux/completion.h>
37#include <linux/bitops.h> 37#include <linux/bitops.h>
38#include <linux/mutex.h> 38#include <linux/mutex.h>
39#include <scsi/scsi.h>
39 40
40#include <asm/byteorder.h> 41#include <asm/byteorder.h>
41#include <asm/irq.h> 42#include <asm/irq.h>
@@ -517,27 +518,6 @@ static void ide_tape_put(struct ide_tape_obj *tape)
517#define IDETAPE_MEDIUM_PRESENT 9 518#define IDETAPE_MEDIUM_PRESENT 9
518 519
519/* 520/*
520 * Supported ATAPI tape drives packet commands
521 */
522#define IDETAPE_TEST_UNIT_READY_CMD 0x00
523#define IDETAPE_REWIND_CMD 0x01
524#define IDETAPE_REQUEST_SENSE_CMD 0x03
525#define IDETAPE_READ_CMD 0x08
526#define IDETAPE_WRITE_CMD 0x0a
527#define IDETAPE_WRITE_FILEMARK_CMD 0x10
528#define IDETAPE_SPACE_CMD 0x11
529#define IDETAPE_INQUIRY_CMD 0x12
530#define IDETAPE_ERASE_CMD 0x19
531#define IDETAPE_MODE_SENSE_CMD 0x1a
532#define IDETAPE_MODE_SELECT_CMD 0x15
533#define IDETAPE_LOAD_UNLOAD_CMD 0x1b
534#define IDETAPE_PREVENT_CMD 0x1e
535#define IDETAPE_LOCATE_CMD 0x2b
536#define IDETAPE_READ_POSITION_CMD 0x34
537#define IDETAPE_READ_BUFFER_CMD 0x3c
538#define IDETAPE_SET_SPEED_CMD 0xbb
539
540/*
541 * Some defines for the READ BUFFER command 521 * Some defines for the READ BUFFER command
542 */ 522 */
543#define IDETAPE_RETRIEVE_FAULTY_BLOCK 6 523#define IDETAPE_RETRIEVE_FAULTY_BLOCK 6
@@ -841,7 +821,7 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 *sense)
841 * with sense key=5, asc=0x22, ascq=0, let it slide. Some drives 821 * with sense key=5, asc=0x22, ascq=0, let it slide. Some drives
842 * (i.e. Seagate STT3401A Travan) don't support 0-length read/writes. 822 * (i.e. Seagate STT3401A Travan) don't support 0-length read/writes.
843 */ 823 */
844 if ((pc->c[0] == IDETAPE_READ_CMD || pc->c[0] == IDETAPE_WRITE_CMD) 824 if ((pc->c[0] == READ_6 || pc->c[0] == WRITE_6)
845 /* length == 0 */ 825 /* length == 0 */
846 && pc->c[4] == 0 && pc->c[3] == 0 && pc->c[2] == 0) { 826 && pc->c[4] == 0 && pc->c[3] == 0 && pc->c[2] == 0) {
847 if (tape->sense_key == 5) { 827 if (tape->sense_key == 5) {
@@ -851,18 +831,18 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 *sense)
851 set_bit(PC_ABORT, &pc->flags); 831 set_bit(PC_ABORT, &pc->flags);
852 } 832 }
853 } 833 }
854 if (pc->c[0] == IDETAPE_READ_CMD && (sense[2] & 0x80)) { 834 if (pc->c[0] == READ_6 && (sense[2] & 0x80)) {
855 pc->error = IDETAPE_ERROR_FILEMARK; 835 pc->error = IDETAPE_ERROR_FILEMARK;
856 set_bit(PC_ABORT, &pc->flags); 836 set_bit(PC_ABORT, &pc->flags);
857 } 837 }
858 if (pc->c[0] == IDETAPE_WRITE_CMD) { 838 if (pc->c[0] == WRITE_6) {
859 if ((sense[2] & 0x40) || (tape->sense_key == 0xd 839 if ((sense[2] & 0x40) || (tape->sense_key == 0xd
860 && tape->asc == 0x0 && tape->ascq == 0x2)) { 840 && tape->asc == 0x0 && tape->ascq == 0x2)) {
861 pc->error = IDETAPE_ERROR_EOD; 841 pc->error = IDETAPE_ERROR_EOD;
862 set_bit(PC_ABORT, &pc->flags); 842 set_bit(PC_ABORT, &pc->flags);
863 } 843 }
864 } 844 }
865 if (pc->c[0] == IDETAPE_READ_CMD || pc->c[0] == IDETAPE_WRITE_CMD) { 845 if (pc->c[0] == READ_6 || pc->c[0] == WRITE_6) {
866 if (tape->sense_key == 8) { 846 if (tape->sense_key == 8) {
867 pc->error = IDETAPE_ERROR_EOD; 847 pc->error = IDETAPE_ERROR_EOD;
868 set_bit(PC_ABORT, &pc->flags); 848 set_bit(PC_ABORT, &pc->flags);
@@ -1111,7 +1091,7 @@ static ide_startstop_t idetape_request_sense_callback (ide_drive_t *drive)
1111static void idetape_create_request_sense_cmd (idetape_pc_t *pc) 1091static void idetape_create_request_sense_cmd (idetape_pc_t *pc)
1112{ 1092{
1113 idetape_init_pc(pc); 1093 idetape_init_pc(pc);
1114 pc->c[0] = IDETAPE_REQUEST_SENSE_CMD; 1094 pc->c[0] = REQUEST_SENSE;
1115 pc->c[4] = 20; 1095 pc->c[4] = 20;
1116 pc->request_transfer = 20; 1096 pc->request_transfer = 20;
1117 pc->callback = &idetape_request_sense_callback; 1097 pc->callback = &idetape_request_sense_callback;
@@ -1264,15 +1244,14 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive)
1264 local_irq_enable(); 1244 local_irq_enable();
1265 1245
1266#if SIMULATE_ERRORS 1246#if SIMULATE_ERRORS
1267 if ((pc->c[0] == IDETAPE_WRITE_CMD || 1247 if ((pc->c[0] == WRITE_6 || pc->c[0] == READ_6) &&
1268 pc->c[0] == IDETAPE_READ_CMD) &&
1269 (++error_sim_count % 100) == 0) { 1248 (++error_sim_count % 100) == 0) {
1270 printk(KERN_INFO "ide-tape: %s: simulating error\n", 1249 printk(KERN_INFO "ide-tape: %s: simulating error\n",
1271 tape->name); 1250 tape->name);
1272 stat |= ERR_STAT; 1251 stat |= ERR_STAT;
1273 } 1252 }
1274#endif 1253#endif
1275 if ((stat & ERR_STAT) && pc->c[0] == IDETAPE_REQUEST_SENSE_CMD) 1254 if ((stat & ERR_STAT) && pc->c[0] == REQUEST_SENSE)
1276 stat &= ~ERR_STAT; 1255 stat &= ~ERR_STAT;
1277 if ((stat & ERR_STAT) || test_bit(PC_DMA_ERROR, &pc->flags)) { 1256 if ((stat & ERR_STAT) || test_bit(PC_DMA_ERROR, &pc->flags)) {
1278 /* Error detected */ 1257 /* Error detected */
@@ -1281,7 +1260,7 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive)
1281 printk(KERN_INFO "ide-tape: %s: I/O error\n", 1260 printk(KERN_INFO "ide-tape: %s: I/O error\n",
1282 tape->name); 1261 tape->name);
1283#endif /* IDETAPE_DEBUG_LOG */ 1262#endif /* IDETAPE_DEBUG_LOG */
1284 if (pc->c[0] == IDETAPE_REQUEST_SENSE_CMD) { 1263 if (pc->c[0] == REQUEST_SENSE) {
1285 printk(KERN_ERR "ide-tape: I/O error in request sense command\n"); 1264 printk(KERN_ERR "ide-tape: I/O error in request sense command\n");
1286 return ide_do_reset(drive); 1265 return ide_do_reset(drive);
1287 } 1266 }
@@ -1469,13 +1448,13 @@ static ide_startstop_t idetape_issue_packet_command (ide_drive_t *drive, idetape
1469 int dma_ok = 0; 1448 int dma_ok = 0;
1470 u16 bcount; 1449 u16 bcount;
1471 1450
1472 if (tape->pc->c[0] == IDETAPE_REQUEST_SENSE_CMD && 1451 if (tape->pc->c[0] == REQUEST_SENSE &&
1473 pc->c[0] == IDETAPE_REQUEST_SENSE_CMD) { 1452 pc->c[0] == REQUEST_SENSE) {
1474 printk(KERN_ERR "ide-tape: possible ide-tape.c bug - " 1453 printk(KERN_ERR "ide-tape: possible ide-tape.c bug - "
1475 "Two request sense in serial were issued\n"); 1454 "Two request sense in serial were issued\n");
1476 } 1455 }
1477 1456
1478 if (tape->failed_pc == NULL && pc->c[0] != IDETAPE_REQUEST_SENSE_CMD) 1457 if (tape->failed_pc == NULL && pc->c[0] != REQUEST_SENSE)
1479 tape->failed_pc = pc; 1458 tape->failed_pc = pc;
1480 /* Set the current packet command */ 1459 /* Set the current packet command */
1481 tape->pc = pc; 1460 tape->pc = pc;
@@ -1488,7 +1467,7 @@ static ide_startstop_t idetape_issue_packet_command (ide_drive_t *drive, idetape
1488 * filemark, or end of the media, for example). 1467 * filemark, or end of the media, for example).
1489 */ 1468 */
1490 if (!test_bit(PC_ABORT, &pc->flags)) { 1469 if (!test_bit(PC_ABORT, &pc->flags)) {
1491 if (!(pc->c[0] == IDETAPE_TEST_UNIT_READY_CMD && 1470 if (!(pc->c[0] == TEST_UNIT_READY &&
1492 tape->sense_key == 2 && tape->asc == 4 && 1471 tape->sense_key == 2 && tape->asc == 4 &&
1493 (tape->ascq == 1 || tape->ascq == 8))) { 1472 (tape->ascq == 1 || tape->ascq == 8))) {
1494 printk(KERN_ERR "ide-tape: %s: I/O error, " 1473 printk(KERN_ERR "ide-tape: %s: I/O error, "
@@ -1561,7 +1540,7 @@ static ide_startstop_t idetape_pc_callback (ide_drive_t *drive)
1561static void idetape_create_mode_sense_cmd (idetape_pc_t *pc, u8 page_code) 1540static void idetape_create_mode_sense_cmd (idetape_pc_t *pc, u8 page_code)
1562{ 1541{
1563 idetape_init_pc(pc); 1542 idetape_init_pc(pc);
1564 pc->c[0] = IDETAPE_MODE_SENSE_CMD; 1543 pc->c[0] = MODE_SENSE;
1565 if (page_code != IDETAPE_BLOCK_DESCRIPTOR) 1544 if (page_code != IDETAPE_BLOCK_DESCRIPTOR)
1566 pc->c[1] = 8; /* DBD = 1 - Don't return block descriptors */ 1545 pc->c[1] = 8; /* DBD = 1 - Don't return block descriptors */
1567 pc->c[2] = page_code; 1546 pc->c[2] = page_code;
@@ -1642,7 +1621,7 @@ static ide_startstop_t idetape_media_access_finished (ide_drive_t *drive)
1642 if (stat & SEEK_STAT) { 1621 if (stat & SEEK_STAT) {
1643 if (stat & ERR_STAT) { 1622 if (stat & ERR_STAT) {
1644 /* Error detected */ 1623 /* Error detected */
1645 if (pc->c[0] != IDETAPE_TEST_UNIT_READY_CMD) 1624 if (pc->c[0] != TEST_UNIT_READY)
1646 printk(KERN_ERR "ide-tape: %s: I/O error, ", 1625 printk(KERN_ERR "ide-tape: %s: I/O error, ",
1647 tape->name); 1626 tape->name);
1648 /* Retry operation */ 1627 /* Retry operation */
@@ -1699,7 +1678,7 @@ static ide_startstop_t idetape_rw_callback (ide_drive_t *drive)
1699static void idetape_create_read_cmd(idetape_tape_t *tape, idetape_pc_t *pc, unsigned int length, struct idetape_bh *bh) 1678static void idetape_create_read_cmd(idetape_tape_t *tape, idetape_pc_t *pc, unsigned int length, struct idetape_bh *bh)
1700{ 1679{
1701 idetape_init_pc(pc); 1680 idetape_init_pc(pc);
1702 pc->c[0] = IDETAPE_READ_CMD; 1681 pc->c[0] = READ_6;
1703 put_unaligned(htonl(length), (unsigned int *) &pc->c[1]); 1682 put_unaligned(htonl(length), (unsigned int *) &pc->c[1]);
1704 pc->c[1] = 1; 1683 pc->c[1] = 1;
1705 pc->callback = &idetape_rw_callback; 1684 pc->callback = &idetape_rw_callback;
@@ -1717,7 +1696,7 @@ static void idetape_create_read_buffer_cmd(idetape_tape_t *tape, idetape_pc_t *p
1717 struct idetape_bh *p = bh; 1696 struct idetape_bh *p = bh;
1718 1697
1719 idetape_init_pc(pc); 1698 idetape_init_pc(pc);
1720 pc->c[0] = IDETAPE_READ_BUFFER_CMD; 1699 pc->c[0] = READ_BUFFER;
1721 pc->c[1] = IDETAPE_RETRIEVE_FAULTY_BLOCK; 1700 pc->c[1] = IDETAPE_RETRIEVE_FAULTY_BLOCK;
1722 pc->c[7] = size >> 8; 1701 pc->c[7] = size >> 8;
1723 pc->c[8] = size & 0xff; 1702 pc->c[8] = size & 0xff;
@@ -1735,7 +1714,7 @@ static void idetape_create_read_buffer_cmd(idetape_tape_t *tape, idetape_pc_t *p
1735static void idetape_create_write_cmd(idetape_tape_t *tape, idetape_pc_t *pc, unsigned int length, struct idetape_bh *bh) 1714static void idetape_create_write_cmd(idetape_tape_t *tape, idetape_pc_t *pc, unsigned int length, struct idetape_bh *bh)
1736{ 1715{
1737 idetape_init_pc(pc); 1716 idetape_init_pc(pc);
1738 pc->c[0] = IDETAPE_WRITE_CMD; 1717 pc->c[0] = WRITE_6;
1739 put_unaligned(htonl(length), (unsigned int *) &pc->c[1]); 1718 put_unaligned(htonl(length), (unsigned int *) &pc->c[1]);
1740 pc->c[1] = 1; 1719 pc->c[1] = 1;
1741 pc->callback = &idetape_rw_callback; 1720 pc->callback = &idetape_rw_callback;
@@ -1781,7 +1760,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
1781 * Retry a failed packet command 1760 * Retry a failed packet command
1782 */ 1761 */
1783 if (tape->failed_pc != NULL && 1762 if (tape->failed_pc != NULL &&
1784 tape->pc->c[0] == IDETAPE_REQUEST_SENSE_CMD) { 1763 tape->pc->c[0] == REQUEST_SENSE) {
1785 return idetape_issue_packet_command(drive, tape->failed_pc); 1764 return idetape_issue_packet_command(drive, tape->failed_pc);
1786 } 1765 }
1787 if (postponed_rq != NULL) 1766 if (postponed_rq != NULL)
@@ -2152,7 +2131,7 @@ static ide_startstop_t idetape_read_position_callback (ide_drive_t *drive)
2152static void idetape_create_write_filemark_cmd (ide_drive_t *drive, idetape_pc_t *pc,int write_filemark) 2131static void idetape_create_write_filemark_cmd (ide_drive_t *drive, idetape_pc_t *pc,int write_filemark)
2153{ 2132{
2154 idetape_init_pc(pc); 2133 idetape_init_pc(pc);
2155 pc->c[0] = IDETAPE_WRITE_FILEMARK_CMD; 2134 pc->c[0] = WRITE_FILEMARKS;
2156 pc->c[4] = write_filemark; 2135 pc->c[4] = write_filemark;
2157 set_bit(PC_WAIT_FOR_DSC, &pc->flags); 2136 set_bit(PC_WAIT_FOR_DSC, &pc->flags);
2158 pc->callback = &idetape_pc_callback; 2137 pc->callback = &idetape_pc_callback;
@@ -2161,7 +2140,7 @@ static void idetape_create_write_filemark_cmd (ide_drive_t *drive, idetape_pc_t
2161static void idetape_create_test_unit_ready_cmd(idetape_pc_t *pc) 2140static void idetape_create_test_unit_ready_cmd(idetape_pc_t *pc)
2162{ 2141{
2163 idetape_init_pc(pc); 2142 idetape_init_pc(pc);
2164 pc->c[0] = IDETAPE_TEST_UNIT_READY_CMD; 2143 pc->c[0] = TEST_UNIT_READY;
2165 pc->callback = &idetape_pc_callback; 2144 pc->callback = &idetape_pc_callback;
2166} 2145}
2167 2146
@@ -2199,7 +2178,7 @@ static int __idetape_queue_pc_tail (ide_drive_t *drive, idetape_pc_t *pc)
2199static void idetape_create_load_unload_cmd (ide_drive_t *drive, idetape_pc_t *pc,int cmd) 2178static void idetape_create_load_unload_cmd (ide_drive_t *drive, idetape_pc_t *pc,int cmd)
2200{ 2179{
2201 idetape_init_pc(pc); 2180 idetape_init_pc(pc);
2202 pc->c[0] = IDETAPE_LOAD_UNLOAD_CMD; 2181 pc->c[0] = START_STOP;
2203 pc->c[4] = cmd; 2182 pc->c[4] = cmd;
2204 set_bit(PC_WAIT_FOR_DSC, &pc->flags); 2183 set_bit(PC_WAIT_FOR_DSC, &pc->flags);
2205 pc->callback = &idetape_pc_callback; 2184 pc->callback = &idetape_pc_callback;
@@ -2256,7 +2235,7 @@ static int idetape_flush_tape_buffers (ide_drive_t *drive)
2256static void idetape_create_read_position_cmd (idetape_pc_t *pc) 2235static void idetape_create_read_position_cmd (idetape_pc_t *pc)
2257{ 2236{
2258 idetape_init_pc(pc); 2237 idetape_init_pc(pc);
2259 pc->c[0] = IDETAPE_READ_POSITION_CMD; 2238 pc->c[0] = READ_POSITION;
2260 pc->request_transfer = 20; 2239 pc->request_transfer = 20;
2261 pc->callback = &idetape_read_position_callback; 2240 pc->callback = &idetape_read_position_callback;
2262} 2241}
@@ -2282,7 +2261,7 @@ static int idetape_read_position (ide_drive_t *drive)
2282static void idetape_create_locate_cmd (ide_drive_t *drive, idetape_pc_t *pc, unsigned int block, u8 partition, int skip) 2261static void idetape_create_locate_cmd (ide_drive_t *drive, idetape_pc_t *pc, unsigned int block, u8 partition, int skip)
2283{ 2262{
2284 idetape_init_pc(pc); 2263 idetape_init_pc(pc);
2285 pc->c[0] = IDETAPE_LOCATE_CMD; 2264 pc->c[0] = POSITION_TO_ELEMENT;
2286 pc->c[1] = 2; 2265 pc->c[1] = 2;
2287 put_unaligned(htonl(block), (unsigned int *) &pc->c[3]); 2266 put_unaligned(htonl(block), (unsigned int *) &pc->c[3]);
2288 pc->c[8] = partition; 2267 pc->c[8] = partition;
@@ -2299,7 +2278,7 @@ static int idetape_create_prevent_cmd (ide_drive_t *drive, idetape_pc_t *pc, int
2299 return 0; 2278 return 0;
2300 2279
2301 idetape_init_pc(pc); 2280 idetape_init_pc(pc);
2302 pc->c[0] = IDETAPE_PREVENT_CMD; 2281 pc->c[0] = ALLOW_MEDIUM_REMOVAL;
2303 pc->c[4] = prevent; 2282 pc->c[4] = prevent;
2304 pc->callback = &idetape_pc_callback; 2283 pc->callback = &idetape_pc_callback;
2305 return 1; 2284 return 1;
@@ -2450,7 +2429,7 @@ static void idetape_insert_pipeline_into_queue (ide_drive_t *drive)
2450static void idetape_create_inquiry_cmd (idetape_pc_t *pc) 2429static void idetape_create_inquiry_cmd (idetape_pc_t *pc)
2451{ 2430{
2452 idetape_init_pc(pc); 2431 idetape_init_pc(pc);
2453 pc->c[0] = IDETAPE_INQUIRY_CMD; 2432 pc->c[0] = INQUIRY;
2454 pc->c[4] = pc->request_transfer = 254; 2433 pc->c[4] = pc->request_transfer = 254;
2455 pc->callback = &idetape_pc_callback; 2434 pc->callback = &idetape_pc_callback;
2456} 2435}
@@ -2458,7 +2437,7 @@ static void idetape_create_inquiry_cmd (idetape_pc_t *pc)
2458static void idetape_create_rewind_cmd (ide_drive_t *drive, idetape_pc_t *pc) 2437static void idetape_create_rewind_cmd (ide_drive_t *drive, idetape_pc_t *pc)
2459{ 2438{
2460 idetape_init_pc(pc); 2439 idetape_init_pc(pc);
2461 pc->c[0] = IDETAPE_REWIND_CMD; 2440 pc->c[0] = REZERO_UNIT;
2462 set_bit(PC_WAIT_FOR_DSC, &pc->flags); 2441 set_bit(PC_WAIT_FOR_DSC, &pc->flags);
2463 pc->callback = &idetape_pc_callback; 2442 pc->callback = &idetape_pc_callback;
2464} 2443}
@@ -2466,7 +2445,7 @@ static void idetape_create_rewind_cmd (ide_drive_t *drive, idetape_pc_t *pc)
2466static void idetape_create_erase_cmd (idetape_pc_t *pc) 2445static void idetape_create_erase_cmd (idetape_pc_t *pc)
2467{ 2446{
2468 idetape_init_pc(pc); 2447 idetape_init_pc(pc);
2469 pc->c[0] = IDETAPE_ERASE_CMD; 2448 pc->c[0] = ERASE;
2470 pc->c[1] = 1; 2449 pc->c[1] = 1;
2471 set_bit(PC_WAIT_FOR_DSC, &pc->flags); 2450 set_bit(PC_WAIT_FOR_DSC, &pc->flags);
2472 pc->callback = &idetape_pc_callback; 2451 pc->callback = &idetape_pc_callback;
@@ -2475,7 +2454,7 @@ static void idetape_create_erase_cmd (idetape_pc_t *pc)
2475static void idetape_create_space_cmd (idetape_pc_t *pc,int count, u8 cmd) 2454static void idetape_create_space_cmd (idetape_pc_t *pc,int count, u8 cmd)
2476{ 2455{
2477 idetape_init_pc(pc); 2456 idetape_init_pc(pc);
2478 pc->c[0] = IDETAPE_SPACE_CMD; 2457 pc->c[0] = SPACE;
2479 put_unaligned(htonl(count), (unsigned int *) &pc->c[1]); 2458 put_unaligned(htonl(count), (unsigned int *) &pc->c[1]);
2480 pc->c[1] = cmd; 2459 pc->c[1] = cmd;
2481 set_bit(PC_WAIT_FOR_DSC, &pc->flags); 2460 set_bit(PC_WAIT_FOR_DSC, &pc->flags);