hostap: 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: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200721150547.371763-1-vaibhavgupta40@gmail.com
This commit is contained in:
parent
140c602616
commit
99aaa1aafa
|
@ -3366,8 +3366,8 @@ static void prism2_free_local_data(struct net_device *dev)
|
|||
}
|
||||
|
||||
|
||||
#if (defined(PRISM2_PCI) && defined(CONFIG_PM)) || defined(PRISM2_PCCARD)
|
||||
static void prism2_suspend(struct net_device *dev)
|
||||
#if defined(PRISM2_PCI) || defined(PRISM2_PCCARD)
|
||||
static void __maybe_unused prism2_suspend(struct net_device *dev)
|
||||
{
|
||||
struct hostap_interface *iface;
|
||||
struct local_info *local;
|
||||
|
@ -3385,7 +3385,7 @@ static void prism2_suspend(struct net_device *dev)
|
|||
/* Disable hardware and firmware */
|
||||
prism2_hw_shutdown(dev, 0);
|
||||
}
|
||||
#endif /* (PRISM2_PCI && CONFIG_PM) || PRISM2_PCCARD */
|
||||
#endif /* PRISM2_PCI || PRISM2_PCCARD */
|
||||
|
||||
|
||||
/* These might at some point be compiled separately and used as separate
|
||||
|
|
|
@ -403,36 +403,23 @@ static void prism2_pci_remove(struct pci_dev *pdev)
|
|||
pci_disable_device(pdev);
|
||||
}
|
||||
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static int prism2_pci_suspend(struct pci_dev *pdev, pm_message_t state)
|
||||
static int __maybe_unused prism2_pci_suspend(struct device *dev_d)
|
||||
{
|
||||
struct net_device *dev = pci_get_drvdata(pdev);
|
||||
struct net_device *dev = dev_get_drvdata(dev_d);
|
||||
|
||||
if (netif_running(dev)) {
|
||||
netif_stop_queue(dev);
|
||||
netif_device_detach(dev);
|
||||
}
|
||||
prism2_suspend(dev);
|
||||
pci_save_state(pdev);
|
||||
pci_disable_device(pdev);
|
||||
pci_set_power_state(pdev, PCI_D3hot);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int prism2_pci_resume(struct pci_dev *pdev)
|
||||
static int __maybe_unused prism2_pci_resume(struct device *dev_d)
|
||||
{
|
||||
struct net_device *dev = pci_get_drvdata(pdev);
|
||||
int err;
|
||||
struct net_device *dev = dev_get_drvdata(dev_d);
|
||||
|
||||
err = pci_enable_device(pdev);
|
||||
if (err) {
|
||||
printk(KERN_ERR "%s: pci_enable_device failed on resume\n",
|
||||
dev->name);
|
||||
return err;
|
||||
}
|
||||
pci_restore_state(pdev);
|
||||
prism2_hw_config(dev, 0);
|
||||
if (netif_running(dev)) {
|
||||
netif_device_attach(dev);
|
||||
|
@ -441,20 +428,19 @@ static int prism2_pci_resume(struct pci_dev *pdev)
|
|||
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_PM */
|
||||
|
||||
|
||||
MODULE_DEVICE_TABLE(pci, prism2_pci_id_table);
|
||||
|
||||
static SIMPLE_DEV_PM_OPS(prism2_pci_pm_ops,
|
||||
prism2_pci_suspend,
|
||||
prism2_pci_resume);
|
||||
|
||||
static struct pci_driver prism2_pci_driver = {
|
||||
.name = "hostap_pci",
|
||||
.id_table = prism2_pci_id_table,
|
||||
.probe = prism2_pci_probe,
|
||||
.remove = prism2_pci_remove,
|
||||
#ifdef CONFIG_PM
|
||||
.suspend = prism2_pci_suspend,
|
||||
.resume = prism2_pci_resume,
|
||||
#endif /* CONFIG_PM */
|
||||
.driver.pm = &prism2_pci_pm_ops,
|
||||
};
|
||||
|
||||
module_pci_driver(prism2_pci_driver);
|
||||
|
|
Loading…
Reference in New Issue