Commit 583871d4 authored by Hidetoshi Seto's avatar Hidetoshi Seto Committed by Jesse Barnes

PCI MSI: Relocate error path in init_msix_capability()

Move it from the middle of the function to the end.
Reviewed-by: default avatarMatthew Wilcox <willy@linux.intel.com>
Signed-off-by: default avatarHidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Signed-off-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
parent f56e4481
...@@ -494,24 +494,8 @@ static int msix_capability_init(struct pci_dev *dev, ...@@ -494,24 +494,8 @@ static int msix_capability_init(struct pci_dev *dev,
} }
ret = arch_setup_msi_irqs(dev, nvec, PCI_CAP_ID_MSIX); ret = arch_setup_msi_irqs(dev, nvec, PCI_CAP_ID_MSIX);
if (ret < 0) { if (ret)
/* If we had some success report the number of irqs goto error;
* we succeeded in setting up. */
int avail = 0;
list_for_each_entry(entry, &dev->msi_list, list) {
if (entry->irq != 0) {
avail++;
}
}
if (avail != 0)
ret = avail;
}
if (ret) {
free_msi_irqs(dev);
return ret;
}
/* /*
* Some devices require MSI-X to be enabled before we can touch the * Some devices require MSI-X to be enabled before we can touch the
...@@ -540,6 +524,26 @@ static int msix_capability_init(struct pci_dev *dev, ...@@ -540,6 +524,26 @@ static int msix_capability_init(struct pci_dev *dev,
pci_write_config_word(dev, pos + PCI_MSIX_FLAGS, control); pci_write_config_word(dev, pos + PCI_MSIX_FLAGS, control);
return 0; return 0;
error:
if (ret < 0) {
/*
* If we had some success, report the number of irqs
* we succeeded in setting up.
*/
int avail = 0;
list_for_each_entry(entry, &dev->msi_list, list) {
if (entry->irq != 0)
avail++;
}
if (avail != 0)
ret = avail;
}
free_msi_irqs(dev);
return ret;
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment