patch-2.3.43 linux/drivers/net/irda/toshoboe.c

Next file: linux/drivers/net/loopback.c
Previous file: linux/drivers/net/irda/smc-ircc.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.42/linux/drivers/net/irda/toshoboe.c linux/drivers/net/irda/toshoboe.c
@@ -56,7 +56,6 @@
 /* No user servicable parts below here */
 
 #include <linux/module.h>
-#include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/skbuff.h>
@@ -77,9 +76,8 @@
 #include <net/irda/irlap_frame.h>
 #include <net/irda/irda_device.h>
 
-#ifdef CONFIG_APM
-#include <linux/apm_bios.h>
-#endif
+#include <linux/pm.h>
+static int toshoboe_pmproc (struct pm_dev *dev, pm_request_t rqst, void *data);
 
 #include <net/irda/toshoboe.h>
 
@@ -690,6 +688,7 @@
 {
   struct toshoboe_cb *self;
   struct net_device *dev;
+  struct pm_dev *pmdev;
   int i = 0;
   int ok = 0;
   int err;
@@ -858,6 +857,10 @@
 	  return -1;
   }
 
+  pmdev = pm_register (PM_PCI_DEV, PM_PCI_ID(pci_dev), toshoboe_pmproc);
+  if (pmdev)
+	  pmdev->data = self;
+
   printk (KERN_WARNING "ToshOboe: Using ");
 #ifdef ONETASK
   printk ("single");
@@ -869,7 +872,6 @@
   return (0);
 }
 
-#ifdef CONFIG_APM
 static void 
 toshoboe_gotosleep (struct toshoboe_cb *self)
 {
@@ -935,52 +937,23 @@
 }
 
 static int 
-toshoboe_apmproc (apm_event_t event)
+toshoboe_pmproc (struct pm_dev *dev, pm_request_t rqst, void *data)
 {
-  static int down = 0;          /*Filter out double events */
-  int i;
-
-  switch (event)
-    {
-    case APM_SYS_SUSPEND:
-    case APM_USER_SUSPEND:
-      if (!down)
-        {
-
-          for (i = 0; i < 4; i++)
-            {
-              if (dev_self[i])
-                toshoboe_gotosleep (dev_self[i]);
-            }
-
-        }
-      down = 1;
-      break;
-    case APM_NORMAL_RESUME:
-    case APM_CRITICAL_RESUME:
-      if (down)
-        {
-
-
-
-          for (i = 0; i < 4; i++)
-            {
-              if (dev_self[i])
-                toshoboe_wakeup (dev_self[i]);
-            }
-
-
-
-        }
-      down = 0;
-      break;
-    }
+  struct toshoboe_cb *self = (struct toshoboe_cb *) dev->data;
+  if (self) {
+	  switch (rqst) {
+	  case PM_SUSPEND:
+		  toshoboe_gotosleep (self);
+		  break;
+	  case PM_RESUME:
+		  toshoboe_wakeup (self);
+		  break;
+	  }
+  }
   return 0;
 }
 
 
-#endif
-
 int __init toshoboe_init (void)
 {
   struct pci_dev *pci_dev = NULL;
@@ -997,7 +970,7 @@
                   pci_dev->irq);
 
           if (!toshoboe_open (pci_dev))
-            found++;
+	      found++;
         }
 
     }
@@ -1006,9 +979,6 @@
 
   if (found)
     {
-#ifdef CONFIG_APM
-      apm_register_callback (toshoboe_apmproc);
-#endif
       return 0;
     }
 
@@ -1030,10 +1000,7 @@
         toshoboe_close (dev_self[i]);
     }
 
-#ifdef CONFIG_APM
-  apm_unregister_callback (toshoboe_apmproc);
-#endif
-
+  pm_unregister_all (toshoboe_pmproc);
 }
 
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)