Commit 7ada9a5e authored by Vaibhav Gupta's avatar Vaibhav Gupta Committed by David S. Miller

qlcninc: use generic power management

With legacy PM, drivers themselves were responsible for managing the
device's power states and taking care of register states. And they use PCI
helper functions to do it.

After upgrading to the generic structure, PCI core will take care of
required tasks and drivers should do only device-specific operations.

.suspend() calls __qlcnic_shutdown, which then calls qlcnic_82xx_shutdown;
.resume()  calls __qlcnic_resume,   which then calls qlcnic_82xx_resume;

Both ...82xx..() are define in
drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c and are used only in
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c.

Hence upgrade them and remove PCI function calls, like pci_save_state() and
pci_enable_wake(), inside them

Compile-tested only.
Signed-off-by: default avatarVaibhav Gupta <vaibhavgupta40@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 063ad9bc
...@@ -1649,7 +1649,6 @@ int qlcnic_82xx_shutdown(struct pci_dev *pdev) ...@@ -1649,7 +1649,6 @@ int qlcnic_82xx_shutdown(struct pci_dev *pdev)
{ {
struct qlcnic_adapter *adapter = pci_get_drvdata(pdev); struct qlcnic_adapter *adapter = pci_get_drvdata(pdev);
struct net_device *netdev = adapter->netdev; struct net_device *netdev = adapter->netdev;
int retval;
netif_device_detach(netdev); netif_device_detach(netdev);
...@@ -1662,14 +1661,8 @@ int qlcnic_82xx_shutdown(struct pci_dev *pdev) ...@@ -1662,14 +1661,8 @@ int qlcnic_82xx_shutdown(struct pci_dev *pdev)
clear_bit(__QLCNIC_RESETTING, &adapter->state); clear_bit(__QLCNIC_RESETTING, &adapter->state);
retval = pci_save_state(pdev); if (qlcnic_wol_supported(adapter))
if (retval) device_wakeup_enable(&pdev->dev);
return retval;
if (qlcnic_wol_supported(adapter)) {
pci_enable_wake(pdev, PCI_D3cold, 1);
pci_enable_wake(pdev, PCI_D3hot, 1);
}
return 0; return 0;
} }
......
...@@ -2811,35 +2811,17 @@ static void qlcnic_shutdown(struct pci_dev *pdev) ...@@ -2811,35 +2811,17 @@ static void qlcnic_shutdown(struct pci_dev *pdev)
pci_disable_device(pdev); pci_disable_device(pdev);
} }
#ifdef CONFIG_PM static int __maybe_unused qlcnic_suspend(struct device *dev_d)
static int qlcnic_suspend(struct pci_dev *pdev, pm_message_t state)
{ {
int retval; return __qlcnic_shutdown(to_pci_dev(dev_d));
retval = __qlcnic_shutdown(pdev);
if (retval)
return retval;
pci_set_power_state(pdev, pci_choose_state(pdev, state));
return 0;
} }
static int qlcnic_resume(struct pci_dev *pdev) static int __maybe_unused qlcnic_resume(struct device *dev_d)
{ {
struct qlcnic_adapter *adapter = pci_get_drvdata(pdev); struct qlcnic_adapter *adapter = dev_get_drvdata(dev_d);
int err;
err = pci_enable_device(pdev);
if (err)
return err;
pci_set_power_state(pdev, PCI_D0);
pci_set_master(pdev);
pci_restore_state(pdev);
return __qlcnic_resume(adapter); return __qlcnic_resume(adapter);
} }
#endif
static int qlcnic_open(struct net_device *netdev) static int qlcnic_open(struct net_device *netdev)
{ {
...@@ -4258,15 +4240,14 @@ static const struct pci_error_handlers qlcnic_err_handler = { ...@@ -4258,15 +4240,14 @@ static const struct pci_error_handlers qlcnic_err_handler = {
.resume = qlcnic_io_resume, .resume = qlcnic_io_resume,
}; };
static SIMPLE_DEV_PM_OPS(qlcnic_pm_ops, qlcnic_suspend, qlcnic_resume);
static struct pci_driver qlcnic_driver = { static struct pci_driver qlcnic_driver = {
.name = qlcnic_driver_name, .name = qlcnic_driver_name,
.id_table = qlcnic_pci_tbl, .id_table = qlcnic_pci_tbl,
.probe = qlcnic_probe, .probe = qlcnic_probe,
.remove = qlcnic_remove, .remove = qlcnic_remove,
#ifdef CONFIG_PM .driver.pm = &qlcnic_pm_ops,
.suspend = qlcnic_suspend,
.resume = qlcnic_resume,
#endif
.shutdown = qlcnic_shutdown, .shutdown = qlcnic_shutdown,
.err_handler = &qlcnic_err_handler, .err_handler = &qlcnic_err_handler,
#ifdef CONFIG_QLCNIC_SRIOV #ifdef CONFIG_QLCNIC_SRIOV
......
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