Merge tag 'rdma-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland...
[firefly-linux-kernel-4.4.55.git] / drivers / ata / ahci.c
index a52a5b662f35ecceb992fd41943ef5f636834838..5a0bf8ed649b8cf9266530ef309aec89a54f99ef 100644 (file)
@@ -1166,13 +1166,13 @@ static inline void ahci_gtf_filter_workaround(struct ata_host *host)
 static int ahci_init_interrupts(struct pci_dev *pdev, unsigned int n_ports,
                         struct ahci_host_priv *hpriv)
 {
-       int rc, nvec;
+       int nvec;
 
        if (hpriv->flags & AHCI_HFLAG_NO_MSI)
                goto intx;
 
-       rc = pci_msi_vec_count(pdev);
-       if (rc < 0)
+       nvec = pci_msi_vec_count(pdev);
+       if (nvec < 0)
                goto intx;
 
        /*
@@ -1180,21 +1180,19 @@ static int ahci_init_interrupts(struct pci_dev *pdev, unsigned int n_ports,
         * Message mode could be enforced. In this case assume that advantage
         * of multipe MSIs is negated and use single MSI mode instead.
         */
-       if (rc < n_ports)
+       if (nvec < n_ports)
                goto single_msi;
 
-       nvec = rc;
-       rc = pci_enable_msi_block(pdev, nvec);
-       if (rc < 0)
-               goto intx;
-       else if (rc > 0)
+       nvec = pci_enable_msi_range(pdev, nvec, nvec);
+       if (nvec == -ENOSPC)
                goto single_msi;
+       else if (nvec < 0)
+               goto intx;
 
        return nvec;
 
 single_msi:
-       rc = pci_enable_msi(pdev);
-       if (rc)
+       if (pci_enable_msi(pdev))
                goto intx;
        return 1;