Skip to content

Commit f65a204

Browse files
Michael Chandavem330
authored andcommitted
bnxt_en: Add suspend/resume callbacks.
Add suspend/resume callbacks using the newer dev_pm_ops method. Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5282db6 commit f65a204

File tree

1 file changed

+57
-0
lines changed
  • drivers/net/ethernet/broadcom/bnxt

1 file changed

+57
-0
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7703,6 +7703,62 @@ static void bnxt_shutdown(struct pci_dev *pdev)
77037703
rtnl_unlock();
77047704
}
77057705

7706+
#ifdef CONFIG_PM_SLEEP
7707+
static int bnxt_suspend(struct device *device)
7708+
{
7709+
struct pci_dev *pdev = to_pci_dev(device);
7710+
struct net_device *dev = pci_get_drvdata(pdev);
7711+
struct bnxt *bp = netdev_priv(dev);
7712+
int rc = 0;
7713+
7714+
rtnl_lock();
7715+
if (netif_running(dev)) {
7716+
netif_device_detach(dev);
7717+
rc = bnxt_close(dev);
7718+
}
7719+
bnxt_hwrm_func_drv_unrgtr(bp);
7720+
rtnl_unlock();
7721+
return rc;
7722+
}
7723+
7724+
static int bnxt_resume(struct device *device)
7725+
{
7726+
struct pci_dev *pdev = to_pci_dev(device);
7727+
struct net_device *dev = pci_get_drvdata(pdev);
7728+
struct bnxt *bp = netdev_priv(dev);
7729+
int rc = 0;
7730+
7731+
rtnl_lock();
7732+
if (bnxt_hwrm_ver_get(bp) || bnxt_hwrm_func_drv_rgtr(bp)) {
7733+
rc = -ENODEV;
7734+
goto resume_exit;
7735+
}
7736+
rc = bnxt_hwrm_func_reset(bp);
7737+
if (rc) {
7738+
rc = -EBUSY;
7739+
goto resume_exit;
7740+
}
7741+
bnxt_get_wol_settings(bp);
7742+
if (netif_running(dev)) {
7743+
rc = bnxt_open(dev);
7744+
if (!rc)
7745+
netif_device_attach(dev);
7746+
}
7747+
7748+
resume_exit:
7749+
rtnl_unlock();
7750+
return rc;
7751+
}
7752+
7753+
static SIMPLE_DEV_PM_OPS(bnxt_pm_ops, bnxt_suspend, bnxt_resume);
7754+
#define BNXT_PM_OPS (&bnxt_pm_ops)
7755+
7756+
#else
7757+
7758+
#define BNXT_PM_OPS NULL
7759+
7760+
#endif /* CONFIG_PM_SLEEP */
7761+
77067762
/**
77077763
* bnxt_io_error_detected - called when PCI error is detected
77087764
* @pdev: Pointer to PCI device
@@ -7820,6 +7876,7 @@ static struct pci_driver bnxt_pci_driver = {
78207876
.probe = bnxt_init_one,
78217877
.remove = bnxt_remove_one,
78227878
.shutdown = bnxt_shutdown,
7879+
.driver.pm = BNXT_PM_OPS,
78237880
.err_handler = &bnxt_err_handler,
78247881
#if defined(CONFIG_BNXT_SRIOV)
78257882
.sriov_configure = bnxt_sriov_configure,

0 commit comments

Comments
 (0)