All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
To: linux-ide@vger.kernel.org
Cc: Borislav Petkov <petkovbb@gmail.com>,
	Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 06/22] ide: add ide_init_pc() helper
Date: Sun, 10 Aug 2008 17:36:09 +0200	[thread overview]
Message-ID: <20080810153609.16255.47218.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20080810153527.16255.2504.sendpatchset@localhost.localdomain>

* Add IDE_PC_BUFFER_SIZE define.

* Add ide_init_pc() and convert ide-{floppy,tape}.c to use it
  instead of ide*_init_pc().

* Remove no longer used IDE*_PC_BUFFER_SIZE and ide*_init_pc().

There should be no functional changes caused by this patch.

Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
 drivers/ide/ide-atapi.c  |    8 ++++++++
 drivers/ide/ide-floppy.c |   31 +++++++++----------------------
 drivers/ide/ide-tape.c   |   44 +++++++++++++-------------------------------
 include/linux/ide.h      |   10 +++++++++-
 4 files changed, 39 insertions(+), 54 deletions(-)

Index: b/drivers/ide/ide-atapi.c
===================================================================
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -111,6 +111,14 @@ int ide_io_buffers(ide_drive_t *drive, s
 }
 EXPORT_SYMBOL_GPL(ide_io_buffers);
 
+void ide_init_pc(struct ide_atapi_pc *pc)
+{
+	memset(pc, 0, sizeof(*pc));
+	pc->buf = pc->pc_buf;
+	pc->buf_size = IDE_PC_BUFFER_SIZE;
+}
+EXPORT_SYMBOL_GPL(ide_init_pc);
+
 /* TODO: unify the code thus making some arguments go away */
 ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc,
 	ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry,
Index: b/drivers/ide/ide-floppy.c
===================================================================
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -68,12 +68,6 @@
  */
 #define IDEFLOPPY_MAX_PC_RETRIES	3
 
-/*
- * With each packet command, we allocate a buffer of IDEFLOPPY_PC_BUFFER_SIZE
- * bytes.
- */
-#define IDEFLOPPY_PC_BUFFER_SIZE	256
-
 /* format capacities descriptor codes */
 #define CAPACITY_INVALID	0x00
 #define CAPACITY_UNFORMATTED	0x01
@@ -273,16 +267,9 @@ static void ide_floppy_callback(ide_driv
 	idefloppy_end_request(drive, uptodate, 0);
 }
 
