summaryrefslogtreecommitdiff
path: root/drivers/net/sundance.c
diff options
context:
space:
mode:
authorDenis Kirjanov <dkirjanov@kernel.org>2010-09-11 03:23:13 +0400
committerDavid S. Miller <davem@davemloft.net>2010-09-14 07:02:50 +0400
commit61a21455ee27dccdd286f61aea611da5e70b47bf (patch)
tree252a299206b91d0dee1b4d81e9e788bf51f66278 /drivers/net/sundance.c
parent83b6b1f5d13414d0cb5c4f0a567a6aec0af073bd (diff)
downloadlinux-61a21455ee27dccdd286f61aea611da5e70b47bf.tar.xz
sundance: Add power management hooks
This patch to adds support for PM hooks into sundance driver Signed-off-by: Denis Kirjanov <dkirjanov@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/sundance.c')
-rw-r--r--drivers/net/sundance.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/drivers/net/sundance.c b/drivers/net/sundance.c
index 3fa949789b42..7dfdbee878e8 100644
--- a/drivers/net/sundance.c
+++ b/drivers/net/sundance.c
@@ -1757,11 +1757,59 @@ static void __devexit sundance_remove1 (struct pci_dev *pdev)
}
}
+#ifdef CONFIG_PM
+
+static int sundance_suspend(struct pci_dev *pci_dev, pm_message_t state)
+{
+ struct net_device *dev = pci_get_drvdata(pci_dev);
+
+ if (!netif_running(dev))
+ return 0;
+
+ netdev_close(dev);
+ netif_device_detach(dev);
+
+ pci_save_state(pci_dev);
+ pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state));
+
+ return 0;
+}
+
+static int sundance_resume(struct pci_dev *pci_dev)
+{
+ struct net_device *dev = pci_get_drvdata(pci_dev);
+ int err = 0;
+
+ if (!netif_running(dev))
+ return 0;
+
+ pci_set_power_state(pci_dev, PCI_D0);
+ pci_restore_state(pci_dev);
+
+ err = netdev_open(dev);
+ if (err) {
+ printk(KERN_ERR "%s: Can't resume interface!\n",
+ dev->name);
+ goto out;
+ }
+
+ netif_device_attach(dev);
+
+out:
+ return err;
+}
+
+#endif /* CONFIG_PM */
+
static struct pci_driver sundance_driver = {
.name = DRV_NAME,
.id_table = sundance_pci_tbl,
.probe = sundance_probe1,
.remove = __devexit_p(sundance_remove1),
+#ifdef CONFIG_PM
+ .suspend = sundance_suspend,
+ .resume = sundance_resume,
+#endif /* CONFIG_PM */
};
static int __init sundance_init(void)