aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/msi.c
diff options
context:
space:
mode:
authorGrant Grundler <grundler@parisc-linux.org>2006-01-14 02:34:53 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-03-23 17:35:10 -0500
commitb64c05e7de6071694dd6840eac9724a006ee19f8 (patch)
treeb611e32ceeaa0de2782334fe88a204dfe97e6017 /drivers/pci/msi.c
parentb0e6e962992b76580f4900b166a337bad7c1e81b (diff)
[PATCH] PCI: clean up msi.c a bit
Clean up: move assignments outside of if() statements. AFAICT, no functional change. Easier to read/understand. Depends on "[PATCH 1/3] msi vector targeting abstractions" by Mark Maule <maule@sgi.com>. I expect one hunk to fail if applied against 2.6.15. This is essentially Joe Perches' patch. I've cleaned up the one instance added by Mark's patch. Signed-off-by: Grant Grundler <grundler@parisc-linux.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/pci/msi.c')
-rw-r--r--drivers/pci/msi.c55
1 files changed, 35 insertions, 20 deletions
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 48723d6fa60..d5a67c1bcb9 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -103,9 +103,9 @@ static void set_msi_affinity(unsigned int vector, cpumask_t cpu_mask)
103 switch (entry->msi_attrib.type) { 103 switch (entry->msi_attrib.type) {
104 case PCI_CAP_ID_MSI: 104 case PCI_CAP_ID_MSI:
105 { 105 {
106 int pos; 106 int pos = pci_find_capability(entry->dev, PCI_CAP_ID_MSI);
107 107
108 if (!(pos = pci_find_capability(entry->dev, PCI_CAP_ID_MSI))) 108 if (!pos)
109 return; 109 return;
110 110
111 pci_read_config_dword(entry->dev, msi_lower_address_reg(pos), 111 pci_read_config_dword(entry->dev, msi_lower_address_reg(pos),
@@ -347,9 +347,9 @@ static int assign_msi_vector(void)
347 347
348static int get_new_vector(void) 348static int get_new_vector(void)
349{ 349{
350 int vector; 350 int vector = assign_msi_vector();
351 351
352 if ((vector = assign_msi_vector()) > 0) 352 if (vector > 0)
353 set_intr_gate(vector, interrupt[vector]); 353 set_intr_gate(vector, interrupt[vector]);
354 354
355 return vector; 355 return vector;
@@ -369,7 +369,8 @@ static int msi_init(void)
369 return status; 369 return status;
370 } 370 }
371 371
372 if ((status = msi_cache_init()) < 0) { 372 status = msi_cache_init();
373 if (status < 0) {
373 pci_msi_enable = 0; 374 pci_msi_enable = 0;
374 printk(KERN_WARNING "PCI: MSI cache init failed\n"); 375 printk(KERN_WARNING "PCI: MSI cache init failed\n");
375 return status; 376 return status;
@@ -523,10 +524,12 @@ static int msi_capability_init(struct pci_dev *dev)
523 pos = pci_find_capability(dev, PCI_CAP_ID_MSI); 524 pos = pci_find_capability(dev, PCI_CAP_ID_MSI);
524 pci_read_config_word(dev, msi_control_reg(pos), &control); 525 pci_read_config_word(dev, msi_control_reg(pos), &control);
525 /* MSI Entry Initialization */ 526 /* MSI Entry Initialization */
526 if (!(entry = alloc_msi_entry())) 527 entry = alloc_msi_entry();
528 if (!entry)
527 return -ENOMEM; 529 return -ENOMEM;
528 530
529 if ((vector = get_msi_vector(dev)) < 0) { 531 vector = get_msi_vector(dev);
532 if (vector < 0) {
530 kmem_cache_free(msi_cachep, entry); 533 kmem_cache_free(msi_cachep, entry);
531 return -EBUSY; 534 return -EBUSY;
532 } 535 }
@@ -620,7 +623,8 @@ static int msix_capability_init(struct pci_dev *dev,
620 entry = alloc_msi_entry(); 623 entry = alloc_msi_entry();
621 if (!entry) 624 if (!entry)
622 break; 625 break;
623 if ((vector = get_msi_vector(dev)) < 0) 626 vector = get_msi_vector(dev);
627 if (vector < 0)
624 break; 628 break;
625 629
626 j = entries[i].entry; 630 j = entries[i].entry;
@@ -701,10 +705,12 @@ int pci_enable_msi(struct pci_dev* dev)
701 705
702 temp = dev->irq; 706 temp = dev->irq;
703 707
704 if ((status = msi_init()) < 0) 708 status = msi_init();
709 if (status < 0)
705 return status; 710 return status;
706 711
707 if (!(pos = pci_find_capability(dev, PCI_CAP_ID_MSI))) 712 pos = pci_find_capability(dev, PCI_CAP_ID_MSI);
713 if (!pos)
708 return -EINVAL; 714 return -EINVAL;
709 715
710 pci_read_config_word(dev, msi_control_reg(pos), &control); 716 pci_read_config_word(dev, msi_control_reg(pos), &control);
@@ -728,8 +734,8 @@ int pci_enable_msi(struct pci_dev* dev)
728 dev->irq = temp; 734 dev->irq = temp;
729 } 735 }
730 /* Check whether driver already requested for MSI-X vectors */ 736 /* Check whether driver already requested for MSI-X vectors */
731 if ((pos = pci_find_capability(dev, PCI_CAP_ID_MSIX)) > 0 && 737 pos = pci_find_capability(dev, PCI_CAP_ID_MSIX);
732 !msi_lookup_vector(dev, PCI_CAP_ID_MSIX)) { 738 if (pos > 0 && !msi_lookup_vector(dev, PCI_CAP_ID_MSIX)) {
733 printk(KERN_INFO "PCI: %s: Can't enable MSI. " 739 printk(KERN_INFO "PCI: %s: Can't enable MSI. "
734 "Device already has MSI-X vectors assigned\n", 740 "Device already has MSI-X vectors assigned\n",
735 pci_name(dev)); 741 pci_name(dev));
@@ -755,7 +761,10 @@ void pci_disable_msi(struct pci_dev* dev)
755 u16 control; 761 u16 control;
756 unsigned long flags; 762 unsigned long flags;
757 763
758 if (!dev || !(pos = pci_find_capability(dev, PCI_CAP_ID_MSI))) 764 if (!dev)
765 return;
766 pos = pci_find_capability(dev, PCI_CAP_ID_MSI);
767 if (!pos)
759 return; 768 return;
760 769
761 pci_read_config_word(dev, msi_control_reg(pos), &control); 770 pci_read_config_word(dev, msi_control_reg(pos), &control);
@@ -924,10 +933,12 @@ int pci_enable_msix(struct pci_dev* dev, struct msix_entry *entries, int nvec)
924 if (!pci_msi_enable || !dev || !entries) 933 if (!pci_msi_enable || !dev || !entries)
925 return -EINVAL; 934 return -EINVAL;
926 935
927 if ((status = msi_init()) < 0) 936 status = msi_init();
937 if (status < 0)
928 return status; 938 return status;
929 939
930 if (!(pos = pci_find_capability(dev, PCI_CAP_ID_MSIX))) 940 pos = pci_find_capability(dev, PCI_CAP_ID_MSIX);
941 if (!pos)
931 return -EINVAL; 942 return -EINVAL;
932 943
933 pci_read_config_word(dev, msi_control_reg(pos), &control); 944 pci_read_config_word(dev, msi_control_reg(pos), &control);
@@ -1006,7 +1017,11 @@ void pci_disable_msix(struct pci_dev* dev)
1006 int pos, temp; 1017 int pos, temp;
1007 u16 control; 1018 u16 control;
1008 1019
1009 if (!dev || !(pos = pci_find_capability(dev, PCI_CAP_ID_MSIX))) 1020 if (!dev)
1021 return;
1022
1023 pos = pci_find_capability(dev, PCI_CAP_ID_MSIX);
1024 if (!pos)
1010 return; 1025 return;
1011 1026
1012 pci_read_config_word(dev, msi_control_reg(pos), &control); 1027 pci_read_config_word(dev, msi_control_reg(pos), &control);
@@ -1066,8 +1081,8 @@ void msi_remove_pci_irq_vectors(struct pci_dev* dev)
1066 return; 1081 return;
1067 1082
1068 temp = dev->irq; /* Save IOAPIC IRQ */ 1083 temp = dev->irq; /* Save IOAPIC IRQ */
1069 if ((pos = pci_find_capability(dev, PCI_CAP_ID_MSI)) > 0 && 1084 pos = pci_find_capability(dev, PCI_CAP_ID_MSI);
1070 !msi_lookup_vector(dev, PCI_CAP_ID_MSI)) { 1085 if (pos > 0 && !msi_lookup_vector(dev, PCI_CAP_ID_MSI)) {
1071 spin_lock_irqsave(&msi_lock, flags); 1086 spin_lock_irqsave(&msi_lock, flags);
1072 state = msi_desc[dev->irq]->msi_attrib.state; 1087 state = msi_desc[dev->irq]->msi_attrib.state;
1073 spin_unlock_irqrestore(&msi_lock, flags); 1088 spin_unlock_irqrestore(&msi_lock, flags);
@@ -1080,8 +1095,8 @@ void msi_remove_pci_irq_vectors(struct pci_dev* dev)
1080 msi_free_vector(dev, dev->irq, 0); 1095 msi_free_vector(dev, dev->irq, 0);
1081 dev->irq = temp; /* Restore IOAPIC IRQ */ 1096 dev->irq = temp; /* Restore IOAPIC IRQ */
1082 } 1097 }
1083 if ((pos = pci_find_capability(dev, PCI_CAP_ID_MSIX)) > 0 && 1098 pos = pci_find_capability(dev, PCI_CAP_ID_MSIX);
1084 !msi_lookup_vector(dev, PCI_CAP_ID_MSIX)) { 1099 if (pos > 0 && !msi_lookup_vector(dev, PCI_CAP_ID_MSIX)) {
1085 int vector, head, tail = 0, warning = 0; 1100 int vector, head, tail = 0, warning = 0;
1086 void __iomem *base = NULL; 1101 void __iomem *base = NULL;
1087 1102