]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - net/ieee80211/softmac/ieee80211softmac_event.c
WorkStruct: make allyesconfig
[net-next-2.6.git] / net / ieee80211 / softmac / ieee80211softmac_event.c
index 8cc8f3f0f8e73d3809556a6cb30c3c8cf588c111..b9015656cfb3835e5e2966c457d0d9269ebb17f7 100644 (file)
@@ -38,7 +38,8 @@
  * The event context is private and can only be used from
  * within this module. Its meaning varies with the event
  * type:
- *  SCAN_FINISHED:     no special meaning
+ *  SCAN_FINISHED,
+ *  DISASSOCIATED:     NULL
  *  ASSOCIATED,
  *  ASSOCIATE_FAILED,
  *  ASSOCIATE_TIMEOUT,
  */
 
 static char *event_descriptions[IEEE80211SOFTMAC_EVENT_LAST+1] = {
-       "scan finished",
-       "associated",
+       NULL, /* scan finished */
+       NULL, /* associated */
        "associating failed",
        "associating timed out",
        "authenticated",
        "authenticating failed",
        "authenticating timed out",
        "associating failed because no suitable network was found",
-       "disassociated",
+       NULL, /* disassociated */
 };
 
 
 static void
-ieee80211softmac_notify_callback(void *d)
+ieee80211softmac_notify_callback(struct work_struct *work)
 {
-       struct ieee80211softmac_event event = *(struct ieee80211softmac_event*) d;
-       kfree(d);
+       struct ieee80211softmac_event *pevent =
+               container_of(work, struct ieee80211softmac_event, work.work);
+       struct ieee80211softmac_event event = *pevent;
+       kfree(pevent);
        
-       event.fun(event.mac->dev, event.context);
+       event.fun(event.mac->dev, event.event_type, event.context);
 }
 
 int
@@ -98,7 +101,7 @@ ieee80211softmac_notify_internal(struct ieee80211softmac_device *mac,
                return -ENOMEM;
        
        eventptr->event_type = event;
-       INIT_WORK(&eventptr->work, ieee80211softmac_notify_callback, eventptr);
+       INIT_DELAYED_WORK(&eventptr->work, ieee80211softmac_notify_callback);
        eventptr->fun = fun;
        eventptr->context = context;
        eventptr->mac = mac;
@@ -136,30 +139,24 @@ ieee80211softmac_call_events_locked(struct ieee80211softmac_device *mac, int eve
                int we_event;
                char *msg = NULL;
 
+               memset(&wrqu, '\0', sizeof (union iwreq_data));
+
                switch(event) {
                case IEEE80211SOFTMAC_EVENT_ASSOCIATED:
                        network = (struct ieee80211softmac_network *)event_ctx;
-                       wrqu.data.length = 0;
-                       wrqu.data.flags = 0;
                        memcpy(wrqu.ap_addr.sa_data, &network->bssid[0], ETH_ALEN);
-                       wrqu.ap_addr.sa_family = ARPHRD_ETHER;
-                       we_event = SIOCGIWAP;
-                       break;
+                       /* fall through */
                case IEEE80211SOFTMAC_EVENT_DISASSOCIATED:
-                       wrqu.data.length = 0;
-                       wrqu.data.flags = 0;
-                       memset(&wrqu, '\0', sizeof (union iwreq_data));
                        wrqu.ap_addr.sa_family = ARPHRD_ETHER;
                        we_event = SIOCGIWAP;
                        break;
                case IEEE80211SOFTMAC_EVENT_SCAN_FINISHED:
-                       wrqu.data.length = 0;
-                       wrqu.data.flags = 0;
-                       memset(&wrqu, '\0', sizeof (union iwreq_data));
                        we_event = SIOCGIWSCAN;
                        break;
                default:
                        msg = event_descriptions[event];
+                       if (!msg)
+                               msg = "SOFTMAC EVENT BUG";
                        wrqu.data.length = strlen(msg);
                        we_event = IWEVCUSTOM;
                        break;
@@ -172,7 +169,10 @@ ieee80211softmac_call_events_locked(struct ieee80211softmac_device *mac, int eve
                        if ((eventptr->event_type == event || eventptr->event_type == -1)
                                && (eventptr->event_context == NULL || eventptr->event_context == event_ctx)) {
                                list_del(&eventptr->list);
-                               schedule_work(&eventptr->work);
+                               /* User may have subscribed to ANY event, so
+                                * we tell them which event triggered it. */
+                               eventptr->event_type = event;
+                               schedule_delayed_work(&eventptr->work, 0);
                        }
                }
 }