aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bnx2.c
diff options
context:
space:
mode:
authorMichael Chan <mchan@broadcom.com>2008-10-09 15:21:08 -0400
committerDavid S. Miller <davem@davemloft.net>2008-10-09 15:21:08 -0400
commit74bf4ba3d367aacbc04fef167289767f162cd730 (patch)
tree6598112a6f1f95e739d339603827d46ec804f991 /drivers/net/bnx2.c
parent64194c31a0b6f5d84703b772113aafc400eeaad6 (diff)
bnx2: Add bnx2_shutdown_chip().
This logic is used in bnx2_close() and bnx2_suspend() and so should be separated out into a separate function. Signed-off-by: Michael Chan <mchan@broadcom.com> Signed-off-by: Benjamin Li <benli@broadcom.com> Signed-off-by: Matt Carlson <mcarlson@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bnx2.c')
-rw-r--r--drivers/net/bnx2.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 883e0a724107..b35f440361de 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -5073,6 +5073,21 @@ bnx2_init_nic(struct bnx2 *bp, int reset_phy)
5073} 5073}
5074 5074
5075static int 5075static int
5076bnx2_shutdown_chip(struct bnx2 *bp)
5077{
5078 u32 reset_code;
5079
5080 if (bp->flags & BNX2_FLAG_NO_WOL)
5081 reset_code = BNX2_DRV_MSG_CODE_UNLOAD_LNK_DN;
5082 else if (bp->wol)
5083 reset_code = BNX2_DRV_MSG_CODE_SUSPEND_WOL;
5084 else
5085 reset_code = BNX2_DRV_MSG_CODE_SUSPEND_NO_WOL;
5086
5087 return bnx2_reset_chip(bp, reset_code);
5088}
5089
5090static int
5076bnx2_test_registers(struct bnx2 *bp) 5091bnx2_test_registers(struct bnx2 *bp)
5077{ 5092{
5078 int ret; 5093 int ret;
@@ -6095,20 +6110,13 @@ static int
6095bnx2_close(struct net_device *dev) 6110bnx2_close(struct net_device *dev)
6096{ 6111{
6097 struct bnx2 *bp = netdev_priv(dev); 6112 struct bnx2 *bp = netdev_priv(dev);
6098 u32 reset_code;
6099 6113
6100 cancel_work_sync(&bp->reset_task); 6114 cancel_work_sync(&bp->reset_task);
6101 6115
6102 bnx2_disable_int_sync(bp); 6116 bnx2_disable_int_sync(bp);
6103 bnx2_napi_disable(bp); 6117 bnx2_napi_disable(bp);
6104 del_timer_sync(&bp->timer); 6118 del_timer_sync(&bp->timer);
6105 if (bp->flags & BNX2_FLAG_NO_WOL) 6119 bnx2_shutdown_chip(bp);
6106 reset_code = BNX2_DRV_MSG_CODE_UNLOAD_LNK_DN;
6107 else if (bp->wol)
6108 reset_code = BNX2_DRV_MSG_CODE_SUSPEND_WOL;
6109 else
6110 reset_code = BNX2_DRV_MSG_CODE_SUSPEND_NO_WOL;
6111 bnx2_reset_chip(bp, reset_code);
6112 bnx2_free_irq(bp); 6120 bnx2_free_irq(bp);
6113 bnx2_free_skbs(bp); 6121 bnx2_free_skbs(bp);
6114 bnx2_free_mem(bp); 6122 bnx2_free_mem(bp);
@@ -7777,7 +7785,6 @@ bnx2_suspend(struct pci_dev *pdev, pm_message_t state)
7777{ 7785{
7778 struct net_device *dev = pci_get_drvdata(pdev); 7786 struct net_device *dev = pci_get_drvdata(pdev);
7779 struct bnx2 *bp = netdev_priv(dev); 7787 struct bnx2 *bp = netdev_priv(dev);
7780 u32 reset_code;
7781 7788
7782 /* PCI register 4 needs to be saved whether netif_running() or not. 7789 /* PCI register 4 needs to be saved whether netif_running() or not.
7783 * MSI address and data need to be saved if using MSI and 7790 * MSI address and data need to be saved if using MSI and
@@ -7791,13 +7798,7 @@ bnx2_suspend(struct pci_dev *pdev, pm_message_t state)
7791 bnx2_netif_stop(bp); 7798 bnx2_netif_stop(bp);
7792 netif_device_detach(dev); 7799 netif_device_detach(dev);
7793 del_timer_sync(&bp->timer); 7800 del_timer_sync(&bp->timer);
7794 if (bp->flags & BNX2_FLAG_NO_WOL) 7801 bnx2_shutdown_chip(bp);
7795 reset_code = BNX2_DRV_MSG_CODE_UNLOAD_LNK_DN;
7796 else if (bp->wol)
7797 reset_code = BNX2_DRV_MSG_CODE_SUSPEND_WOL;
7798 else
7799 reset_code = BNX2_DRV_MSG_CODE_SUSPEND_NO_WOL;
7800 bnx2_reset_chip(bp, reset_code);
7801 bnx2_free_skbs(bp); 7802 bnx2_free_skbs(bp);
7802 bnx2_set_power_state(bp, pci_choose_state(pdev, state)); 7803 bnx2_set_power_state(bp, pci_choose_state(pdev, state));
7803 return 0; 7804 return 0;