linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <htejun@gmail.com>
To: jgarzik@pobox.com, alan@lxorguk.ukuu.org.uk, albertcc@tw.ibm.com,
	linux-ide@vger.kernel.org
Cc: Tejun Heo <htejun@gmail.com>
Subject: [PATCH 07/15] libata: reorganize ata_set_mode()
Date: Sat, 1 Apr 2006 01:38:18 +0900	[thread overview]
Message-ID: <11438230982830-git-send-email-htejun@gmail.com> (raw)
In-Reply-To: <1143823097579-git-send-email-htejun@gmail.com>

Merge ata_host_set_pio() and ata_host_set_dma() into ata_set_mode()
and use function-level *dev to iterate over devices.  This eases
soon-to-follow ata_set_mode() interface change.

While at it, kill an unnecessary comment and normalize others.

Signed-off-by: Tejun Heo <htejun@gmail.com>

---

 drivers/scsi/libata-core.c |   91 +++++++++++++++++---------------------------
 1 files changed, 35 insertions(+), 56 deletions(-)

dd939109a2ed9d9ad567d3688eace13cca31a9e1
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 913e378..f04561a 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -1771,47 +1771,6 @@ static int ata_dev_set_mode(struct ata_p
 	return 0;
 }
 
-static int ata_host_set_pio(struct ata_port *ap)
-{
-	int i;
-
-	for (i = 0; i < ATA_MAX_DEVICES; i++) {
-		struct ata_device *dev = &ap->device[i];
-
-		if (!ata_dev_enabled(dev))
-			continue;
-
-		if (!dev->pio_mode) {
-			printk(KERN_WARNING "ata%u: no PIO support for device %d.\n", ap->id, i);
-			return -1;
-		}
-
-		dev->xfer_mode = dev->pio_mode;
-		dev->xfer_shift = ATA_SHIFT_PIO;
-		if (ap->ops->set_piomode)
-			ap->ops->set_piomode(ap, dev);
-	}
-
-	return 0;
-}
-
-static void ata_host_set_dma(struct ata_port *ap)
-{
-	int i;
-
-	for (i = 0; i < ATA_MAX_DEVICES; i++) {
-		struct ata_device *dev = &ap->device[i];
-
-		if (!ata_dev_enabled(dev) || !dev->dma_mode)
-			continue;
-
-		dev->xfer_mode = dev->dma_mode;
-		dev->xfer_shift = ata_xfer_mode2shift(dev->dma_mode);
-		if (ap->ops->set_dmamode)
-			ap->ops->set_dmamode(ap, dev);
-	}
-}
-
 /**
  *	ata_set_mode - Program timings and issue SET FEATURES - XFER
  *	@ap: port on which timings will be programmed
@@ -1823,20 +1782,20 @@ static void ata_host_set_dma(struct ata_
  */
 static void ata_set_mode(struct ata_port *ap)
 {
+	struct ata_device *dev;
 	int i, rc, used_dma = 0, found = 0;
 
 	/* step 1: calculate xfer_mask */
 	for (i = 0; i < ATA_MAX_DEVICES; i++) {
-		struct ata_device *dev = &ap->device[i];
 		unsigned int pio_mask, dma_mask;
 
+		dev = &ap->device[i];
+
 		if (!ata_dev_enabled(dev))
 			continue;
 
 		ata_dev_xfermask(ap, dev);
 
-		/* TODO: let LLDD filter dev->*_mask here */
-
 		pio_mask = ata_pack_xfermask(dev->pio_mask, 0, 0);
 		dma_mask = ata_pack_xfermask(0, dev->mwdma_mask, dev->udma_mask);
 		dev->pio_mode = ata_xfer_mask2mode(pio_mask);
@@ -1850,16 +1809,40 @@ static void ata_set_mode(struct ata_port
 		return;
 
 	/* step 2: always set host PIO timings */
-	rc = ata_host_set_pio(ap);
-	if (rc)
-		goto err_out;
+	for (i = 0; i < ATA_MAX_DEVICES; i++) {
+		dev = &ap->device[i];
+		if (!ata_dev_enabled(dev))
+			continue;
+
+		if (!dev->pio_mode) {
+			printk(KERN_WARNING "ata%u: dev %u no PIO support\n",
+			       ap->id, dev->devno);
+			rc = -EINVAL;
+			goto err_out;
+		}
+
+		dev->xfer_mode = dev->pio_mode;
+		dev->xfer_shift = ATA_SHIFT_PIO;
+		if (ap->ops->set_piomode)
+			ap->ops->set_piomode(ap, dev);
+	}
 
 	/* step 3: set host DMA timings */
-	ata_host_set_dma(ap);
+	for (i = 0; i < ATA_MAX_DEVICES; i++) {
+		dev = &ap->device[i];
+
+		if (!ata_dev_enabled(dev) || !dev->dma_mode)
+			continue;
+
+		dev->xfer_mode = dev->dma_mode;
+		dev->xfer_shift = ata_xfer_mode2shift(dev->dma_mode);
+		if (ap->ops->set_dmamode)
+			ap->ops->set_dmamode(ap, dev);
+	}
 
 	/* step 4: update devices' xfer mode */
 	for (i = 0; i < ATA_MAX_DEVICES; i++) {
-		struct ata_device *dev = &ap->device[i];
+		dev = &ap->device[i];
 
 		if (!ata_dev_enabled(dev))
 			continue;
@@ -1869,17 +1852,13 @@ static void ata_set_mode(struct ata_port
 			goto err_out;
 	}
 
-	/*
-	 *	Record simplex status. If we selected DMA then the other
-	 *	host channels are not permitted to do so.
+	/* Record simplex status. If we selected DMA then the other
+	 * host channels are not permitted to do so.
 	 */
-
 	if (used_dma && (ap->host_set->flags & ATA_HOST_SIMPLEX))
 		ap->host_set->simplex_claimed = 1;
 
-	/*
-	 *	Chip specific finalisation
-	 */
+	/* step5: chip specific finalisation */
 	if (ap->ops->post_set_mode)
 		ap->ops->post_set_mode(ap);
 
-- 
1.2.4



  parent reply	other threads:[~2006-03-31 16:38 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-31 16:38 [PATCHSET] libata: improve ata_bus_probe failure handling Tejun Heo
2006-03-31 16:38 ` [PATCH 02/15] libata: make ata_bus_probe() return negative errno on failure Tejun Heo
2006-03-31 16:38 ` [PATCH 04/15] libata: convert do_probe_reset() to ata_do_reset() Tejun Heo
2006-03-31 16:38 ` [PATCH 01/15] libata: fix ata_set_mode() return value Tejun Heo
2006-04-01 17:34   ` Jeff Garzik
2006-03-31 16:38 ` [PATCH 03/15] libata: separate out ata_spd_string() Tejun Heo
2006-03-31 16:38 ` [PATCH 08/15] libata: don't disable devices from ata_set_mode() Tejun Heo
2006-04-01 19:46   ` Jeff Garzik
2006-03-31 16:38 ` [PATCH 05/15] libata: implement ata_dev_enabled and disabled() Tejun Heo
2006-04-01 17:29   ` Jeff Garzik
2006-04-02  0:54     ` Tejun Heo
2006-03-31 16:38 ` [PATCH 06/15] libata: make ata_set_mode() handle no-device case properly Tejun Heo
2006-03-31 16:38 ` Tejun Heo [this message]
2006-03-31 16:38 ` [PATCH 09/15] libata: implement ata_down_xfermask_limit() Tejun Heo
2006-03-31 22:31   ` Alan Cox
2006-04-01  0:11     ` Tejun Heo
2006-04-01 19:47   ` Jeff Garzik
2006-04-02  0:55     ` Tejun Heo
2006-04-02  6:58       ` Tejun Heo
2006-04-02  8:07         ` Jeff Garzik
2006-03-31 16:38 ` [PATCH 11/15] libata: preserve SATA SPD setting over hard resets Tejun Heo
2006-04-01 19:52   ` Jeff Garzik
2006-03-31 16:38 ` [PATCH 10/15] libata: add dev->sata_spd_limit and helpers Tejun Heo
2006-04-01 19:51   ` Jeff Garzik
2006-04-02  1:00     ` Tejun Heo
2006-04-02  8:12       ` Jeff Garzik
2006-03-31 16:38 ` [PATCH 15/15] libata: consider disabled devices in ata_dev_xfermask() Tejun Heo
2006-04-01 20:00   ` Jeff Garzik
2006-04-02  1:09     ` Tejun Heo
2006-03-31 16:38 ` [PATCH 14/15] libata: improve ata_bus_probe() Tejun Heo
2006-04-01 19:58   ` Jeff Garzik
2006-03-31 16:38 ` [PATCH 13/15] libata: add 1s sleep between resets Tejun Heo
2006-04-01 19:57   ` Jeff Garzik
2006-04-02  1:07     ` Tejun Heo
2006-03-31 16:38 ` [PATCH 12/15] libata: use SATA speeding down in ata_drive_probe_reset() Tejun Heo
2006-04-01 19:56   ` Jeff Garzik
2006-04-02  1:05     ` Tejun Heo

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=11438230982830-git-send-email-htejun@gmail.com \
    --to=htejun@gmail.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=albertcc@tw.ibm.com \
    --cc=jgarzik@pobox.com \
    --cc=linux-ide@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 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).