Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

via-rhine: rework suspend and resume.

Cover of 861ab44059350e5cab350238606cf8814abab93b.

Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>

+20 -21
+20 -21
drivers/net/ethernet/via/via-rhine.c
··· 2291 2291 2292 2292 spin_unlock(&rp->lock); 2293 2293 2294 - /* Hit power state D3 (sleep) */ 2295 - if (!avoid_D3) 2294 + if (system_state == SYSTEM_POWER_OFF && !avoid_D3) { 2296 2295 iowrite8(ioread8(ioaddr + StickyHW) | 0x03, ioaddr + StickyHW); 2297 2296 2298 - /* TODO: Check use of pci_enable_wake() */ 2299 - 2297 + pci_wake_from_d3(pdev, true); 2298 + pci_set_power_state(pdev, PCI_D3hot); 2299 + } 2300 2300 } 2301 2301 2302 - #ifdef CONFIG_PM 2303 - static int rhine_suspend(struct pci_dev *pdev, pm_message_t state) 2302 + #ifdef CONFIG_PM_SLEEP 2303 + static int rhine_suspend(struct device *device) 2304 2304 { 2305 + struct pci_dev *pdev = to_pci_dev(device); 2305 2306 struct net_device *dev = pci_get_drvdata(pdev); 2306 2307 struct rhine_private *rp = netdev_priv(dev); 2307 2308 ··· 2314 2313 napi_disable(&rp->napi); 2315 2314 2316 2315 netif_device_detach(dev); 2317 - pci_save_state(pdev); 2318 2316 2319 2317 rhine_shutdown(pdev); 2320 2318 2321 2319 return 0; 2322 2320 } 2323 2321 2324 - static int rhine_resume(struct pci_dev *pdev) 2322 + static int rhine_resume(struct device *device) 2325 2323 { 2324 + struct pci_dev *pdev = to_pci_dev(device); 2326 2325 struct net_device *dev = pci_get_drvdata(pdev); 2327 2326 struct rhine_private *rp = netdev_priv(dev); 2328 - int ret; 2329 2327 2330 2328 if (!netif_running(dev)) 2331 2329 return 0; 2332 - 2333 - ret = pci_set_power_state(pdev, PCI_D0); 2334 - netif_info(rp, drv, dev, "Entering power state D0 %s (%d)\n", 2335 - ret ? "failed" : "succeeded", ret); 2336 - 2337 - pci_restore_state(pdev); 2338 2330 2339 2331 #ifdef USE_MMIO 2340 2332 enable_mmio(rp->pioaddr, rp->quirks); ··· 2346 2352 2347 2353 return 0; 2348 2354 } 2349 - #endif /* CONFIG_PM */ 2355 + 2356 + static SIMPLE_DEV_PM_OPS(rhine_pm_ops, rhine_suspend, rhine_resume); 2357 + #define RHINE_PM_OPS (&rhine_pm_ops) 2358 + 2359 + #else 2360 + 2361 + #define RHINE_PM_OPS NULL 2362 + 2363 + #endif /* !CONFIG_PM_SLEEP */ 2350 2364 2351 2365 static struct pci_driver rhine_driver = { 2352 2366 .name = DRV_NAME, 2353 2367 .id_table = rhine_pci_tbl, 2354 2368 .probe = rhine_init_one, 2355 2369 .remove = __devexit_p(rhine_remove_one), 2356 - #ifdef CONFIG_PM 2357 - .suspend = rhine_suspend, 2358 - .resume = rhine_resume, 2359 - #endif /* CONFIG_PM */ 2360 - .shutdown = rhine_shutdown, 2370 + .shutdown = rhine_shutdown, 2371 + .driver.pm = RHINE_PM_OPS, 2361 2372 }; 2362 2373 2363 2374 static struct dmi_system_id __initdata rhine_dmi_table[] = {