mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-27 19:29:37 +00:00
staging: qlge/qlge_main.c: use generic power management
Drivers should not use legacy power management as they have to manage power states and related operations, for the device, themselves. This driver was handling them with the help of PCI helper functions like pci_save/restore_state(), pci_enable/disable_device(), etc. With generic PM, all essentials will be handled by the PCI core. Driver needs to do only device-specific operations. The driver was also using pci_enable_wake(...,..., 0) to disable wake. Use device_wakeup_disable() instead. Compile-tested only. Signed-off-by: Vaibhav Gupta <vaibhavgupta40@gmail.com> Link: https://lore.kernel.org/r/20200629173459.262075-2-vaibhavgupta40@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
7a46931ba9
commit
be1247782e
1 changed files with 10 additions and 28 deletions
|
@ -4764,9 +4764,9 @@ static const struct pci_error_handlers qlge_err_handler = {
|
||||||
.resume = qlge_io_resume,
|
.resume = qlge_io_resume,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int qlge_suspend(struct pci_dev *pdev, pm_message_t state)
|
static int __maybe_unused qlge_suspend(struct device *dev_d)
|
||||||
{
|
{
|
||||||
struct net_device *ndev = pci_get_drvdata(pdev);
|
struct net_device *ndev = dev_get_drvdata(dev_d);
|
||||||
struct ql_adapter *qdev = netdev_priv(ndev);
|
struct ql_adapter *qdev = netdev_priv(ndev);
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
@ -4780,35 +4780,19 @@ static int qlge_suspend(struct pci_dev *pdev, pm_message_t state)
|
||||||
}
|
}
|
||||||
|
|
||||||
ql_wol(qdev);
|
ql_wol(qdev);
|
||||||
err = pci_save_state(pdev);
|
|
||||||
if (err)
|
|
||||||
return err;
|
|
||||||
|
|
||||||
pci_disable_device(pdev);
|
|
||||||
|
|
||||||
pci_set_power_state(pdev, pci_choose_state(pdev, state));
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_PM
|
static int __maybe_unused qlge_resume(struct device *dev_d)
|
||||||
static int qlge_resume(struct pci_dev *pdev)
|
|
||||||
{
|
{
|
||||||
struct net_device *ndev = pci_get_drvdata(pdev);
|
struct net_device *ndev = dev_get_drvdata(dev_d);
|
||||||
struct ql_adapter *qdev = netdev_priv(ndev);
|
struct ql_adapter *qdev = netdev_priv(ndev);
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
pci_set_power_state(pdev, PCI_D0);
|
pci_set_master(to_pci_dev(dev_d));
|
||||||
pci_restore_state(pdev);
|
|
||||||
err = pci_enable_device(pdev);
|
|
||||||
if (err) {
|
|
||||||
netif_err(qdev, ifup, qdev->ndev, "Cannot enable PCI device from suspend\n");
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
pci_set_master(pdev);
|
|
||||||
|
|
||||||
pci_enable_wake(pdev, PCI_D3hot, 0);
|
device_wakeup_disable(dev_d);
|
||||||
pci_enable_wake(pdev, PCI_D3cold, 0);
|
|
||||||
|
|
||||||
if (netif_running(ndev)) {
|
if (netif_running(ndev)) {
|
||||||
err = ql_adapter_up(qdev);
|
err = ql_adapter_up(qdev);
|
||||||
|
@ -4821,22 +4805,20 @@ static int qlge_resume(struct pci_dev *pdev)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_PM */
|
|
||||||
|
|
||||||
static void qlge_shutdown(struct pci_dev *pdev)
|
static void qlge_shutdown(struct pci_dev *pdev)
|
||||||
{
|
{
|
||||||
qlge_suspend(pdev, PMSG_SUSPEND);
|
qlge_suspend(&pdev->dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SIMPLE_DEV_PM_OPS(qlge_pm_ops, qlge_suspend, qlge_resume);
|
||||||
|
|
||||||
static struct pci_driver qlge_driver = {
|
static struct pci_driver qlge_driver = {
|
||||||
.name = DRV_NAME,
|
.name = DRV_NAME,
|
||||||
.id_table = qlge_pci_tbl,
|
.id_table = qlge_pci_tbl,
|
||||||
.probe = qlge_probe,
|
.probe = qlge_probe,
|
||||||
.remove = qlge_remove,
|
.remove = qlge_remove,
|
||||||
#ifdef CONFIG_PM
|
.driver.pm = &qlge_pm_ops,
|
||||||
.suspend = qlge_suspend,
|
|
||||||
.resume = qlge_resume,
|
|
||||||
#endif
|
|
||||||
.shutdown = qlge_shutdown,
|
.shutdown = qlge_shutdown,
|
||||||
.err_handler = &qlge_err_handler
|
.err_handler = &qlge_err_handler
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue