Commit 78cad4ce authored by Vaibhav Gupta's avatar Vaibhav Gupta Committed by David S. Miller

sundance: use generic power management

With legacy PM, drivers themselves were responsible for managing the
device's power states and takes care of register states.

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

Thus, there is no need to call the PCI helper functions like
pci_enable/disable_device(), pci_save/restore_sate() and
pci_set_power_state().

Compile-tested only.
Signed-off-by: default avatarVaibhav Gupta <vaibhavgupta40@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1c2e4839
...@@ -1928,11 +1928,9 @@ static void sundance_remove1(struct pci_dev *pdev) ...@@ -1928,11 +1928,9 @@ static void sundance_remove1(struct pci_dev *pdev)
} }
} }
#ifdef CONFIG_PM static int __maybe_unused sundance_suspend(struct device *dev_d)
static int sundance_suspend(struct pci_dev *pci_dev, pm_message_t state)
{ {
struct net_device *dev = pci_get_drvdata(pci_dev); struct net_device *dev = dev_get_drvdata(dev_d);
struct netdev_private *np = netdev_priv(dev); struct netdev_private *np = netdev_priv(dev);
void __iomem *ioaddr = np->base; void __iomem *ioaddr = np->base;
...@@ -1942,30 +1940,24 @@ static int sundance_suspend(struct pci_dev *pci_dev, pm_message_t state) ...@@ -1942,30 +1940,24 @@ static int sundance_suspend(struct pci_dev *pci_dev, pm_message_t state)
netdev_close(dev); netdev_close(dev);
netif_device_detach(dev); netif_device_detach(dev);
pci_save_state(pci_dev);
if (np->wol_enabled) { if (np->wol_enabled) {
iowrite8(AcceptBroadcast | AcceptMyPhys, ioaddr + RxMode); iowrite8(AcceptBroadcast | AcceptMyPhys, ioaddr + RxMode);
iowrite16(RxEnable, ioaddr + MACCtrl1); iowrite16(RxEnable, ioaddr + MACCtrl1);
} }
pci_enable_wake(pci_dev, pci_choose_state(pci_dev, state),
np->wol_enabled); device_set_wakeup_enable(dev_d, np->wol_enabled);
pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state));
return 0; return 0;
} }
static int sundance_resume(struct pci_dev *pci_dev) static int __maybe_unused sundance_resume(struct device *dev_d)
{ {
struct net_device *dev = pci_get_drvdata(pci_dev); struct net_device *dev = dev_get_drvdata(dev_d);
int err = 0; int err = 0;
if (!netif_running(dev)) if (!netif_running(dev))
return 0; return 0;
pci_set_power_state(pci_dev, PCI_D0);
pci_restore_state(pci_dev);
pci_enable_wake(pci_dev, PCI_D0, 0);
err = netdev_open(dev); err = netdev_open(dev);
if (err) { if (err) {
printk(KERN_ERR "%s: Can't resume interface!\n", printk(KERN_ERR "%s: Can't resume interface!\n",
...@@ -1979,17 +1971,14 @@ static int sundance_resume(struct pci_dev *pci_dev) ...@@ -1979,17 +1971,14 @@ static int sundance_resume(struct pci_dev *pci_dev)
return err; return err;
} }
#endif /* CONFIG_PM */ static SIMPLE_DEV_PM_OPS(sundance_pm_ops, sundance_suspend, sundance_resume);
static struct pci_driver sundance_driver = { static struct pci_driver sundance_driver = {
.name = DRV_NAME, .name = DRV_NAME,
.id_table = sundance_pci_tbl, .id_table = sundance_pci_tbl,
.probe = sundance_probe1, .probe = sundance_probe1,
.remove = sundance_remove1, .remove = sundance_remove1,
#ifdef CONFIG_PM .driver.pm = &sundance_pm_ops,
.suspend = sundance_suspend,
.resume = sundance_resume,
#endif /* CONFIG_PM */
}; };
static int __init sundance_init(void) static int __init sundance_init(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