-static void idefloppy_init_pc(struct ide_atapi_pc *pc)
-{
-	memset(pc, 0, sizeof(*pc));
-	pc->buf = pc->pc_buf;
-	pc->buf_size = IDEFLOPPY_PC_BUFFER_SIZE;
-}
-
 static void idefloppy_create_request_sense_cmd(struct ide_atapi_pc *pc)
 {
-	idefloppy_init_pc(pc);
+	ide_init_pc(pc);
 	pc->c[0] = GPCMD_REQUEST_SENSE;
 	pc->c[4] = 255;
 	pc->req_xfer = 18;
@@ -412,14 +399,14 @@ static void idefloppy_create_prevent_cmd
 {
 	debug_log("creating prevent removal command, prevent = %d\n", prevent);
 
-	idefloppy_init_pc(pc);
+	ide_init_pc(pc);
 	pc->c[0] = GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL;
 	pc->c[4] = prevent;
 }
 
 static void idefloppy_create_read_capacity_cmd(struct ide_atapi_pc *pc)
 {
-	idefloppy_init_pc(pc);
+	ide_init_pc(pc);
 	pc->c[0] = GPCMD_READ_FORMAT_CAPACITIES;
 	pc->c[7] = 255;
 	pc->c[8] = 255;
@@ -429,7 +416,7 @@ static void idefloppy_create_read_capaci
 static void idefloppy_create_format_unit_cmd(struct ide_atapi_pc *pc, int b,
 		int l, int flags)
 {
-	idefloppy_init_pc(pc);
+	ide_init_pc(pc);
 	pc->c[0] = GPCMD_FORMAT_UNIT;
 	pc->c[1] = 0x17;
 
@@ -453,7 +440,7 @@ static void idefloppy_create_mode_sense_
 {
 	u16 length = 8; /* sizeof(Mode Parameter Header) = 8 Bytes */
 
-	idefloppy_init_pc(pc);
+	ide_init_pc(pc);
 	pc->c[0] = GPCMD_MODE_SENSE_10;
 	pc->c[1] = 0;
 	pc->c[2] = page_code;
@@ -475,7 +462,7 @@ static void idefloppy_create_mode_sense_
 
 static void idefloppy_create_start_stop_cmd(struct ide_atapi_pc *pc, int start)
 {
-	idefloppy_init_pc(pc);
+	ide_init_pc(pc);
 	pc->c[0] = GPCMD_START_STOP_UNIT;
 	pc->c[4] = start;
 }
@@ -491,7 +478,7 @@ static void idefloppy_create_rw_cmd(idef
 	debug_log("create_rw10_cmd: block == %d, blocks == %d\n",
 		block, blocks);
 
-	idefloppy_init_pc(pc);
+	ide_init_pc(pc);
 	pc->c[0] = cmd == READ ? GPCMD_READ_10 : GPCMD_WRITE_10;
 	put_unaligned(cpu_to_be16(blocks), (unsigned short *)&pc->c[7]);
 	put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[2]);
@@ -510,7 +497,7 @@ static void idefloppy_create_rw_cmd(idef
 static void idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy,
 		struct ide_atapi_pc *pc, struct request *rq)
 {
-	idefloppy_init_pc(pc);
+	ide_init_pc(pc);
 	memcpy(pc->c, rq->cmd, sizeof(pc->c));
 	pc->rq = rq;
 	pc->b_count = 0;
@@ -1070,7 +1057,7 @@ static int idefloppy_open(struct inode *
 		drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS;
 		/* Just in case */
 
-		idefloppy_init_pc(&pc);
+		ide_init_pc(&pc);
 		pc.c[0] = GPCMD_TEST_UNIT_READY;
 
 		if (idefloppy_queue_pc_tail(drive, &pc)) {
Index: b/drivers/ide/ide-tape.c
===================================================================
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -81,12 +81,6 @@ enum {
 #define IDETAPE_MAX_PC_RETRIES		3
 
 /*
- * With each packet command, we allocate a buffer of IDETAPE_PC_BUFFER_SIZE
- * bytes. This is used for several packet commands (Not for READ/WRITE commands)
- */
-#define IDETAPE_PC_BUFFER_SIZE		256
-
-/*
  * Some drives (for example, Seagate STT3401A Travan) require a very long
  * timeout, because they don't return an interrupt or clear their busy bit
  * until after the command completes (even retension commands).
@@ -610,21 +604,9 @@ static void ide_tape_callback(ide_drive_
 	idetape_end_request(drive, uptodate, 0);
 }
 
-static void idetape_init_pc(struct ide_atapi_pc *pc)
-{
-	memset(pc->c, 0, 12);
-	pc->retries = 0;
-	pc->flags = 0;
-	pc->req_xfer = 0;
-	pc->buf = pc->pc_buf;
-	pc->buf_size = IDETAPE_PC_BUFFER_SIZE;
-	pc->bh = NULL;
-	pc->b_data = NULL;
-}
-
 static void idetape_create_request_sense_cmd(struct ide_atapi_pc *pc)
 {
-	idetape_init_pc(pc);
+	ide_init_pc(pc);
 	pc->c[0] = REQUEST_SENSE;
 	pc->c[4] = 20;
 	pc->req_xfer = 20;
@@ -816,7 +798,7 @@ static ide_startstop_t idetape_issue_pc(
 /* A mode sense command is used to "sense" tape parameters. */
 static void idetape_create_mode_sense_cmd(struct ide_atapi_pc *pc, u8 page_code)
 {
-	idetape_init_pc(pc);
+	ide_init_pc(pc);
 	pc->c[0] = MODE_SENSE;
 	if (page_code != IDETAPE_BLOCK_DESCRIPTOR)
 		/* DBD = 1 - Don't return block descriptors */
@@ -875,7 +857,7 @@ static void ide_tape_create_rw_cmd(ideta
 	struct idetape_bh *bh = (struct idetape_bh *)rq->special;
 	unsigned int length = rq->current_nr_sectors;
 
-	idetape_init_pc(pc);
+	ide_init_pc(pc);
 	put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]);
 	pc->c[1] = 1;
 	pc->bh = bh;
@@ -1164,7 +1146,7 @@ static void idetape_init_merge_buffer(id
 static void idetape_create_write_filemark_cmd(ide_drive_t *drive,
 		struct ide_atapi_pc *pc, int write_filemark)
 {
-	idetape_init_pc(pc);
+	ide_init_pc(pc);
 	pc->c[0] = WRITE_FILEMARKS;
 	pc->c[4] = write_filemark;
 	pc->flags |= PC_FLAG_WAIT_FOR_DSC;
@@ -1172,7 +1154,7 @@ static void idetape_create_write_filemar
 
 static void idetape_create_test_unit_ready_cmd(struct ide_atapi_pc *pc)
 {
-	idetape_init_pc(pc);
+	ide_init_pc(pc);
 	pc->c[0] = TEST_UNIT_READY;
 }
 
@@ -1199,7 +1181,7 @@ static int idetape_queue_pc_tail(ide_dri
 static void idetape_create_load_unload_cmd(ide_drive_t *drive,
 		struct ide_atapi_pc *pc, int cmd)
 {
-	idetape_init_pc(pc);
+	ide_init_pc(pc);
 	pc->c[0] = START_STOP;
 	pc->c[4] = cmd;
 	pc->flags |= PC_FLAG_WAIT_FOR_DSC;
@@ -1251,7 +1233,7 @@ static int idetape_flush_tape_buffers(id
 
 static void idetape_create_read_position_cmd(struct ide_atapi_pc *pc)
 {
-	idetape_init_pc(pc);
+	ide_init_pc(pc);
 	pc->c[0] = READ_POSITION;
 	pc->req_xfer = 20;
 }
@@ -1275,7 +1257,7 @@ static void idetape_create_locate_cmd(id
 		struct ide_atapi_pc *pc,
 		unsigned int block, u8 partition, int skip)
 {
-	idetape_init_pc(pc);
+	ide_init_pc(pc);
 	pc->c[0] = POSITION_TO_ELEMENT;
 	pc->c[1] = 2;
 	put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[3]);
@@ -1292,7 +1274,7 @@ static int idetape_create_prevent_cmd(id
 	if (!(tape->caps[6] & 0x01))
 		return 0;
 
-	idetape_init_pc(pc);
+	ide_init_pc(pc);
 	pc->c[0] = ALLOW_MEDIUM_REMOVAL;
 	pc->c[4] = prevent;
 	return 1;
@@ -1407,7 +1389,7 @@ static int idetape_queue_rw_tail(ide_dri
 
 static void idetape_create_inquiry_cmd(struct ide_atapi_pc *pc)
 {
-	idetape_init_pc(pc);
+	ide_init_pc(pc);
 	pc->c[0] = INQUIRY;
 	pc->c[4] = 254;
 	pc->req_xfer = 254;
@@ -1416,14 +1398,14 @@ static void idetape_create_inquiry_cmd(s
 static void idetape_create_rewind_cmd(ide_drive_t *drive,
 		struct ide_atapi_pc *pc)
 {
-	idetape_init_pc(pc);
+	ide_init_pc(pc);
 	pc->c[0] = REZERO_UNIT;
 	pc->flags |= PC_FLAG_WAIT_FOR_DSC;
 }
 
 static void idetape_create_erase_cmd(struct ide_atapi_pc *pc)
 {
-	idetape_init_pc(pc);
+	ide_init_pc(pc);
 	pc->c[0] = ERASE;
 	pc->c[1] = 1;
 	pc->flags |= PC_FLAG_WAIT_FOR_DSC;
@@ -1431,7 +1413,7 @@ static void idetape_create_erase_cmd(str
 
 static void idetape_create_space_cmd(struct ide_atapi_pc *pc, int count, u8 cmd)
 {
-	idetape_init_pc(pc);
+	ide_init_pc(pc);
 	pc->c[0] = SPACE;
 	put_unaligned(cpu_to_be32(count), (unsigned int *) &pc->c[1]);
 	pc->c[1] = cmd;
Index: b/include/linux/ide.h
===================================================================
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -722,6 +722,12 @@ enum {
 	PC_FLAG_TIMEDOUT		= (1 << 7),
 };
 
+/*
+ * With each packet command, we allocate a buffer of IDE_PC_BUFFER_SIZE bytes.
+ * This is used for several packet commands (not for READ/WRITE commands).
+ */
+#define IDE_PC_BUFFER_SIZE	256
+
 struct ide_atapi_pc {
 	/* actual packet bytes */
 	u8 c[12];
@@ -751,7 +757,7 @@ struct ide_atapi_pc {
 	 * those are more or less driver-specific and some of them are subject
 	 * to change/removal later.
 	 */
-	u8 pc_buf[256];
+	u8 pc_buf[IDE_PC_BUFFER_SIZE];
 
 	/* idetape only */
 	struct idetape_bh *bh;
@@ -1111,6 +1117,8 @@ void ide_pktcmd_tf_load(ide_drive_t *, u
 
 int ide_check_atapi_device(ide_drive_t *, const char *);
 
+void ide_init_pc(struct ide_atapi_pc *);
+
 ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc,
 	ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry,
 	void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *),

  parent reply	other threads:[~2008-08-10 15:38 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-10 15:35 [PATCH 00/22] ide: more work on generic ATAPI support Bartlomiej Zolnierkiewicz
2008-08-10 15:35 ` [PATCH 01/22] ide-floppy: fixup ide_floppy_io_buffers() Bartlomiej Zolnierkiewicz
2008-08-10 15:35 ` [PATCH 02/22] ide-scsi: cleanup ide_scsi_io_buffers() Bartlomiej Zolnierkiewicz
2008-08-10 15:35 ` [PATCH 03/22] ide: add ide_io_buffers() helper Bartlomiej Zolnierkiewicz
2008-08-10 15:35 ` [PATCH 04/22] ide-floppy: add ide_floppy_set_media_lock() helper Bartlomiej Zolnierkiewicz
2008-08-23 11:49   ` Sergei Shtylyov
2008-08-10 15:36 ` [PATCH 05/22] ide-tape: add ide_tape_set_media_lock() helper Bartlomiej Zolnierkiewicz
2008-08-10 15:36 ` Bartlomiej Zolnierkiewicz [this message]
2008-08-10 15:36 ` [PATCH 07/22] ide: add ide_queue_pc_head() helper Bartlomiej Zolnierkiewicz
2008-08-23 21:57   ` Sergei Shtylyov
2008-08-10 15:36 ` [PATCH 08/22] ide: add ide_queue_pc_tail() helper Bartlomiej Zolnierkiewicz
2008-08-23 21:58   ` Sergei Shtylyov
2008-08-10 15:36 ` [PATCH 09/22] ide-floppy: ->{srfp,wp} -> IDE_AFLAG_{SRFP,WP} Bartlomiej Zolnierkiewicz
2008-08-10 15:36 ` [PATCH 10/22] ide-floppy: move floppy ioctls handling to ide-floppy_ioctl.c Bartlomiej Zolnierkiewicz
2008-08-10 15:36 ` [PATCH 11/22] ide: add ide_set_media_lock() helper Bartlomiej Zolnierkiewicz
2008-08-11  6:02   ` Borislav Petkov
2008-08-12  9:05     ` Bartlomiej Zolnierkiewicz
2008-08-12 13:37       ` Boris Petkov
2008-08-12 17:48         ` Bartlomiej Zolnierkiewicz
2008-08-10 15:36 ` [PATCH 12/22] ide: add ide_do_start_stop() helper Bartlomiej Zolnierkiewicz
2008-08-10 15:37 ` [PATCH 13/22] ide: add ide_do_test_unit_ready() helper Bartlomiej Zolnierkiewicz
2008-08-23 21:31   ` Sergei Shtylyov
2008-08-10 15:37 ` [PATCH 14/22] ide: move IDE{FLOPPY,TAPE}_WAIT_CMD defines to <linux/ide.h> Bartlomiej Zolnierkiewicz
2008-08-10 15:37 ` [PATCH 15/22] ide: drop dsc_handle argument from ide_pc_intr() Bartlomiej Zolnierkiewicz
2008-08-10 15:37 ` [PATCH 16/22] ide: add pointer to the current packet command to ide_drive_t Bartlomiej Zolnierkiewicz
2008-08-10 15:37 ` [PATCH 17/22] ide: drop 'timeout' and 'expiry' arguments from ide_pc_intr() Bartlomiej Zolnierkiewicz
2008-08-10 15:37 ` [PATCH 18/22] ide: add request_sense_{pc,rq} to ide_drive_t Bartlomiej Zolnierkiewicz
2008-08-10 15:37 ` [PATCH 19/22] ide: add ide_retry_pc() helper Bartlomiej Zolnierkiewicz
2008-08-10 15:37 ` [PATCH 20/22] ide: add ->pc_{update,io}_buffers methods Bartlomiej Zolnierkiewicz
2008-08-10 15:37 ` [PATCH 21/22] ide: make ide_pc_intr() static Bartlomiej Zolnierkiewicz
2008-08-10 15:38 ` [PATCH 22/22] ide: make ide_transfer_pc() static Bartlomiej Zolnierkiewicz
2008-08-11  6:36 ` [PATCH 00/22] ide: more work on generic ATAPI support Borislav Petkov

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=20080810153609.16255.47218.sendpatchset@localhost.localdomain \
    --to=bzolnier@gmail.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=petkovbb@gmail.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.