]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
ahci: Move interrupt enablement code to a separate function
authorRobert Richter <rrichter@cavium.com>
Sun, 31 May 2015 11:55:17 +0000 (13:55 +0200)
committerTejun Heo <tj@kernel.org>
Wed, 3 Jun 2015 05:37:49 +0000 (01:37 -0400)
This patch refactors ahci_init_interrupts() and moves msi code to a
separate function. Need the split since we add msix initialization in
a later patch. The initialization for msix will be done after msi but
before intx.

Signed-off-by: Robert Richter <rrichter@cavium.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
drivers/ata/ahci.c

index c7a92a743ed035e9af81ac779180fc65456a8390..7ba5332476c6f9061917d951ba594121717e7c04 100644 (file)
@@ -1201,17 +1201,17 @@ static inline void ahci_gtf_filter_workaround(struct ata_host *host)
 {}
 #endif
 
-static int ahci_init_interrupts(struct pci_dev *pdev, unsigned int n_ports,
-                               struct ahci_host_priv *hpriv)
+static int ahci_init_msi(struct pci_dev *pdev, unsigned int n_ports,
+                       struct ahci_host_priv *hpriv)
 {
        int rc, nvec;
 
        if (hpriv->flags & AHCI_HFLAG_NO_MSI)
-               goto intx;
+               return -ENODEV;
 
        nvec = pci_msi_vec_count(pdev);
        if (nvec < 0)
-               goto intx;
+               return nvec;
 
        /*
         * If number of MSIs is less than number of ports then Sharing Last
@@ -1224,8 +1224,8 @@ static int ahci_init_interrupts(struct pci_dev *pdev, unsigned int n_ports,
        rc = pci_enable_msi_exact(pdev, nvec);
        if (rc == -ENOSPC)
                goto single_msi;
-       else if (rc < 0)
-               goto intx;
+       if (rc < 0)
+               return rc;
 
        /* fallback to single MSI mode if the controller enforced MRSM mode */
        if (readl(hpriv->mmio + HOST_CTL) & HOST_MRSM) {
@@ -1240,12 +1240,25 @@ static int ahci_init_interrupts(struct pci_dev *pdev, unsigned int n_ports,
        return nvec;
 
 single_msi:
-       if (pci_enable_msi(pdev))
-               goto intx;
+       rc = pci_enable_msi(pdev);
+       if (rc < 0)
+               return rc;
+
        return 1;
+}
 
-intx:
+static int ahci_init_interrupts(struct pci_dev *pdev, unsigned int n_ports,
+                               struct ahci_host_priv *hpriv)
+{
+       int nvec;
+
+       nvec = ahci_init_msi(pdev, n_ports, hpriv);
+       if (nvec >= 0)
+               return nvec;
+
+       /* lagacy intx interrupts */
        pci_intx(pdev, 1);
+
        return 0;
 }