Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=e94bd23f67c87011f012f26ca0af3fcf6878eeac
Commit:     e94bd23f67c87011f012f26ca0af3fcf6878eeac
Parent:     fb136c070bfdde11dc79758674f54fb26bba1a2f
Author:     Auke Kok <[EMAIL PROTECTED]>
AuthorDate: Wed May 16 01:49:46 2007 -0700
Committer:  Jeff Garzik <[EMAIL PROTECTED]>
CommitDate: Thu May 17 20:43:15 2007 -0400

    e1000: Fix msi enable leak on error, don't print error message, cleanup
    
    pci_enable_msi failure is a normal event so we should not print any error.
    Going over the code I spotted a missing pci_disable_msi() leak when irq
    allocation fails. The whole code also needed a cleanup, so I combined the
    two different calls to pci_request_irq into a single call making this
    look a lot better. All #ifdef CONFIG_PCI_MSI's have been removed.
    
    Compile tested with both CONFIG_PCI_MSI enabled and disabled.
    
    Signed-off-by: Auke Kok <[EMAIL PROTECTED]>
    Cc: H. Peter Anvin <[EMAIL PROTECTED]>
    Signed-off-by: Jeff Garzik <[EMAIL PROTECTED]>
---
 drivers/net/e1000/e1000.h      |    4 +---
 drivers/net/e1000/e1000_main.c |   39 ++++++++++++++-------------------------
 2 files changed, 15 insertions(+), 28 deletions(-)

diff --git a/drivers/net/e1000/e1000.h b/drivers/net/e1000/e1000.h
index a9ea67e..16a6edf 100644
--- a/drivers/net/e1000/e1000.h
+++ b/drivers/net/e1000/e1000.h
@@ -333,11 +333,9 @@ struct e1000_adapter {
        struct e1000_tx_ring test_tx_ring;
        struct e1000_rx_ring test_rx_ring;
 
-
        int msg_enable;
-#ifdef CONFIG_PCI_MSI
        boolean_t have_msi;
-#endif
+
        /* to not mess up cache alignment, always add to the bottom */
        boolean_t tso_force;
        boolean_t smart_power_down;     /* phy smart power down */
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 637ae8f..49be393 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -158,9 +158,7 @@ static struct net_device_stats * e1000_get_stats(struct 
net_device *netdev);
 static int e1000_change_mtu(struct net_device *netdev, int new_mtu);
 static int e1000_set_mac(struct net_device *netdev, void *p);
 static irqreturn_t e1000_intr(int irq, void *data);
-#ifdef CONFIG_PCI_MSI
 static irqreturn_t e1000_intr_msi(int irq, void *data);
-#endif
 static boolean_t e1000_clean_tx_irq(struct e1000_adapter *adapter,
                                     struct e1000_tx_ring *tx_ring);
 #ifdef CONFIG_E1000_NAPI
@@ -300,31 +298,26 @@ module_exit(e1000_exit_module);
 static int e1000_request_irq(struct e1000_adapter *adapter)
 {
        struct net_device *netdev = adapter->netdev;
-       int flags, err = 0;
+       void (*handler) = &e1000_intr;
+       int irq_flags = IRQF_SHARED;
+       int err;
 
-       flags = IRQF_SHARED;
-#ifdef CONFIG_PCI_MSI
        if (adapter->hw.mac_type >= e1000_82571) {
-               adapter->have_msi = TRUE;
-               if ((err = pci_enable_msi(adapter->pdev))) {
-                       DPRINTK(PROBE, ERR,
-                        "Unable to allocate MSI interrupt Error: %d\n", err);
-                       adapter->have_msi = FALSE;
+               adapter->have_msi = !pci_enable_msi(adapter->pdev);
+               if (adapter->have_msi) {
+                       handler = &e1000_intr_msi;
+                       irq_flags = 0;
                }
        }
-       if (adapter->have_msi) {
-               flags &= ~IRQF_SHARED;
-               err = request_irq(adapter->pdev->irq, &e1000_intr_msi, flags,
-                                 netdev->name, netdev);
-               if (err)
-                       DPRINTK(PROBE, ERR,
-                              "Unable to allocate interrupt Error: %d\n", err);
-       } else
-#endif
-       if ((err = request_irq(adapter->pdev->irq, &e1000_intr, flags,
-                              netdev->name, netdev)))
+
+       err = request_irq(adapter->pdev->irq, handler, irq_flags, netdev->name,
+                         netdev);
+       if (err) {
+               if (adapter->have_msi)
+                       pci_disable_msi(adapter->pdev);
                DPRINTK(PROBE, ERR,
                        "Unable to allocate interrupt Error: %d\n", err);
+       }
 
        return err;
 }
@@ -335,10 +328,8 @@ static void e1000_free_irq(struct e1000_adapter *adapter)
 
        free_irq(adapter->pdev->irq, netdev);
 
-#ifdef CONFIG_PCI_MSI
        if (adapter->have_msi)
                pci_disable_msi(adapter->pdev);
-#endif
 }
 
 /**
@@ -3744,7 +3735,6 @@ e1000_update_stats(struct e1000_adapter *adapter)
 
        spin_unlock_irqrestore(&adapter->stats_lock, flags);
 }
-#ifdef CONFIG_PCI_MSI
 
 /**
  * e1000_intr_msi - Interrupt Handler
@@ -3810,7 +3800,6 @@ e1000_intr_msi(int irq, void *data)
 
        return IRQ_HANDLED;
 }
-#endif
 
 /**
  * e1000_intr - Interrupt Handler
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to