diff options
author | Auke Kok <auke\-jan.h.kok@intel.com> | 2006-09-27 12:53:25 -0700 |
---|---|---|
committer | Auke Kok <juke-jan.h.kok@intel.com> | 2006-09-27 12:53:25 -0700 |
commit | 975b366af66280ed5b852a1a0446586ce71e306e (patch) | |
tree | 92a0875940d74b235e2a2132f3fa8394ab75d747 /drivers/net/e100.c | |
parent | dc45010e28bc4a1bfa6043eee31d1c59e93e1546 (diff) | |
download | op-kernel-dev-975b366af66280ed5b852a1a0446586ce71e306e.zip op-kernel-dev-975b366af66280ed5b852a1a0446586ce71e306e.tar.gz |
e100: rework WoL and shutdown handling
Unify our shutdown/suspend/resume code and make it similar to e1000:
e1000_shutdown now calls suspend which does the exact same thing on
shutdown except saving PCI config state on suspend. WoL setup code
is now also more simple and works even when CONFIG_PM is not set, which
was previously broken.
Signed-off-by: Auke Kok <auke-jan.h.kok@intel.com>
Diffstat (limited to 'drivers/net/e100.c')
-rw-r--r-- | drivers/net/e100.c | 51 |
1 files changed, 20 insertions, 31 deletions
diff --git a/drivers/net/e100.c b/drivers/net/e100.c index 3909829..e9e7124 100644 --- a/drivers/net/e100.c +++ b/drivers/net/e100.c @@ -2715,68 +2715,56 @@ static void __devexit e100_remove(struct pci_dev *pdev) } } -#ifdef CONFIG_PM static int e100_suspend(struct pci_dev *pdev, pm_message_t state) { struct net_device *netdev = pci_get_drvdata(pdev); struct nic *nic = netdev_priv(netdev); - int retval; - if(netif_running(netdev)) + if (netif_running(netdev)) e100_down(nic); e100_hw_reset(nic); netif_device_detach(netdev); +#ifdef CONFIG_PM pci_save_state(pdev); - retval = pci_enable_wake(pdev, pci_choose_state(pdev, state), - nic->flags & (wol_magic | e100_asf(nic))); - if (retval) - DPRINTK(PROBE,ERR, "Error enabling wake\n"); + if (nic->flags & (wol_magic | e100_asf(nic))) +#else + if (nic->flags & (wol_magic)) +#endif + pci_enable_wake(pdev, pci_choose_state(pdev, state), 1); + else + /* disable PME */ + pci_enable_wake(pdev, 0, 0); + pci_disable_device(pdev); - retval = pci_set_power_state(pdev, pci_choose_state(pdev, state)); - if (retval) - DPRINTK(PROBE,ERR, "Error %d setting power state\n", retval); + pci_set_power_state(pdev, pci_choose_state(pdev, state)); return 0; } +#ifdef CONFIG_PM static int e100_resume(struct pci_dev *pdev) { struct net_device *netdev = pci_get_drvdata(pdev); struct nic *nic = netdev_priv(netdev); - int retval; - retval = pci_set_power_state(pdev, PCI_D0); - if (retval) - DPRINTK(PROBE,ERR, "Error waking adapter\n"); + pci_set_power_state(pdev, PCI_D0); pci_restore_state(pdev); /* ack any pending wake events, disable PME */ - retval = pci_enable_wake(pdev, 0, 0); - if (retval) - DPRINTK(PROBE,ERR, "Error clearing wake events\n"); + pci_enable_wake(pdev, 0, 0); netif_device_attach(netdev); - if(netif_running(netdev)) + if (netif_running(netdev)) e100_up(nic); return 0; } -#endif +#endif /* CONFIG_PM */ static void e100_shutdown(struct pci_dev *pdev) { - struct net_device *netdev = pci_get_drvdata(pdev); - struct nic *nic = netdev_priv(netdev); - int retval; - -#ifdef CONFIG_PM - retval = pci_enable_wake(pdev, 0, nic->flags & (wol_magic | e100_asf(nic))); -#else - retval = pci_enable_wake(pdev, 0, nic->flags & (wol_magic)); -#endif - if (retval) - DPRINTK(PROBE,ERR, "Error enabling wake\n"); + e100_suspend(pdev, PMSG_SUSPEND); } /* ------------------ PCI Error Recovery infrastructure -------------- */ @@ -2860,8 +2848,9 @@ static struct pci_driver e100_driver = { .id_table = e100_id_table, .probe = e100_probe, .remove = __devexit_p(e100_remove), -#ifdef CONFIG_PM + /* Power Management hooks */ .suspend = e100_suspend, +#ifdef CONFIG_PM .resume = e100_resume, #endif .shutdown = e100_shutdown, |