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

pcnet32: Convert to generic power management

Remove legacy PM callbacks and use generic operations. With legacy code,
drivers were responsible for handling PCI PM operations like
pci_save_state(). In generic code, all these are handled by PCI core.

The generic suspend() and resume() are called at the same point the legacy
ones were called. Thus, it does not affect the normal functioning of the
driver.

Compile-tested only.
Signed-off-by: default avatarVaibhav Gupta <vaibhavgupta40@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f9215d6b
...@@ -2913,30 +2913,27 @@ static void pcnet32_watchdog(struct timer_list *t) ...@@ -2913,30 +2913,27 @@ static void pcnet32_watchdog(struct timer_list *t)
mod_timer(&lp->watchdog_timer, round_jiffies(PCNET32_WATCHDOG_TIMEOUT)); mod_timer(&lp->watchdog_timer, round_jiffies(PCNET32_WATCHDOG_TIMEOUT));
} }
static int pcnet32_pm_suspend(struct pci_dev *pdev, pm_message_t state) static int pcnet32_pm_suspend(struct device *device_d)
{ {
struct net_device *dev = pci_get_drvdata(pdev); struct net_device *dev = dev_get_drvdata(device_d);
if (netif_running(dev)) { if (netif_running(dev)) {
netif_device_detach(dev); netif_device_detach(dev);
pcnet32_close(dev); pcnet32_close(dev);
} }
pci_save_state(pdev);
pci_set_power_state(pdev, pci_choose_state(pdev, state));
return 0; return 0;
} }
static int pcnet32_pm_resume(struct pci_dev *pdev) static int pcnet32_pm_resume(struct device *device_d)
{ {
struct net_device *dev = pci_get_drvdata(pdev); struct net_device *dev = dev_get_drvdata(device_d);
pci_set_power_state(pdev, PCI_D0);
pci_restore_state(pdev);
if (netif_running(dev)) { if (netif_running(dev)) {
pcnet32_open(dev); pcnet32_open(dev);
netif_device_attach(dev); netif_device_attach(dev);
} }
return 0; return 0;
} }
...@@ -2957,13 +2954,16 @@ static void pcnet32_remove_one(struct pci_dev *pdev) ...@@ -2957,13 +2954,16 @@ static void pcnet32_remove_one(struct pci_dev *pdev)
} }
} }
static SIMPLE_DEV_PM_OPS(pcnet32_pm_ops, pcnet32_pm_suspend, pcnet32_pm_resume);
static struct pci_driver pcnet32_driver = { static struct pci_driver pcnet32_driver = {
.name = DRV_NAME, .name = DRV_NAME,
.probe = pcnet32_probe_pci, .probe = pcnet32_probe_pci,
.remove = pcnet32_remove_one, .remove = pcnet32_remove_one,
.id_table = pcnet32_pci_tbl, .id_table = pcnet32_pci_tbl,
.suspend = pcnet32_pm_suspend, .driver = {
.resume = pcnet32_pm_resume, .pm = &pcnet32_pm_ops,
},
}; };
/* An additional parameter that may be passed in... */ /* An additional parameter that may be passed in... */
......
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