Skip to contentSkip to conversation

: Suspend2 Merge: Device driver fixes 1/2

PATCH In review Nigel Cunningham 3 participants 3 messages Sep 16, 2004 – Sep 17, 2004 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : Suspend2 Merge: Device driver fixes 1/2

-----Forwarded Message-----

Quoted 18 lines

From: Éric Brunet <[email protected]>
To: Paul Gortmaker <[email protected]>
Cc: [email protected], [email protected]
Subject: PATCH swsuspend for ne2k-pci cards
Date: Sat, 21 Aug 2004 14:14:30 +0200

Hi,

Arkadiusz Miskiewicz had some suggestions to improve my patch which adds suspend/resume support to ne2k-pci.c. Actually, he basically rewrote it.

This patch was only tested on my own ne2k clone [Realtek Semiconductor Co., Ltd. RTL-8029(AS)], and it works nicely for me. As 1) it cannot hurt people which are not using swsuspend 2) it can only improve things for people using swsuspend, it would be nice if this patch could go into the kernel.

Quoted 3 lines

Thank you,

Éric Brunet

drivers/net/ne2k-pci.c +31 -1
diff -ruN linux-2.6.9-rc1/drivers/net/ne2k-pci.c software-suspend-linux-2.6.9-rc1-rev3/drivers/net/ne2k-pci.c
@@ -653,12 +653,43 @@
 	pci_set_drvdata(pdev, NULL);
 }
 
+#ifdef CONFIG_PM
+static int ne2k_pci_suspend (struct pci_dev *pdev, u32 state)
+{
+	struct net_device *dev = pci_get_drvdata (pdev);
+
+	netif_device_detach(dev);
+	pci_save_state(pdev, pdev->saved_config_space);
+	pci_set_power_state(pdev, state);
+
+	return 0;
+}
+
+static int ne2k_pci_resume (struct pci_dev *pdev)
+{
+	struct net_device *dev = pci_get_drvdata (pdev);
+
+	pci_set_power_state(pdev, 0);
+	pci_restore_state(pdev, pdev->saved_config_space);
+	NS8390_init(dev, 1);
+	netif_device_attach(dev);
+
+	return 0;
+}
+
+#endif /* CONFIG_PM */
+
 
 static struct pci_driver ne2k_driver = {
 	.name		= DRV_NAME,
 	.probe		= ne2k_pci_init_one,
 	.remove		= __devexit_p(ne2k_pci_remove_one),
 	.id_table	= ne2k_pci_tbl,
+#ifdef CONFIG_PM
+	.suspend	= ne2k_pci_suspend,
+	.resume		= ne2k_pci_resume,
+#endif /* CONFIG_PM */
+
 };
 
-- 

Nigel Cunningham
Pastoral Worker
Christian Reformed Church of Tuggeranong
PO Box 1004, Tuggeranong, ACT 2901

Many today claim to be tolerant. True tolerance, however, can cope with others being intolerant.

#1 lore raw

Well I kept trying to push this patch to Paul Gortmaker (maintainer of the n2kpci driver), but to no avail. I guess I won't have to any more.

Éric Brunet

Quoted 84 lines

-----Forwarded Message-----

Quoted 18 lines

From: Éric Brunet <[email protected]>
To: Paul Gortmaker <[email protected]>
Cc: [email protected], [email protected]
Subject: PATCH swsuspend for ne2k-pci cards
Date: Sat, 21 Aug 2004 14:14:30 +0200

Hi,

Arkadiusz Miskiewicz had some suggestions to improve my patch which adds suspend/resume support to ne2k-pci.c. Actually, he basically rewrote it.

This patch was only tested on my own ne2k clone [Realtek Semiconductor Co., Ltd. RTL-8029(AS)], and it works nicely for me. As 1) it cannot hurt people which are not using swsuspend 2) it can only improve things for people using swsuspend, it would be nice if this patch could go into the kernel.

Quoted 3 lines

Thank you,

Éric Brunet

diff -ruN linux-2.6.9-rc1/drivers/net/ne2k-pci.c software-suspend-linux-2.6.9-rc1-rev3/drivers/net/ne2k-pci.c

drivers/net/ne2k-pci.c +31 -1
@@ -653,12 +653,43 @@
 	pci_set_drvdata(pdev, NULL);
 }
 
+#ifdef CONFIG_PM
+static int ne2k_pci_suspend (struct pci_dev *pdev, u32 state)
+{
+	struct net_device *dev = pci_get_drvdata (pdev);
+
+	netif_device_detach(dev);
+	pci_save_state(pdev, pdev->saved_config_space);
+	pci_set_power_state(pdev, state);
+
+	return 0;
+}
+
+static int ne2k_pci_resume (struct pci_dev *pdev)
+{
+	struct net_device *dev = pci_get_drvdata (pdev);
+
+	pci_set_power_state(pdev, 0);
+	pci_restore_state(pdev, pdev->saved_config_space);
+	NS8390_init(dev, 1);
+	netif_device_attach(dev);
+
+	return 0;
+}
+
+#endif /* CONFIG_PM */
+
 
 static struct pci_driver ne2k_driver = {
 	.name		= DRV_NAME,
 	.probe		= ne2k_pci_init_one,
 	.remove		= __devexit_p(ne2k_pci_remove_one),
 	.id_table	= ne2k_pci_tbl,
+#ifdef CONFIG_PM
+	.suspend	= ne2k_pci_suspend,
+	.resume		= ne2k_pci_resume,
+#endif /* CONFIG_PM */
+
 };
 
-- 

Nigel Cunningham
Pastoral Worker
Christian Reformed Church of Tuggeranong
PO Box 1004, Tuggeranong, ACT 2901

Many today claim to be tolerant. True tolerance, however, can cope with others being intolerant.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/