diff options
author | Vaibhav Gupta <vaibhavgupta40@gmail.com> | 2020-07-30 12:23:34 +0530 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-07-30 17:43:01 -0700 |
commit | bfc6c183cb820bfca22c6f075bd81be7ef84d774 (patch) | |
tree | cce089aa6ca74139492fe645c6ac4da9ec71833f | |
parent | bbf1b94a733d823f195d9e9f960a2e60718acc3e (diff) | |
download | linux-bfc6c183cb820bfca22c6f075bd81be7ef84d774.tar.bz2 |
sc92031: use generic power management
Drivers using legacy power management .suspen()/.resume() callbacks
have to manage PCI states and device's PM states themselves. They also
need to take care of standard configuration registers.
Switch to generic power management framework using a single
"struct dev_pm_ops" variable to take the unnecessary load from the driver.
This also avoids the need for the driver to directly call most of the PCI
helper functions and device power state control functions, as through
the generic framework PCI Core takes care of the necessary operations,
and drivers are required to do only device-specific jobs.
Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/silan/sc92031.c | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/drivers/net/ethernet/silan/sc92031.c b/drivers/net/ethernet/silan/sc92031.c index cb043eb1bdc1..f94078f8ebe5 100644 --- a/drivers/net/ethernet/silan/sc92031.c +++ b/drivers/net/ethernet/silan/sc92031.c @@ -1499,15 +1499,13 @@ static void sc92031_remove(struct pci_dev *pdev) pci_disable_device(pdev); } -static int sc92031_suspend(struct pci_dev *pdev, pm_message_t state) +static int __maybe_unused sc92031_suspend(struct device *dev_d) { - struct net_device *dev = pci_get_drvdata(pdev); + struct net_device *dev = dev_get_drvdata(dev_d); struct sc92031_priv *priv = netdev_priv(dev); - pci_save_state(pdev); - if (!netif_running(dev)) - goto out; + return 0; netif_device_detach(dev); @@ -1521,22 +1519,16 @@ static int sc92031_suspend(struct pci_dev *pdev, pm_message_t state) spin_unlock_bh(&priv->lock); -out: - pci_set_power_state(pdev, pci_choose_state(pdev, state)); - return 0; } -static int sc92031_resume(struct pci_dev *pdev) +static int __maybe_unused sc92031_resume(struct device *dev_d) { - struct net_device *dev = pci_get_drvdata(pdev); + struct net_device *dev = dev_get_drvdata(dev_d); struct sc92031_priv *priv = netdev_priv(dev); - pci_restore_state(pdev); - pci_set_power_state(pdev, PCI_D0); - if (!netif_running(dev)) - goto out; + return 0; /* Interrupts already disabled by sc92031_suspend */ spin_lock_bh(&priv->lock); @@ -1553,7 +1545,6 @@ static int sc92031_resume(struct pci_dev *pdev) else netif_tx_disable(dev); -out: return 0; } @@ -1565,13 +1556,14 @@ static const struct pci_device_id sc92031_pci_device_id_table[] = { }; MODULE_DEVICE_TABLE(pci, sc92031_pci_device_id_table); +static SIMPLE_DEV_PM_OPS(sc92031_pm_ops, sc92031_suspend, sc92031_resume); + static struct pci_driver sc92031_pci_driver = { .name = SC92031_NAME, .id_table = sc92031_pci_device_id_table, .probe = sc92031_probe, .remove = sc92031_remove, - .suspend = sc92031_suspend, - .resume = sc92031_resume, + .driver.pm = &sc92031_pm_ops, }; module_pci_driver(sc92031_pci_driver); |