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

sis900: 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: default avatarVaibhav Gupta <vaibhavgupta40@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bfc6c183
...@@ -2502,11 +2502,9 @@ static void sis900_remove(struct pci_dev *pci_dev) ...@@ -2502,11 +2502,9 @@ static void sis900_remove(struct pci_dev *pci_dev)
pci_release_regions(pci_dev); pci_release_regions(pci_dev);
} }
#ifdef CONFIG_PM static int __maybe_unused sis900_suspend(struct device *dev)
static int sis900_suspend(struct pci_dev *pci_dev, pm_message_t state)
{ {
struct net_device *net_dev = pci_get_drvdata(pci_dev); struct net_device *net_dev = dev_get_drvdata(dev);
struct sis900_private *sis_priv = netdev_priv(net_dev); struct sis900_private *sis_priv = netdev_priv(net_dev);
void __iomem *ioaddr = sis_priv->ioaddr; void __iomem *ioaddr = sis_priv->ioaddr;
...@@ -2519,22 +2517,17 @@ static int sis900_suspend(struct pci_dev *pci_dev, pm_message_t state) ...@@ -2519,22 +2517,17 @@ static int sis900_suspend(struct pci_dev *pci_dev, pm_message_t state)
/* Stop the chip's Tx and Rx Status Machine */ /* Stop the chip's Tx and Rx Status Machine */
sw32(cr, RxDIS | TxDIS | sr32(cr)); sw32(cr, RxDIS | TxDIS | sr32(cr));
pci_set_power_state(pci_dev, PCI_D3hot);
pci_save_state(pci_dev);
return 0; return 0;
} }
static int sis900_resume(struct pci_dev *pci_dev) static int __maybe_unused sis900_resume(struct device *dev)
{ {
struct net_device *net_dev = pci_get_drvdata(pci_dev); struct net_device *net_dev = dev_get_drvdata(dev);
struct sis900_private *sis_priv = netdev_priv(net_dev); struct sis900_private *sis_priv = netdev_priv(net_dev);
void __iomem *ioaddr = sis_priv->ioaddr; void __iomem *ioaddr = sis_priv->ioaddr;
if(!netif_running(net_dev)) if(!netif_running(net_dev))
return 0; return 0;
pci_restore_state(pci_dev);
pci_set_power_state(pci_dev, PCI_D0);
sis900_init_rxfilter(net_dev); sis900_init_rxfilter(net_dev);
...@@ -2558,17 +2551,15 @@ static int sis900_resume(struct pci_dev *pci_dev) ...@@ -2558,17 +2551,15 @@ static int sis900_resume(struct pci_dev *pci_dev)
return 0; return 0;
} }
#endif /* CONFIG_PM */
static SIMPLE_DEV_PM_OPS(sis900_pm_ops, sis900_suspend, sis900_resume);
static struct pci_driver sis900_pci_driver = { static struct pci_driver sis900_pci_driver = {
.name = SIS900_MODULE_NAME, .name = SIS900_MODULE_NAME,
.id_table = sis900_pci_tbl, .id_table = sis900_pci_tbl,
.probe = sis900_probe, .probe = sis900_probe,
.remove = sis900_remove, .remove = sis900_remove,
#ifdef CONFIG_PM .driver.pm = &sis900_pm_ops,
.suspend = sis900_suspend,
.resume = sis900_resume,
#endif /* CONFIG_PM */
}; };
static int __init sis900_init_module(void) static int __init sis900_init_module(void)
......
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