diff options
author | Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com> | 2009-08-05 22:33:39 -0400 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2009-09-09 16:29:32 -0400 |
commit | 583871d436bea48cc2204cee0ec8eb7025e03db6 (patch) | |
tree | 607f50839335e102e103c579115738babce4a0db /drivers/pci/msi.c | |
parent | f56e4481328071d293306a55a951d83639d8d529 (diff) |
PCI MSI: Relocate error path in init_msix_capability()
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>
Diffstat (limited to 'drivers/pci/msi.c')
-rw-r--r-- | drivers/pci/msi.c | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index a7f2a014046b..7085d665db01 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c | |||
@@ -494,24 +494,8 @@ static int msix_capability_init(struct pci_dev *dev, | |||
494 | } | 494 | } |
495 | 495 | ||
496 | ret = arch_setup_msi_irqs(dev, nvec, PCI_CAP_ID_MSIX); | 496 | ret = arch_setup_msi_irqs(dev, nvec, PCI_CAP_ID_MSIX); |
497 | if (ret < 0) { | 497 | if (ret) |
498 | /* If we had some success report the number of irqs | 498 | goto error; |
499 | * we succeeded in setting up. */ | ||
500 | int avail = 0; | ||
501 | list_for_each_entry(entry, &dev->msi_list, list) { | ||
502 | if (entry->irq != 0) { | ||
503 | avail++; | ||
504 | } | ||
505 | } | ||
506 | |||
507 | if (avail != 0) | ||
508 | ret = avail; | ||
509 | } | ||
510 | |||
511 | if (ret) { | ||
512 | free_msi_irqs(dev); | ||
513 | return ret; | ||
514 | } | ||
515 | 499 | ||
516 | /* | 500 | /* |
517 | * Some devices require MSI-X to be enabled before we can touch the | 501 | * 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 | pci_write_config_word(dev, pos + PCI_MSIX_FLAGS, control); | 524 | pci_write_config_word(dev, pos + PCI_MSIX_FLAGS, control); |
541 | 525 | ||
542 | return 0; | 526 | return 0; |
527 | |||
528 | error: | ||
529 | if (ret < 0) { | ||
530 | /* | ||
531 | * If we had some success, report the number of irqs | ||
532 | * we succeeded in setting up. | ||
533 | */ | ||
534 | int avail = 0; | ||
535 | |||
536 | list_for_each_entry(entry, &dev->msi_list, list) { | ||
537 | if (entry->irq != 0) | ||
538 | avail++; | ||
539 | } | ||
540 | if (avail != 0) | ||
541 | ret = avail; | ||
542 | } | ||
543 | |||
544 | free_msi_irqs(dev); | ||
545 | |||
546 | return ret; | ||
543 | } | 547 | } |
544 | 548 | ||
545 | /** | 549 | /** |