{}
 #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
        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) {
        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;
 }