diff options
author | Francois Romieu <romieu@fr.zoreil.com> | 2012-01-07 16:58:27 -0500 |
---|---|---|
committer | Francois Romieu <romieu@fr.zoreil.com> | 2012-01-07 17:02:38 -0500 |
commit | e92b9b3b091d5fcdaed91d6fa9410deae135704b (patch) | |
tree | 0f4baaefba74f6b41f302d16555c9894c0923e8f /drivers/net/ethernet | |
parent | fc3e0f8aec05dd812cba2c1e31c3d1f5fc85e55c (diff) |
via-rhine: rework suspend and resume.
Cover of 861ab44059350e5cab350238606cf8814abab93b.
Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r-- | drivers/net/ethernet/via/via-rhine.c | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/drivers/net/ethernet/via/via-rhine.c b/drivers/net/ethernet/via/via-rhine.c index e39802f37b21..10b18eb63d25 100644 --- a/drivers/net/ethernet/via/via-rhine.c +++ b/drivers/net/ethernet/via/via-rhine.c | |||
@@ -2291,17 +2291,18 @@ static void rhine_shutdown (struct pci_dev *pdev) | |||
2291 | 2291 | ||
2292 | spin_unlock(&rp->lock); | 2292 | spin_unlock(&rp->lock); |
2293 | 2293 | ||
2294 | /* Hit power state D3 (sleep) */ | 2294 | if (system_state == SYSTEM_POWER_OFF && !avoid_D3) { |
2295 | if (!avoid_D3) | ||
2296 | iowrite8(ioread8(ioaddr + StickyHW) | 0x03, ioaddr + StickyHW); | 2295 | iowrite8(ioread8(ioaddr + StickyHW) | 0x03, ioaddr + StickyHW); |
2297 | 2296 | ||
2298 | /* TODO: Check use of pci_enable_wake() */ | 2297 | pci_wake_from_d3(pdev, true); |
2299 | 2298 | pci_set_power_state(pdev, PCI_D3hot); | |
2299 | } | ||
2300 | } | 2300 | } |
2301 | 2301 | ||
2302 | #ifdef CONFIG_PM | 2302 | #ifdef CONFIG_PM_SLEEP |
2303 | static int rhine_suspend(struct pci_dev *pdev, pm_message_t state) | 2303 | static int rhine_suspend(struct device *device) |
2304 | { | 2304 | { |
2305 | struct pci_dev *pdev = to_pci_dev(device); | ||
2305 | struct net_device *dev = pci_get_drvdata(pdev); | 2306 | struct net_device *dev = pci_get_drvdata(pdev); |
2306 | struct rhine_private *rp = netdev_priv(dev); | 2307 | struct rhine_private *rp = netdev_priv(dev); |
2307 | 2308 | ||
@@ -2313,28 +2314,21 @@ static int rhine_suspend(struct pci_dev *pdev, pm_message_t state) | |||
2313 | napi_disable(&rp->napi); | 2314 | napi_disable(&rp->napi); |
2314 | 2315 | ||
2315 | netif_device_detach(dev); | 2316 | netif_device_detach(dev); |
2316 | pci_save_state(pdev); | ||
2317 | 2317 | ||
2318 | rhine_shutdown(pdev); | 2318 | rhine_shutdown(pdev); |
2319 | 2319 | ||
2320 | return 0; | 2320 | return 0; |
2321 | } | 2321 | } |
2322 | 2322 | ||
2323 | static int rhine_resume(struct pci_dev *pdev) | 2323 | static int rhine_resume(struct device *device) |
2324 | { | 2324 | { |
2325 | struct pci_dev *pdev = to_pci_dev(device); | ||
2325 | struct net_device *dev = pci_get_drvdata(pdev); | 2326 | struct net_device *dev = pci_get_drvdata(pdev); |
2326 | struct rhine_private *rp = netdev_priv(dev); | 2327 | struct rhine_private *rp = netdev_priv(dev); |
2327 | int ret; | ||
2328 | 2328 | ||
2329 | if (!netif_running(dev)) | 2329 | if (!netif_running(dev)) |
2330 | return 0; | 2330 | return 0; |
2331 | 2331 | ||
2332 | ret = pci_set_power_state(pdev, PCI_D0); | ||
2333 | netif_info(rp, drv, dev, "Entering power state D0 %s (%d)\n", | ||
2334 | ret ? "failed" : "succeeded", ret); | ||
2335 | |||
2336 | pci_restore_state(pdev); | ||
2337 | |||
2338 | #ifdef USE_MMIO | 2332 | #ifdef USE_MMIO |
2339 | enable_mmio(rp->pioaddr, rp->quirks); | 2333 | enable_mmio(rp->pioaddr, rp->quirks); |
2340 | #endif | 2334 | #endif |
@@ -2352,18 +2346,23 @@ static int rhine_resume(struct pci_dev *pdev) | |||
2352 | 2346 | ||
2353 | return 0; | 2347 | return 0; |
2354 | } | 2348 | } |
2355 | #endif /* CONFIG_PM */ | 2349 | |
2350 | static SIMPLE_DEV_PM_OPS(rhine_pm_ops, rhine_suspend, rhine_resume); | ||
2351 | #define RHINE_PM_OPS (&rhine_pm_ops) | ||
2352 | |||
2353 | #else | ||
2354 | |||
2355 | #define RHINE_PM_OPS NULL | ||
2356 | |||
2357 | #endif /* !CONFIG_PM_SLEEP */ | ||
2356 | 2358 | ||
2357 | static struct pci_driver rhine_driver = { | 2359 | static struct pci_driver rhine_driver = { |
2358 | .name = DRV_NAME, | 2360 | .name = DRV_NAME, |
2359 | .id_table = rhine_pci_tbl, | 2361 | .id_table = rhine_pci_tbl, |
2360 | .probe = rhine_init_one, | 2362 | .probe = rhine_init_one, |
2361 | .remove = __devexit_p(rhine_remove_one), | 2363 | .remove = __devexit_p(rhine_remove_one), |
2362 | #ifdef CONFIG_PM | 2364 | .shutdown = rhine_shutdown, |
2363 | .suspend = rhine_suspend, | 2365 | .driver.pm = RHINE_PM_OPS, |
2364 | .resume = rhine_resume, | ||
2365 | #endif /* CONFIG_PM */ | ||
2366 | .shutdown = rhine_shutdown, | ||
2367 | }; | 2366 | }; |
2368 | 2367 | ||
2369 | static struct dmi_system_id __initdata rhine_dmi_table[] = { | 2368 | static struct dmi_system_id __initdata rhine_dmi_table[] = { |