diff options
author | Michael Chan <mchan@broadcom.com> | 2013-08-06 18:50:10 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-08-07 13:44:07 -0400 |
commit | 28fb4eb4b7f29abaef3e79be5fc049a904221698 (patch) | |
tree | ee635e524a5952b462fec83c22b859d8300591a2 /drivers/net/ethernet/broadcom/bnx2.c | |
parent | b6a23e91cccf7118c04edb71f28eac8c7bedc8d4 (diff) |
bnx2: Use SIMPLE_DEV_PM_OPS.
This simplifies the suspend/resume code.
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/broadcom/bnx2.c')
-rw-r--r-- | drivers/net/ethernet/broadcom/bnx2.c | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c index 0b54ca039a45..27a128ce8c7b 100644 --- a/drivers/net/ethernet/broadcom/bnx2.c +++ b/drivers/net/ethernet/broadcom/bnx2.c | |||
@@ -8602,46 +8602,52 @@ bnx2_remove_one(struct pci_dev *pdev) | |||
8602 | } | 8602 | } |
8603 | 8603 | ||
8604 | static int | 8604 | static int |
8605 | bnx2_suspend(struct pci_dev *pdev, pm_message_t state) | 8605 | bnx2_suspend(struct device *device) |
8606 | { | 8606 | { |
8607 | struct pci_dev *pdev = to_pci_dev(device); | ||
8607 | struct net_device *dev = pci_get_drvdata(pdev); | 8608 | struct net_device *dev = pci_get_drvdata(pdev); |
8608 | struct bnx2 *bp = netdev_priv(dev); | 8609 | struct bnx2 *bp = netdev_priv(dev); |
8609 | 8610 | ||
8610 | /* PCI register 4 needs to be saved whether netif_running() or not. | 8611 | if (netif_running(dev)) { |
8611 | * MSI address and data need to be saved if using MSI and | 8612 | cancel_work_sync(&bp->reset_task); |
8612 | * netif_running(). | 8613 | bnx2_netif_stop(bp, true); |
8613 | */ | 8614 | netif_device_detach(dev); |
8614 | pci_save_state(pdev); | 8615 | del_timer_sync(&bp->timer); |
8615 | if (!netif_running(dev)) | 8616 | bnx2_shutdown_chip(bp); |
8616 | return 0; | 8617 | __bnx2_free_irq(bp); |
8617 | 8618 | bnx2_free_skbs(bp); | |
8618 | cancel_work_sync(&bp->reset_task); | 8619 | } |
8619 | bnx2_netif_stop(bp, true); | 8620 | bnx2_setup_wol(bp); |
8620 | netif_device_detach(dev); | ||
8621 | del_timer_sync(&bp->timer); | ||
8622 | bnx2_shutdown_chip(bp); | ||
8623 | bnx2_free_skbs(bp); | ||
8624 | bnx2_set_power_state(bp, pci_choose_state(pdev, state)); | ||
8625 | return 0; | 8621 | return 0; |
8626 | } | 8622 | } |
8627 | 8623 | ||
8628 | static int | 8624 | static int |
8629 | bnx2_resume(struct pci_dev *pdev) | 8625 | bnx2_resume(struct device *device) |
8630 | { | 8626 | { |
8627 | struct pci_dev *pdev = to_pci_dev(device); | ||
8631 | struct net_device *dev = pci_get_drvdata(pdev); | 8628 | struct net_device *dev = pci_get_drvdata(pdev); |
8632 | struct bnx2 *bp = netdev_priv(dev); | 8629 | struct bnx2 *bp = netdev_priv(dev); |
8633 | 8630 | ||
8634 | pci_restore_state(pdev); | ||
8635 | if (!netif_running(dev)) | 8631 | if (!netif_running(dev)) |
8636 | return 0; | 8632 | return 0; |
8637 | 8633 | ||
8638 | bnx2_set_power_state(bp, PCI_D0); | 8634 | bnx2_set_power_state(bp, PCI_D0); |
8639 | netif_device_attach(dev); | 8635 | netif_device_attach(dev); |
8636 | bnx2_request_irq(bp); | ||
8640 | bnx2_init_nic(bp, 1); | 8637 | bnx2_init_nic(bp, 1); |
8641 | bnx2_netif_start(bp, true); | 8638 | bnx2_netif_start(bp, true); |
8642 | return 0; | 8639 | return 0; |
8643 | } | 8640 | } |
8644 | 8641 | ||
8642 | #ifdef CONFIG_PM_SLEEP | ||
8643 | static SIMPLE_DEV_PM_OPS(bnx2_pm_ops, bnx2_suspend, bnx2_resume); | ||
8644 | #define BNX2_PM_OPS (&bnx2_pm_ops) | ||
8645 | |||
8646 | #else | ||
8647 | |||
8648 | #define BNX2_PM_OPS NULL | ||
8649 | |||
8650 | #endif /* CONFIG_PM_SLEEP */ | ||
8645 | /** | 8651 | /** |
8646 | * bnx2_io_error_detected - called when PCI error is detected | 8652 | * bnx2_io_error_detected - called when PCI error is detected |
8647 | * @pdev: Pointer to PCI device | 8653 | * @pdev: Pointer to PCI device |
@@ -8757,8 +8763,7 @@ static struct pci_driver bnx2_pci_driver = { | |||
8757 | .id_table = bnx2_pci_tbl, | 8763 | .id_table = bnx2_pci_tbl, |
8758 | .probe = bnx2_init_one, | 8764 | .probe = bnx2_init_one, |
8759 | .remove = bnx2_remove_one, | 8765 | .remove = bnx2_remove_one, |
8760 | .suspend = bnx2_suspend, | 8766 | .driver.pm = BNX2_PM_OPS, |
8761 | .resume = bnx2_resume, | ||
8762 | .err_handler = &bnx2_err_handler, | 8767 | .err_handler = &bnx2_err_handler, |
8763 | }; | 8768 | }; |
8764 | 8769 | ||