]> err.no Git - linux-2.6/commitdiff
[PATCH] starfire: Implement suspend/resume
authorStefan Rompf <stefan@loplof.de>
Tue, 17 Jan 2006 21:52:51 +0000 (22:52 +0100)
committerJeff Garzik <jgarzik@pobox.com>
Wed, 18 Jan 2006 00:19:12 +0000 (19:19 -0500)
This patch implements suspend and resume methods for the starfire driver. It
allows me to put my desktop PC with a starfire dual board into S4.

Signed-Off-By: Stefan Rompf <stefan@loplof.de>
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
drivers/net/starfire.c

index d167deda9a53a0cb8c05bc375af76105021d3967..ed5458c45446930a8baadc4a63860b5f5f4b8edd 100644 (file)
@@ -2084,6 +2084,38 @@ static int netdev_close(struct net_device *dev)
        return 0;
 }
 
+#ifdef CONFIG_PM
+static int starfire_suspend(struct pci_dev *pdev, pm_message_t state)
+{
+       struct net_device *dev = pci_get_drvdata(pdev);
+
+       if (netif_running(dev)) {
+               netif_device_detach(dev);
+               netdev_close(dev);
+       }
+
+       pci_save_state(pdev);
+       pci_set_power_state(pdev, pci_choose_state(pdev,state));
+
+       return 0;
+}
+
+static int starfire_resume(struct pci_dev *pdev)
+{
+       struct net_device *dev = pci_get_drvdata(pdev);
+       
+       pci_set_power_state(pdev, PCI_D0);
+       pci_restore_state(pdev);
+
+       if (netif_running(dev)) {
+               netdev_open(dev);
+               netif_device_attach(dev);
+       }
+
+       return 0;
+}
+#endif /* CONFIG_PM */
+
 
 static void __devexit starfire_remove_one (struct pci_dev *pdev)
 {
@@ -2115,6 +2147,10 @@ static struct pci_driver starfire_driver = {
        .name           = DRV_NAME,
        .probe          = starfire_init_one,
        .remove         = __devexit_p(starfire_remove_one),
+#ifdef CONFIG_PM
+       .suspend        = starfire_suspend,
+       .resume         = starfire_resume,
+#endif /* CONFIG_PM */
        .id_table       = starfire_pci_tbl,
 };