Commit 0c17ac54 authored by Vaibhav Gupta's avatar Vaibhav Gupta Committed by David S. Miller

ethernet: myri10ge: use generic power management

Drivers using legacy PM have to manage PCI states and device's PM states
themselves. They also need to take care of configuration registers.

With improved and powerful support of generic PM, PCI Core takes care of
above mentioned, device-independent, jobs.

This driver makes use of PCI helper functions like
pci_save/restore_state(), pci_enable/disable_device(),
pci_set_power_state() and pci_set_master() to do required operations. In
generic mode, they are no longer needed.

Change function parameter in both .suspend() and .resume() to
"struct device*" type. Use to_pci_dev() and dev_get_drvdata() to get
"struct pci_dev*" variable and drv data.

Compile-tested only.
Signed-off-by: default avatarVaibhav Gupta <vaibhavgupta40@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f43995bd
......@@ -3257,13 +3257,12 @@ static void myri10ge_mask_surprise_down(struct pci_dev *pdev)
}
}
#ifdef CONFIG_PM
static int myri10ge_suspend(struct pci_dev *pdev, pm_message_t state)
static int __maybe_unused myri10ge_suspend(struct device *dev)
{
struct myri10ge_priv *mgp;
struct net_device *netdev;
mgp = pci_get_drvdata(pdev);
mgp = dev_get_drvdata(dev);
if (mgp == NULL)
return -EINVAL;
netdev = mgp->dev;
......@@ -3276,14 +3275,13 @@ static int myri10ge_suspend(struct pci_dev *pdev, pm_message_t state)
rtnl_unlock();
}
myri10ge_dummy_rdma(mgp, 0);
pci_save_state(pdev);
pci_disable_device(pdev);
return pci_set_power_state(pdev, pci_choose_state(pdev, state));
return 0;
}
static int myri10ge_resume(struct pci_dev *pdev)
static int __maybe_unused myri10ge_resume(struct device *dev)
{
struct pci_dev *pdev = to_pci_dev(dev);
struct myri10ge_priv *mgp;
struct net_device *netdev;
int status;
......@@ -3293,7 +3291,6 @@ static int myri10ge_resume(struct pci_dev *pdev)
if (mgp == NULL)
return -EINVAL;
netdev = mgp->dev;
pci_set_power_state(pdev, PCI_D0); /* zeros conf space as a side effect */
msleep(5); /* give card time to respond */
pci_read_config_word(mgp->pdev, PCI_VENDOR_ID, &vendor);
if (vendor == 0xffff) {
......@@ -3301,23 +3298,9 @@ static int myri10ge_resume(struct pci_dev *pdev)
return -EIO;
}
pci_restore_state(pdev);
status = pci_enable_device(pdev);
if (status) {
dev_err(&pdev->dev, "failed to enable device\n");
return status;
}
pci_set_master(pdev);
myri10ge_reset(mgp);
myri10ge_dummy_rdma(mgp, 1);
/* Save configuration space to be restored if the
* nic resets due to a parity error */
pci_save_state(pdev);
if (netif_running(netdev)) {
rtnl_lock();
status = myri10ge_open(netdev);
......@@ -3331,11 +3314,8 @@ static int myri10ge_resume(struct pci_dev *pdev)
return 0;
abort_with_enabled:
pci_disable_device(pdev);
return -EIO;
}
#endif /* CONFIG_PM */
static u32 myri10ge_read_reboot(struct myri10ge_priv *mgp)
{
......@@ -4017,15 +3997,14 @@ static const struct pci_device_id myri10ge_pci_tbl[] = {
MODULE_DEVICE_TABLE(pci, myri10ge_pci_tbl);
static SIMPLE_DEV_PM_OPS(myri10ge_pm_ops, myri10ge_suspend, myri10ge_resume);
static struct pci_driver myri10ge_driver = {
.name = "myri10ge",
.probe = myri10ge_probe,
.remove = myri10ge_remove,
.id_table = myri10ge_pci_tbl,
#ifdef CONFIG_PM
.suspend = myri10ge_suspend,
.resume = myri10ge_resume,
#endif
.driver.pm = &myri10ge_pm_ops,
};
#ifdef CONFIG_MYRI10GE_DCA
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment