All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
To: linux-ide@vger.kernel.org
Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 6/9] ide: factor out processing of special commands from ide_special_rq()
Date: Thu, 15 Jan 2009 21:01:15 +0100	[thread overview]
Message-ID: <20090115200115.17294.71947.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20090115200032.17294.84745.sendpatchset@localhost.localdomain>

From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] ide: factor out processing of special commands from ide_special_rq()

Factor out processing of special commands from ide_special_rq()
to ide_do_devset() and ide_do_park_unpark().

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
 drivers/ide/ide-io.c |   75 +++++++++++++++++++++++++++------------------------
 1 file changed, 41 insertions(+), 34 deletions(-)

Index: b/drivers/ide/ide-io.c
===================================================================
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -511,46 +511,53 @@ int ide_devset_execute(ide_drive_t *driv
 	return ret;
 }
 
+static ide_startstop_t ide_do_devset(ide_drive_t *drive, struct request *rq)
+{
+	int err, (*setfunc)(ide_drive_t *, int) = rq->special;
+
+	err = setfunc(drive, *(int *)&rq->cmd[1]);
+	if (err)
+		rq->errors = err;
+	else
+		err = 1;
+	ide_end_request(drive, err, 0);
+	return ide_stopped;
+}
+
+static ide_startstop_t ide_do_park_unpark(ide_drive_t *drive, struct request *rq)
+{
+	ide_task_t task;
+	struct ide_taskfile *tf = &task.tf;
+
+	memset(&task, 0, sizeof(task));
+	if (rq->cmd[0] == REQ_PARK_HEADS) {
+		drive->sleep = *(unsigned long *)rq->special;
+		drive->dev_flags |= IDE_DFLAG_SLEEPING;
+		tf->command = ATA_CMD_IDLEIMMEDIATE;
+		tf->feature = 0x44;
+		tf->lbal = 0x4c;
+		tf->lbam = 0x4e;
+		tf->lbah = 0x55;
+		task.tf_flags |= IDE_TFLAG_CUSTOM_HANDLER;
+	} else		/* cmd == REQ_UNPARK_HEADS */
+		tf->command = ATA_CMD_CHK_POWER;
+
+	task.tf_flags |= IDE_TFLAG_TF | IDE_TFLAG_DEVICE;
+	task.rq = rq;
+	drive->hwif->data_phase = task.data_phase = TASKFILE_NO_DATA;
+	return do_rw_taskfile(drive, &task);
+}
+
 static ide_startstop_t ide_special_rq(ide_drive_t *drive, struct request *rq)
 {
 	u8 cmd = rq->cmd[0];
 
-	if (cmd == REQ_PARK_HEADS || cmd == REQ_UNPARK_HEADS) {
-		ide_task_t task;
-		struct ide_taskfile *tf = &task.tf;
-
-		memset(&task, 0, sizeof(task));
-		if (cmd == REQ_PARK_HEADS) {
-			drive->sleep = *(unsigned long *)rq->special;
-			drive->dev_flags |= IDE_DFLAG_SLEEPING;
-			tf->command = ATA_CMD_IDLEIMMEDIATE;
-			tf->feature = 0x44;
-			tf->lbal = 0x4c;
-			tf->lbam = 0x4e;
-			tf->lbah = 0x55;
-			task.tf_flags |= IDE_TFLAG_CUSTOM_HANDLER;
-		} else		/* cmd == REQ_UNPARK_HEADS */
-			tf->command = ATA_CMD_CHK_POWER;
-
-		task.tf_flags |= IDE_TFLAG_TF | IDE_TFLAG_DEVICE;
-		task.rq = rq;
-		drive->hwif->data_phase = task.data_phase = TASKFILE_NO_DATA;
-		return do_rw_taskfile(drive, &task);
-	}
-
 	switch (cmd) {
+	case REQ_PARK_HEADS:
+	case REQ_UNPARK_HEADS:
+		return ide_do_park_unpark(drive, rq);
 	case REQ_DEVSET_EXEC:
-	{
-		int err, (*setfunc)(ide_drive_t *, int) = rq->special;
-
-		err = setfunc(drive, *(int *)&rq->cmd[1]);
-		if (err)
-			rq->errors = err;
-		else
-			err = 1;
-		ide_end_request(drive, err, 0);
-		return ide_stopped;
-	}
+		return ide_do_devset(drive, rq);
 	case REQ_DRIVE_RESET:
 		return ide_do_reset(drive);
 	default:

  parent reply	other threads:[~2009-01-15 20:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-15 20:00 [PATCH 0/9] ide: core code housekeeping Bartlomiej Zolnierkiewicz
2009-01-15 20:00 ` [PATCH 1/9] ide: remove stale comments from drive_is_ready() Bartlomiej Zolnierkiewicz
2009-01-15 20:00 ` [PATCH 2/9] ide: unexport ide_devset_execute() Bartlomiej Zolnierkiewicz
2009-01-15 20:00 ` [PATCH 3/9] ide: move drive_is_ready() to ide-io.c Bartlomiej Zolnierkiewicz
2009-01-17 20:22   ` Sergei Shtylyov
2009-01-15 20:01 ` [PATCH 4/9] ide: move ide_dma_timeout_retry() to ide-dma.c Bartlomiej Zolnierkiewicz
2009-01-17 20:20   ` Sergei Shtylyov
2009-01-15 20:01 ` [PATCH 5/9] ide: remove ide_do_drive_cmd() Bartlomiej Zolnierkiewicz
2009-01-17 20:13   ` Sergei Shtylyov
2009-01-15 20:01 ` Bartlomiej Zolnierkiewicz [this message]
2009-01-15 20:01 ` [PATCH 7/9] ide: move ide_do_park_unpark() to ide-park.c Bartlomiej Zolnierkiewicz
2009-01-17 20:14   ` Sergei Shtylyov
2009-01-15 20:01 ` [PATCH 8/9] ide: move device settings code to ide-devsets.c Bartlomiej Zolnierkiewicz
2009-01-15 20:01 ` [PATCH 9/9] ide: move xfer mode tuning code to ide-xfer-mode.c 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=20090115200115.17294.71947.sendpatchset@localhost.localdomain \
    --to=bzolnier@gmail.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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.