Skip to content

Commit

Permalink
PCI MSI: Relocate error path in init_msix_capability()
Browse files Browse the repository at this point in the history
Move it from the middle of the function to the end.

Reviewed-by: Matthew Wilcox <willy@linux.intel.com>
Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
  • Loading branch information
Hidetoshi Seto authored and Jesse Barnes committed Sep 9, 2009
1 parent f56e448 commit 583871d
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions drivers/pci/msi.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,24 +494,8 @@ static int msix_capability_init(struct pci_dev *dev,
}

ret = arch_setup_msi_irqs(dev, nvec, PCI_CAP_ID_MSIX);
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;
}

if (ret) {
free_msi_irqs(dev);
return ret;
}
if (ret)
goto error;

/*
* Some devices require MSI-X to be enabled before we can touch the
Expand Down Expand Up @@ -540,6 +524,26 @@ static int msix_capability_init(struct pci_dev *dev,
pci_write_config_word(dev, pos + PCI_MSIX_FLAGS, control);

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;
}

/**
Expand Down

0 comments on commit 583871d

Please sign in to comment.