aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAuke Kok <auke-jan.h.kok@intel.com>2007-05-16 04:49:46 -0400
committerJeff Garzik <jeff@garzik.org>2007-05-17 20:43:15 -0400
commite94bd23f67c87011f012f26ca0af3fcf6878eeac (patch)
tree59bd2c79007363beee0c50084e63f7840999bdfa
parentfb136c070bfdde11dc79758674f54fb26bba1a2f (diff)
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 <auke-jan.h.kok@intel.com> Cc: H. Peter Anvin <hpa@zytor.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
-rw-r--r--drivers/net/e1000/e1000.h4
-rw-r--r--drivers/net/e1000/e1000_main.c39
2 files changed, 15 insertions, 28 deletions
diff --git a/drivers/net/e1000/e1000.h b/drivers/net/e1000/e1000.h
index a9ea67e75c1b..16a6edfeba41 100644
--- a/drivers/net/e1000/e1000.h
+++ b/drivers/net/e1000/e1000.h
@@ -333,11 +333,9 @@ struct e1000_adapter {
333 struct e1000_tx_ring test_tx_ring; 333 struct e1000_tx_ring test_tx_ring;
334 struct e1000_rx_ring test_rx_ring; 334 struct e1000_rx_ring test_rx_ring;
335 335
336
337 int msg_enable; 336 int msg_enable;
338#ifdef CONFIG_PCI_MSI
339 boolean_t have_msi; 337 boolean_t have_msi;
340#endif 338
341 /* to not mess up cache alignment, always add to the bottom */ 339 /* to not mess up cache alignment, always add to the bottom */
342 boolean_t tso_force; 340 boolean_t tso_force;
343 boolean_t smart_power_down; /* phy smart power down */ 341 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 637ae8f68791..49be393e1c1d 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);
158static int e1000_change_mtu(struct net_device *netdev, int new_mtu); 158static int e1000_change_mtu(struct net_device *netdev, int new_mtu);
159static int e1000_set_mac(struct net_device *netdev, void *p); 159static int e1000_set_mac(struct net_device *netdev, void *p);
160static irqreturn_t e1000_intr(int irq, void *data); 160static irqreturn_t e1000_intr(int irq, void *data);
161#ifdef CONFIG_PCI_MSI
162static irqreturn_t e1000_intr_msi(int irq, void *data); 161static irqreturn_t e1000_intr_msi(int irq, void *data);
163#endif
164static boolean_t e1000_clean_tx_irq(struct e1000_adapter *adapter, 162static boolean_t e1000_clean_tx_irq(struct e1000_adapter *adapter,
165 struct e1000_tx_ring *tx_ring); 163 struct e1000_tx_ring *tx_ring);
166#ifdef CONFIG_E1000_NAPI 164#ifdef CONFIG_E1000_NAPI
@@ -300,31 +298,26 @@ module_exit(e1000_exit_module);
300static int e1000_request_irq(struct e1000_adapter *adapter) 298static int e1000_request_irq(struct e1000_adapter *adapter)
301{ 299{
302 struct net_device *netdev = adapter->netdev; 300 struct net_device *netdev = adapter->netdev;
303 int flags, err = 0; 301 void (*handler) = &e1000_intr;
302 int irq_flags = IRQF_SHARED;
303 int err;
304 304
305 flags = IRQF_SHARED;
306#ifdef CONFIG_PCI_MSI
307 if (adapter->hw.mac_type >= e1000_82571) { 305 if (adapter->hw.mac_type >= e1000_82571) {
308 adapter->have_msi = TRUE; 306 adapter->have_msi = !pci_enable_msi(adapter->pdev);
309 if ((err = pci_enable_msi(adapter->pdev))) { 307 if (adapter->have_msi) {
310 DPRINTK(PROBE, ERR, 308 handler = &e1000_intr_msi;
311 "Unable to allocate MSI interrupt Error: %d\n", err); 309 irq_flags = 0;
312 adapter->have_msi = FALSE;
313 } 310 }
314 } 311 }
315 if (adapter->have_msi) { 312
316 flags &= ~IRQF_SHARED; 313 err = request_irq(adapter->pdev->irq, handler, irq_flags, netdev->name,
317 err = request_irq(adapter->pdev->irq, &e1000_intr_msi, flags, 314 netdev);
318 netdev->name, netdev); 315 if (err) {
319 if (err) 316 if (adapter->have_msi)
320 DPRINTK(PROBE, ERR, 317 pci_disable_msi(adapter->pdev);
321 "Unable to allocate interrupt Error: %d\n", err);
322 } else
323#endif
324 if ((err = request_irq(adapter->pdev->irq, &e1000_intr, flags,
325 netdev->name, netdev)))
326 DPRINTK(PROBE, ERR, 318 DPRINTK(PROBE, ERR,
327 "Unable to allocate interrupt Error: %d\n", err); 319 "Unable to allocate interrupt Error: %d\n", err);
320 }
328 321
329 return err; 322 return err;
330} 323}
@@ -335,10 +328,8 @@ static void e1000_free_irq(struct e1000_adapter *adapter)
335 328
336 free_irq(adapter->pdev->irq, netdev); 329 free_irq(adapter->pdev->irq, netdev);
337 330
338#ifdef CONFIG_PCI_MSI
339 if (adapter->have_msi) 331 if (adapter->have_msi)
340 pci_disable_msi(adapter->pdev); 332 pci_disable_msi(adapter->pdev);
341#endif
342} 333}
343 334
344/** 335/**
@@ -3744,7 +3735,6 @@ e1000_update_stats(struct e1000_adapter *adapter)
3744 3735
3745 spin_unlock_irqrestore(&adapter->stats_lock, flags); 3736 spin_unlock_irqrestore(&adapter->stats_lock, flags);
3746} 3737}
3747#ifdef CONFIG_PCI_MSI
3748 3738
3749/** 3739/**
3750 * e1000_intr_msi - Interrupt Handler 3740 * e1000_intr_msi - Interrupt Handler
@@ -3810,7 +3800,6 @@ e1000_intr_msi(int irq, void *data)
3810 3800
3811 return IRQ_HANDLED; 3801 return IRQ_HANDLED;
3812} 3802}
3813#endif
3814 3803
3815/** 3804/**
3816 * e1000_intr - Interrupt Handler 3805 * e1000_intr - Interrupt Handler