aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/e1000/e1000_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/e1000/e1000_main.c')
-rw-r--r--drivers/net/e1000/e1000_main.c58
1 files changed, 2 insertions, 56 deletions
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index f293690b8fc2..a71023741c3a 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -5071,58 +5071,6 @@ e1000_set_spd_dplx(struct e1000_adapter *adapter, uint16_t spddplx)
5071 return 0; 5071 return 0;
5072} 5072}
5073 5073
5074#ifdef CONFIG_PM
5075/* Save/restore 16 or 64 dwords of PCI config space depending on which
5076 * bus we're on (PCI(X) vs. PCI-E)
5077 */
5078#define PCIE_CONFIG_SPACE_LEN 256
5079#define PCI_CONFIG_SPACE_LEN 64
5080static int
5081e1000_pci_save_state(struct e1000_adapter *adapter)
5082{
5083 struct pci_dev *dev = adapter->pdev;
5084 int size;
5085 int i;
5086
5087 if (adapter->hw.mac_type >= e1000_82571)
5088 size = PCIE_CONFIG_SPACE_LEN;
5089 else
5090 size = PCI_CONFIG_SPACE_LEN;
5091
5092 WARN_ON(adapter->config_space != NULL);
5093
5094 adapter->config_space = kmalloc(size, GFP_KERNEL);
5095 if (!adapter->config_space) {
5096 DPRINTK(PROBE, ERR, "unable to allocate %d bytes\n", size);
5097 return -ENOMEM;
5098 }
5099 for (i = 0; i < (size / 4); i++)
5100 pci_read_config_dword(dev, i * 4, &adapter->config_space[i]);
5101 return 0;
5102}
5103
5104static void
5105e1000_pci_restore_state(struct e1000_adapter *adapter)
5106{
5107 struct pci_dev *dev = adapter->pdev;
5108 int size;
5109 int i;
5110
5111 if (adapter->config_space == NULL)
5112 return;
5113
5114 if (adapter->hw.mac_type >= e1000_82571)
5115 size = PCIE_CONFIG_SPACE_LEN;
5116 else
5117 size = PCI_CONFIG_SPACE_LEN;
5118 for (i = 0; i < (size / 4); i++)
5119 pci_write_config_dword(dev, i * 4, adapter->config_space[i]);
5120 kfree(adapter->config_space);
5121 adapter->config_space = NULL;
5122 return;
5123}
5124#endif /* CONFIG_PM */
5125
5126static int 5074static int
5127e1000_suspend(struct pci_dev *pdev, pm_message_t state) 5075e1000_suspend(struct pci_dev *pdev, pm_message_t state)
5128{ 5076{
@@ -5142,9 +5090,7 @@ e1000_suspend(struct pci_dev *pdev, pm_message_t state)
5142 } 5090 }
5143 5091
5144#ifdef CONFIG_PM 5092#ifdef CONFIG_PM
5145 /* Implement our own version of pci_save_state(pdev) because pci- 5093 retval = pci_save_state(pdev);
5146 * express adapters have 256-byte config spaces. */
5147 retval = e1000_pci_save_state(adapter);
5148 if (retval) 5094 if (retval)
5149 return retval; 5095 return retval;
5150#endif 5096#endif
@@ -5231,7 +5177,7 @@ e1000_resume(struct pci_dev *pdev)
5231 uint32_t err; 5177 uint32_t err;
5232 5178
5233 pci_set_power_state(pdev, PCI_D0); 5179 pci_set_power_state(pdev, PCI_D0);
5234 e1000_pci_restore_state(adapter); 5180 pci_restore_state(pdev);
5235 if ((err = pci_enable_device(pdev))) { 5181 if ((err = pci_enable_device(pdev))) {
5236 printk(KERN_ERR "e1000: Cannot enable PCI device from suspend\n"); 5182 printk(KERN_ERR "e1000: Cannot enable PCI device from suspend\n");
5237 return err; 5183 return err;