mirror of
https://github.com/torvalds/linux.git
synced 2024-11-19 10:31:48 +00:00
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>
This commit is contained in:
parent
b6a23e91cc
commit
28fb4eb4b7
@ -8602,46 +8602,52 @@ bnx2_remove_one(struct pci_dev *pdev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
bnx2_suspend(struct pci_dev *pdev, pm_message_t state)
|
bnx2_suspend(struct device *device)
|
||||||
{
|
{
|
||||||
|
struct pci_dev *pdev = to_pci_dev(device);
|
||||||
struct net_device *dev = pci_get_drvdata(pdev);
|
struct net_device *dev = pci_get_drvdata(pdev);
|
||||||
struct bnx2 *bp = netdev_priv(dev);
|
struct bnx2 *bp = netdev_priv(dev);
|
||||||
|
|
||||||
/* PCI register 4 needs to be saved whether netif_running() or not.
|
if (netif_running(dev)) {
|
||||||
* MSI address and data need to be saved if using MSI and
|
cancel_work_sync(&bp->reset_task);
|
||||||
* netif_running().
|
bnx2_netif_stop(bp, true);
|
||||||
*/
|
netif_device_detach(dev);
|
||||||
pci_save_state(pdev);
|
del_timer_sync(&bp->timer);
|
||||||
if (!netif_running(dev))
|
bnx2_shutdown_chip(bp);
|
||||||
return 0;
|
__bnx2_free_irq(bp);
|
||||||
|
bnx2_free_skbs(bp);
|
||||||
cancel_work_sync(&bp->reset_task);
|
}
|
||||||
bnx2_netif_stop(bp, true);
|
bnx2_setup_wol(bp);
|
||||||
netif_device_detach(dev);
|
|
||||||
del_timer_sync(&bp->timer);
|
|
||||||
bnx2_shutdown_chip(bp);
|
|
||||||
bnx2_free_skbs(bp);
|
|
||||||
bnx2_set_power_state(bp, pci_choose_state(pdev, state));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
bnx2_resume(struct pci_dev *pdev)
|
bnx2_resume(struct device *device)
|
||||||
{
|
{
|
||||||
|
struct pci_dev *pdev = to_pci_dev(device);
|
||||||
struct net_device *dev = pci_get_drvdata(pdev);
|
struct net_device *dev = pci_get_drvdata(pdev);
|
||||||
struct bnx2 *bp = netdev_priv(dev);
|
struct bnx2 *bp = netdev_priv(dev);
|
||||||
|
|
||||||
pci_restore_state(pdev);
|
|
||||||
if (!netif_running(dev))
|
if (!netif_running(dev))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
bnx2_set_power_state(bp, PCI_D0);
|
bnx2_set_power_state(bp, PCI_D0);
|
||||||
netif_device_attach(dev);
|
netif_device_attach(dev);
|
||||||
|
bnx2_request_irq(bp);
|
||||||
bnx2_init_nic(bp, 1);
|
bnx2_init_nic(bp, 1);
|
||||||
bnx2_netif_start(bp, true);
|
bnx2_netif_start(bp, true);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_PM_SLEEP
|
||||||
|
static SIMPLE_DEV_PM_OPS(bnx2_pm_ops, bnx2_suspend, bnx2_resume);
|
||||||
|
#define BNX2_PM_OPS (&bnx2_pm_ops)
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define BNX2_PM_OPS NULL
|
||||||
|
|
||||||
|
#endif /* CONFIG_PM_SLEEP */
|
||||||
/**
|
/**
|
||||||
* bnx2_io_error_detected - called when PCI error is detected
|
* bnx2_io_error_detected - called when PCI error is detected
|
||||||
* @pdev: Pointer to PCI device
|
* @pdev: Pointer to PCI device
|
||||||
@ -8757,8 +8763,7 @@ static struct pci_driver bnx2_pci_driver = {
|
|||||||
.id_table = bnx2_pci_tbl,
|
.id_table = bnx2_pci_tbl,
|
||||||
.probe = bnx2_init_one,
|
.probe = bnx2_init_one,
|
||||||
.remove = bnx2_remove_one,
|
.remove = bnx2_remove_one,
|
||||||
.suspend = bnx2_suspend,
|
.driver.pm = BNX2_PM_OPS,
|
||||||
.resume = bnx2_resume,
|
|
||||||
.err_handler = &bnx2_err_handler,
|
.err_handler = &bnx2_err_handler,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user