LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Borislav Petkov <petkovbb@gmail.com>
To: <bzolnier@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-ide@vger.kernel.org,
	Borislav Petkov <bbpetkov@yahoo.de>
Subject: [PATCH 16/32] ide-tape: use generic scsi commands
Date: Sun, 27 Jan 2008 10:48:04 +0100	[thread overview]
Message-ID: <1201427300-3954-11-git-send-email-petkovbb@gmail.com> (raw)
In-Reply-To: <1201427300-3954-1-git-send-email-petkovbb@gmail.com>

From: Borislav Petkov <bbpetkov@yahoo.de>

Also, remove those which weren't used.

Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de>
---
 drivers/ide/ide-tape.c |   80 ++++++++++++++++++------------------------------
 1 files changed, 30 insertions(+), 50 deletions(-)

diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 0708049..1435f4e 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>
@@ -521,27 +522,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
@@ -813,7 +793,7 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 *sense)
 	 * 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) {
@@ -823,11 +803,11 @@ 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 &&
@@ -836,7 +816,7 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 *sense)
 			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);
@@ -1073,7 +1053,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;
@@ -1216,22 +1196,22 @@ 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 */
 			debug_log(DBG_ERR, "%s: I/O error\n", tape->name);
 
-			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);
 			}
@@ -1416,13 +1396,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;
@@ -1435,7 +1415,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, "
@@ -1502,7 +1482,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;
@@ -1583,7 +1563,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 */
@@ -1636,7 +1616,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;
@@ -1654,7 +1634,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;
@@ -1672,7 +1652,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;
@@ -1715,7 +1695,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)
@@ -2079,7 +2059,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;
@@ -2088,7 +2068,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;
 }
 
@@ -2126,7 +2106,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;
@@ -2183,7 +2163,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;
 }
@@ -2206,7 +2186,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;
@@ -2223,7 +2203,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;
@@ -2373,7 +2353,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;
 }
@@ -2381,7 +2361,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;
 }
@@ -2389,7 +2369,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;
@@ -2398,7 +2378,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);
-- 
1.5.3.7


  parent reply	other threads:[~2008-01-27  9:54 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-27  9:47 [PATCH 06/32] ide-tape: remove IDETAPE_DEBUG_BUGS Borislav Petkov
2008-01-27  9:47 ` [PATCH 07/32] ide-tape: refactor the debug logging facility Borislav Petkov
2008-01-27 16:12   ` Bartlomiej Zolnierkiewicz
2008-01-27  9:47 ` [PATCH 08/32] ide-tape: remove struct idetape_capabilities_page_t Borislav Petkov
2008-01-27 16:46   ` Bartlomiej Zolnierkiewicz
2008-01-27  9:47 ` [PATCH 09/32] ide-tape: remove struct idetape_inquiry_result_t Borislav Petkov
2008-01-27  9:47 ` [PATCH 10/32] ide-tape: remove struct idetape_read_position_result_t Borislav Petkov
2008-01-27 19:43   ` Bartlomiej Zolnierkiewicz
2008-01-27  9:47 ` [PATCH 11/32] ide-tape: remove struct idetape_data_compression_page_t Borislav Petkov
2008-01-27  9:48 ` [PATCH 12/32] ide-tape: remove struct idetape_medium_partition_page_t Borislav Petkov
2008-01-27  9:48 ` [PATCH 13/32] ide-tape: remove struct idetape_parameter_block_descriptor_t Borislav Petkov
2008-01-27  9:48 ` [PATCH 14/32] ide-tape: remove structs os_partition_t, os_dat_entry_t, os_dat_t Borislav Petkov
2008-01-27  9:48 ` [PATCH 15/32] ide-tape: remove struct idetape_block_size_page_t Borislav Petkov
2008-01-27  9:48 ` Borislav Petkov [this message]
2008-01-27  9:48 ` [PATCH 17/32] ide-tape: remove EXPERIMENTAL driver status Borislav Petkov
2008-01-27  9:48 ` [PATCH 18/32] ide-tape: use generic byteorder macros Borislav Petkov
2008-01-27  9:48 ` [PATCH 19/32] ide-tape: remove unused sense packet commands Borislav Petkov
2008-01-27  9:48 ` [PATCH 20/32] ide-tape: make function name more accurate Borislav Petkov
2008-01-27  9:48 ` [PATCH 21/32] ide-tape: idetape_chrdev_direction_t:shorten enum names Borislav Petkov
2008-01-27 18:38   ` Bartlomiej Zolnierkiewicz
2008-01-27  9:48 ` [PATCH 22/32] ide-tape: struct idetape_packet_command_s: shorten member names Borislav Petkov
2008-01-27 19:40   ` Bartlomiej Zolnierkiewicz
2008-01-27  9:48 ` [PATCH 23/32] ide-tape: struct idetape_tape_t: " Borislav Petkov
2008-02-02 23:43   ` Bartlomiej Zolnierkiewicz
2008-02-03 11:36     ` Borislav Petkov
2008-01-27  9:48 ` [PATCH 24/32] ide-tape: remove unreachable code chunk Borislav Petkov
2008-01-27 19:41   ` Bartlomiej Zolnierkiewicz
2008-01-27  9:48 ` [PATCH 25/32] ide-tape: simplify code branching in the interrupt handler Borislav Petkov
2008-01-27 19:42   ` Bartlomiej Zolnierkiewicz
2008-01-27  9:48 ` [RFC PATCH 26/32] ide-tape: remove packet command and struct request memory buffers Borislav Petkov
2008-02-03  0:03   ` Bartlomiej Zolnierkiewicz
2008-01-27  9:48 ` [PATCH 27/32] ide-tape: remove idetape_increase_max_pipeline_stages() Borislav Petkov
2008-02-03  0:07   ` Bartlomiej Zolnierkiewicz
2008-01-27  9:48 ` [PATCH 28/32] ide-tape: shorten some function names Borislav Petkov
2008-02-03  0:12   ` Bartlomiej Zolnierkiewicz
2008-01-27  9:48 ` [PATCH 29/32] ide-tape: remove mtio.h related comments Borislav Petkov
2008-01-27 18:24   ` Bartlomiej Zolnierkiewicz
2008-01-27  9:48 ` [PATCH 30/32] ide-tape: remove atomic test/set macros Borislav Petkov
2008-01-27  9:48 ` [PATCH 31/32] ide-tape: remove idetape_config_t typedef Borislav Petkov
2008-01-27 18:30   ` Bartlomiej Zolnierkiewicz
2008-01-27  9:48 ` [PATCH 32/32] ide-tape: cleanup the remaining codestyle issues Borislav Petkov
2008-01-27 10:48 ` [PATCH 06/32] ide-tape: remove IDETAPE_DEBUG_BUGS Borislav Petkov
2008-01-27 15:35 ` Bartlomiej Zolnierkiewicz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1201427300-3954-11-git-send-email-petkovbb@gmail.com \
    --to=petkovbb@gmail.com \
    --cc=bbpetkov@yahoo.de \
    --cc=bzolnier@gmail.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [PATCH 16/32] ide-tape: use generic scsi commands' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).