[PATCH 07/12] ahci: Factor out PCI specifics from ahci_init_controller()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Anton Vorontsov
Date: Tuesday, March 2, 2010 - 11:29 am

Move PCI stuff into ahci_pci_init_controller().

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
 drivers/ata/ahci.c |   45 +++++++++++++++++++++++++++------------------
 1 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 1afb35e..aaeac15 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -1643,11 +1643,34 @@ static void ahci_port_init(struct device *dev, struct ata_port *ap,
 static void ahci_init_controller(struct ata_host *host)
 {
 	struct ahci_host_priv *hpriv = host->private_data;
-	struct pci_dev *pdev = to_pci_dev(host->dev);
 	void __iomem *mmio = hpriv->mmio;
 	int i;
 	void __iomem *port_mmio;
 	u32 tmp;
+
+	for (i = 0; i < host->n_ports; i++) {
+		struct ata_port *ap = host->ports[i];
+
+		port_mmio = ahci_port_base(ap);
+		if (ata_port_is_dummy(ap))
+			continue;
+
+		ahci_port_init(host->dev, ap, i, mmio, port_mmio);
+	}
+
+	tmp = readl(mmio + HOST_CTL);
+	VPRINTK("HOST_CTL 0x%x\n", tmp);
+	writel(tmp | HOST_IRQ_EN, mmio + HOST_CTL);
+	tmp = readl(mmio + HOST_CTL);
+	VPRINTK("HOST_CTL 0x%x\n", tmp);
+}
+
+static void ahci_pci_init_controller(struct ata_host *host)
+{
+	struct ahci_host_priv *hpriv = host->private_data;
+	struct pci_dev *pdev = to_pci_dev(host->dev);
+	void __iomem *port_mmio;
+	u32 tmp;
 	int mv;
 
 	if (hpriv->flags & AHCI_HFLAG_MV_PATA) {
@@ -1666,21 +1689,7 @@ static void ahci_init_controller(struct ata_host *host)
 			writel(tmp, port_mmio + PORT_IRQ_STAT);
 	}
 
-	for (i = 0; i < host->n_ports; i++) {
-		struct ata_port *ap = host->ports[i];
-
-		port_mmio = ahci_port_base(ap);
-		if (ata_port_is_dummy(ap))
-			continue;
-
-		ahci_port_init(host->dev, ap, i, mmio, port_mmio);
-	}
-
-	tmp = readl(mmio + HOST_CTL);
-	VPRINTK("HOST_CTL 0x%x\n", tmp);
-	writel(tmp | HOST_IRQ_EN, mmio + HOST_CTL);
-	tmp = readl(mmio + HOST_CTL);
-	VPRINTK("HOST_CTL 0x%x\n", tmp);
+	ahci_init_controller(host);
 }
 
 static void ahci_dev_config(struct ata_device *dev)
@@ -2511,7 +2520,7 @@ static int ahci_pci_device_resume(struct pci_dev *pdev)
 		if (rc)
 			return rc;
 
-		ahci_init_controller(host);
+		ahci_pci_init_controller(host);
 	}
 
 	ata_host_resume(host);
@@ -3219,7 +3228,7 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	if (rc)
 		return rc;
 
-	ahci_init_controller(host);
+	ahci_pci_init_controller(host);
 	ahci_print_info(host);
 
 	pci_set_master(pdev);
-- 
1.7.0

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH RFC 0/12] ahci: Add support for non-PCI devices, Anton Vorontsov, (Tue Mar 2, 11:28 am)
[PATCH 01/12] ahci: Fix some sparse warnings, Anton Vorontsov, (Tue Mar 2, 11:29 am)
[PATCH 02/12] ahci: Get rid of host-&gt;iomap usage, Anton Vorontsov, (Tue Mar 2, 11:29 am)
[PATCH 07/12] ahci: Factor out PCI specifics from ahci_ini ..., Anton Vorontsov, (Tue Mar 2, 11:29 am)
[PATCH 09/12] ahci: Introduce ahci_set_em_messages(), Anton Vorontsov, (Tue Mar 2, 11:29 am)
[PATCH 10/12] ahci: Move PCI code into ahci_pci.c, Anton Vorontsov, (Tue Mar 2, 11:29 am)
[PATCH 11/12] ahci: Export generic AHCI symbols, Anton Vorontsov, (Tue Mar 2, 11:29 am)
[PATCH 12/12] ahci: Add platform driver, Anton Vorontsov, (Tue Mar 2, 11:29 am)
Re: [PATCH 12/12] ahci: Add platform driver, Sergei Shtylyov, (Tue Mar 2, 12:41 pm)
Re: [PATCH 09/12] ahci: Introduce ahci_set_em_messages(), Sergei Shtylyov, (Tue Mar 2, 2:18 pm)
Re: [PATCH 09/12] ahci: Introduce ahci_set_em_messages(), Sergei Shtylyov, (Wed Mar 3, 3:40 am)
Re: [PATCH 12/12] ahci: Add platform driver, Anton Vorontsov, (Wed Mar 3, 6:14 am)
Re: [PATCH RFC 0/12] ahci: Add support for non-PCI devices, Anton Vorontsov, (Wed Mar 3, 6:15 am)