[PATCH] softmac: clean up event handling code
authorJohannes Berg <johannes@sipsolutions.net>
Thu, 20 Apr 2006 18:02:04 +0000 (20:02 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 24 Apr 2006 20:15:58 +0000 (16:15 -0400)
This patch cleans up the event handling code in ieee80211softmac_event.c and
makes the module slightly smaller by removing some strings that are not used
any more and consolidating some code.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
net/ieee80211/softmac/ieee80211softmac_event.c

index 8cc8f3f..4b153f7 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 */
 };
 
 
@@ -136,30 +137,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;