[PATCH] pcmcia: new suspend core
[deliverable/linux.git] / drivers / net / wireless / wavelan_cs.c
index 183c4732ef65ca0eb24e99c79d1b43197a3f8930..3e3532830c26493d0be142c693d744236e4a2ef1 100644 (file)
@@ -415,7 +415,6 @@ fee_read(u_long             base,   /* i/o port of the card */
     }
 }
 
-#ifdef WIRELESS_EXT    /* If wireless extension exist in the kernel */
 
 /*------------------------------------------------------------------*/
 /*
@@ -500,7 +499,6 @@ fee_write(u_long    base,   /* i/o port of the card */
   fee_wait(base, 10, 100);
 #endif /* EEPROM_IS_PROTECTED */
 }
-#endif /* WIRELESS_EXT */
 
 /******************* WaveLAN Roaming routines... ********************/
 
@@ -1161,10 +1159,8 @@ wv_mmc_show(struct net_device *  dev)
   mmc_read(base, 0, (u_char *)&m, sizeof(m));
   mmc_out(base, mmwoff(0, mmw_freeze), 0);
 
-#ifdef WIRELESS_EXT    /* If wireless extension exist in the kernel */
   /* Don't forget to update statistics */
   lp->wstats.discard.nwid += (m.mmr_wrong_nwid_h << 8) | m.mmr_wrong_nwid_l;
-#endif /* WIRELESS_EXT */
 
   spin_unlock_irqrestore(&lp->spinlock, flags);
 
@@ -1550,7 +1546,6 @@ wavelan_set_mac_address(struct net_device *       dev,
 }
 #endif /* SET_MAC_ADDRESS */
 
-#ifdef WIRELESS_EXT    /* If wireless extension exist in the kernel */
 
 /*------------------------------------------------------------------*/
 /*
@@ -2793,7 +2788,6 @@ wavelan_get_wireless_stats(struct net_device *    dev)
 #endif
   return &lp->wstats;
 }
-#endif /* WIRELESS_EXT */
 
 /************************* PACKET RECEPTION *************************/
 /*
@@ -4614,9 +4608,8 @@ wavelan_attach(void)
 #endif
 
   /* Initialize the dev_link_t structure */
-  link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL);
+  link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL);
   if (!link) return NULL;
-  memset(link, 0, sizeof(struct dev_link_t));
 
   /* The io structure describes IO port mapping */
   link->io.NumPorts1 = 8;
@@ -4679,11 +4672,9 @@ wavelan_attach(void)
   dev->watchdog_timeo  = WATCHDOG_JIFFIES;
   SET_ETHTOOL_OPS(dev, &ops);
 
-#ifdef WIRELESS_EXT    /* If wireless extension exist in the kernel */
   dev->wireless_handlers = &wavelan_handler_def;
   lp->wireless_data.spy_data = &lp->spy_data;
   dev->wireless_data = &lp->wireless_data;
-#endif
 
   /* Other specific data */
   dev->mtu = WAVELAN_MTU;
@@ -4784,6 +4775,56 @@ wavelan_detach(dev_link_t *      link)
 #endif
 }
 
+static int wavelan_suspend(struct pcmcia_device *p_dev)
+{
+       dev_link_t *link = dev_to_instance(p_dev);
+       struct net_device *     dev = (struct net_device *) link->priv;
+
+       /* NB: wavelan_close will be called, but too late, so we are
+        * obliged to close nicely the wavelan here. David, could you
+        * close the device before suspending them ? And, by the way,
+        * could you, on resume, add a "route add -net ..." after the
+        * ifconfig up ? Thanks... */
+
+       /* Stop receiving new messages and wait end of transmission */
+       wv_ru_stop(dev);
+
+       /* Power down the module */
+       hacr_write(dev->base_addr, HACR_DEFAULT & (~HACR_PWR_STAT));
+
+       /* The card is now suspended */
+       link->state |= DEV_SUSPEND;
+
+       if(link->state & DEV_CONFIG)
+       {
+               if(link->open)
+                       netif_device_detach(dev);
+               pcmcia_release_configuration(link->handle);
+       }
+
+       return 0;
+}
+
+static int wavelan_resume(struct pcmcia_device *p_dev)
+{
+       dev_link_t *link = dev_to_instance(p_dev);
+       struct net_device *     dev = (struct net_device *) link->priv;
+
+       link->state &= ~DEV_SUSPEND;
+       if(link->state & DEV_CONFIG)
+       {
+               pcmcia_request_configuration(link->handle, &link->conf);
+               if(link->open)  /* If RESET -> True, If RESUME -> False ? */
+               {
+                       wv_hw_reset(dev);
+                       netif_device_attach(dev);
+               }
+       }
+
+       return 0;
+}
+
+
 /*------------------------------------------------------------------*/
 /*
  * The card status event handler. Mostly, this schedules other stuff
@@ -4841,46 +4882,6 @@ wavelan_event(event_t            event,          /* The event received */
        else
          dev->irq = 0;
        break;
-
-      case CS_EVENT_PM_SUSPEND:
-       /* NB: wavelan_close will be called, but too late, so we are
-        * obliged to close nicely the wavelan here. David, could you
-        * close the device before suspending them ? And, by the way,
-        * could you, on resume, add a "route add -net ..." after the
-        * ifconfig up ? Thanks... */
-
-       /* Stop receiving new messages and wait end of transmission */
-       wv_ru_stop(dev);
-
-       /* Power down the module */
-       hacr_write(dev->base_addr, HACR_DEFAULT & (~HACR_PWR_STAT));
-
-       /* The card is now suspended */
-       link->state |= DEV_SUSPEND;
-       /* Fall through... */
-      case CS_EVENT_RESET_PHYSICAL:
-       if(link->state & DEV_CONFIG)
-         {
-           if(link->open)
-             netif_device_detach(dev);
-           pcmcia_release_configuration(link->handle);
-         }
-       break;
-
-      case CS_EVENT_PM_RESUME:
-       link->state &= ~DEV_SUSPEND;
-       /* Fall through... */
-      case CS_EVENT_CARD_RESET:
-       if(link->state & DEV_CONFIG)
-         {
-           pcmcia_request_configuration(link->handle, &link->conf);
-           if(link->open)      /* If RESET -> True, If RESUME -> False ? */
-             {
-               wv_hw_reset(dev);
-               netif_device_attach(dev);
-             }
-         }
-       break;
     }
 
 #ifdef DEBUG_CALLBACK_TRACE
@@ -4907,6 +4908,8 @@ static struct pcmcia_driver wavelan_driver = {
        .event          = wavelan_event,
        .detach         = wavelan_detach,
        .id_table       = wavelan_ids,
+       .suspend        = wavelan_suspend,
+       .resume         = wavelan_resume,
 };
 
 static int __init
This page took 0.034396 seconds and 5 git commands to generate.