From: Gerald Britton (gbritton_at_doomcom.org)
Date: 2002-06-22 18:07:48 UTC
this patch adds simple pci suspend/resume support to hostap_pci. It seems to
work for me, basically resetting the card following a resume. It could
probably use a few more #ifdefs for the pci features vs. kernel version. It
does things a little differently if the interface is up, but I think i've got
it right. I generally ifdown wlan0 on suspend, so i don't normally hit this,
but i tested it once and it seemed to work.
diff -ruN hostap.orig/driver/modules/hostap_pci.c hostap/driver/modules/hostap_pci.c
--- hostap.orig/driver/modules/hostap_pci.c Fri Jun 7 12:09:56 2002@@ -221,6 +221,37 @@
+++ hostap/driver/modules/hostap_pci.c Sat Jun 15 13:21:39 2002
+static int prism2_pci_suspend(struct pci_dev *pdev, u32 state)
+{
+ struct net_device *dev = pci_get_drvdata(pdev);
+ local_info_t *local = (local_info_t *) dev->priv;
+
+ if (netif_running(dev)) {
+ prism2_netif_stop_queues(dev);
+ netif_device_detach(dev);
+ }
+ pci_save_state(pdev, local->pci_save_state);
+ pci_disable_device(pdev);
+ pci_set_power_state(pdev, 3);
+
+ return 0;
+}
+
+static int prism2_pci_resume(struct pci_dev *pdev)
+{
+ struct net_device *dev = pci_get_drvdata(pdev);
+ local_info_t *local = (local_info_t *) dev->priv;
+
+ pci_enable_device(pdev);
+ pci_restore_state(pdev, local->pci_save_state);
+ prism2_hw_reset(dev);
+ if (netif_running(dev)) {
+ netif_device_attach(dev);
+ netif_start_queue(dev);
+ }
+
+ return 0;
+}
MODULE_DEVICE_TABLE(pci, prism2_pci_id_table);
@@ -229,14 +260,11 @@
id_table: prism2_pci_id_table, probe: prism2_pci_probe, remove: prism2_pci_remove,
+ suspend: prism2_pci_suspend,
+ resume: prism2_pci_resume,
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,6)) save_state: NULL, - suspend: NULL, - resume: NULL, - enable_wake: NULL -#else /* Linux < 2.4.6 */ - suspend: NULL, - resume: NULL
+ enable_wake: NULL,
diff -ruN hostap.orig/driver/modules/prism2_wlan.h hostap/driver/modules/prism2_wlan.h
--- hostap.orig/driver/modules/prism2_wlan.h Fri Jun 14 13:00:07 2002@@ -923,7 +923,9 @@
+++ hostap/driver/modules/prism2_wlan.h Sat Jun 15 12:59:05 2002
struct prism2_helper_functions *func;
-#if defined(PRISM2_PCI) && defined(PRISM2_BUS_MASTER)
+#if defined(PRISM2_PCI)
+ u32 pci_save_state[64/sizeof(u32)];
+#if defined(PRISM2_BUS_MASTER)
/* bus master for BAP0 (TX) */ int bus_master_threshold_tx; int bus_m0_tx_idx; @@ -934,7 +936,8 @@ /* bus master for BAP1 (RX) */ int bus_master_threshold_rx; int bus_m1_in_use; -#endif /* PRISM2_PCI and PRISM2_BUS_MASTER */
u8 *bus_m1_buf; prism2_wds_info_t *rx_wds; struct hfa384x_rx_frame rxdesc;