Use helpers to obtain task pid in printks
[safe/jmp/linux-2.6] / drivers / net / wireless / hostap / hostap_ioctl.c
index 4c236e7..d8f5efc 100644 (file)
@@ -1,11 +1,12 @@
 /* ioctl() (mostly Linux Wireless Extensions) routines for Host AP driver */
 
-#ifdef in_atomic
-/* Get kernel_locked() for in_atomic() */
-#include <linux/smp_lock.h>
-#endif
+#include <linux/types.h>
 #include <linux/ethtool.h>
+#include <net/ieee80211_crypt.h>
 
+#include "hostap_wlan.h"
+#include "hostap.h"
+#include "hostap_ap.h"
 
 static struct iw_statistics *hostap_get_wireless_stats(struct net_device *dev)
 {
@@ -50,7 +51,8 @@ static struct iw_statistics *hostap_get_wireless_stats(struct net_device *dev)
 #endif /* in_atomic */
 
                if (update && prism2_update_comms_qual(dev) == 0)
-                       wstats->qual.updated = 7;
+                       wstats->qual.updated = IW_QUAL_ALL_UPDATED |
+                               IW_QUAL_DBM;
 
                wstats->qual.qual = local->comms_qual;
                wstats->qual.level = local->avg_signal;
@@ -59,7 +61,7 @@ static struct iw_statistics *hostap_get_wireless_stats(struct net_device *dev)
                wstats->qual.qual = 0;
                wstats->qual.level = 0;
                wstats->qual.noise = 0;
-               wstats->qual.updated = 0;
+               wstats->qual.updated = IW_QUAL_ALL_INVALID;
        }
 
        return wstats;
@@ -115,9 +117,9 @@ static int prism2_get_name(struct net_device *dev,
 
 
 static void prism2_crypt_delayed_deinit(local_info_t *local,
-                                       struct prism2_crypt_data **crypt)
+                                       struct ieee80211_crypt_data **crypt)
 {
-       struct prism2_crypt_data *tmp;
+       struct ieee80211_crypt_data *tmp;
        unsigned long flags;
 
        tmp = *crypt;
@@ -147,7 +149,7 @@ static int prism2_ioctl_siwencode(struct net_device *dev,
        struct hostap_interface *iface;
        local_info_t *local;
        int i;
-       struct prism2_crypt_data **crypt;
+       struct ieee80211_crypt_data **crypt;
 
        iface = netdev_priv(dev);
        local = iface->local;
@@ -175,18 +177,17 @@ static int prism2_ioctl_siwencode(struct net_device *dev,
        }
 
        if (*crypt == NULL) {
-               struct prism2_crypt_data *new_crypt;
+               struct ieee80211_crypt_data *new_crypt;
 
                /* take WEP into use */
-               new_crypt = (struct prism2_crypt_data *)
-                       kmalloc(sizeof(struct prism2_crypt_data), GFP_KERNEL);
+               new_crypt = kzalloc(sizeof(struct ieee80211_crypt_data),
+                               GFP_KERNEL);
                if (new_crypt == NULL)
                        return -ENOMEM;
-               memset(new_crypt, 0, sizeof(struct prism2_crypt_data));
-               new_crypt->ops = hostap_get_crypto_ops("WEP");
+               new_crypt->ops = ieee80211_get_crypto_ops("WEP");
                if (!new_crypt->ops) {
-                       request_module("hostap_crypt_wep");
-                       new_crypt->ops = hostap_get_crypto_ops("WEP");
+                       request_module("ieee80211_crypt_wep");
+                       new_crypt->ops = ieee80211_get_crypto_ops("WEP");
                }
                if (new_crypt->ops)
                        new_crypt->priv = new_crypt->ops->init(i);
@@ -251,7 +252,7 @@ static int prism2_ioctl_giwencode(struct net_device *dev,
        local_info_t *local;
        int i, len;
        u16 val;
-       struct prism2_crypt_data *crypt;
+       struct ieee80211_crypt_data *crypt;
 
        iface = netdev_priv(dev);
        local = iface->local;
@@ -334,7 +335,7 @@ static int hostap_set_rate(struct net_device *dev)
               hostap_set_word(dev, HFA384X_RID_CNFSUPPORTEDRATES,
                               local->tx_rate_control) ||
               local->func->reset_port(dev));
-               
+
        if (ret) {
                printk(KERN_WARNING "%s: TXRateControl/cnfSupportedRates "
                       "setting to 0x%x failed\n",
@@ -550,7 +551,6 @@ static int prism2_ioctl_giwaplist(struct net_device *dev,
 
        kfree(addr);
        kfree(qual);
-
        return 0;
 }
 
@@ -663,7 +663,8 @@ static int hostap_join_ap(struct net_device *dev)
        struct hfa384x_join_request req;
        unsigned long flags;
        int i;
-       struct hfa384x_scan_result *entry;
+       struct hfa384x_hostscan_result *entry;
+       DECLARE_MAC_BUF(mac);
 
        iface = netdev_priv(dev);
        local = iface->local;
@@ -685,14 +686,14 @@ static int hostap_join_ap(struct net_device *dev)
 
        if (local->func->set_rid(dev, HFA384X_RID_JOINREQUEST, &req,
                                 sizeof(req))) {
-               printk(KERN_DEBUG "%s: JoinRequest " MACSTR
+               printk(KERN_DEBUG "%s: JoinRequest %s"
                       " failed\n",
-                      dev->name, MAC2STR(local->preferred_ap));
+                      dev->name, print_mac(mac, local->preferred_ap));
                return -1;
        }
 
-       printk(KERN_DEBUG "%s: Trying to join BSSID " MACSTR "\n",
-              dev->name, MAC2STR(local->preferred_ap));
+       printk(KERN_DEBUG "%s: Trying to join BSSID %s\n",
+              dev->name, print_mac(mac, local->preferred_ap));
 
        return 0;
 }
@@ -896,11 +897,8 @@ static void hostap_monitor_set_type(local_info_t *local)
        if (local->monitor_type == PRISM2_MONITOR_PRISM ||
            local->monitor_type == PRISM2_MONITOR_CAPHDR) {
                dev->type = ARPHRD_IEEE80211_PRISM;
-               dev->hard_header_parse =
-                       hostap_80211_prism_header_parse;
        } else {
                dev->type = ARPHRD_IEEE80211;
-               dev->hard_header_parse = hostap_80211_header_parse;
        }
 }
 
@@ -1140,7 +1138,7 @@ static int hostap_monitor_mode_disable(local_info_t *local)
 
        printk(KERN_DEBUG "%s: Disabling monitor mode\n", dev->name);
        dev->type = ARPHRD_ETHER;
-       dev->hard_header_parse = local->saved_eth_header_parse;
+
        if (local->func->cmd(dev, HFA384X_CMDCODE_TEST |
                             (HFA384X_TEST_STOP << 8),
                             0, NULL, NULL))
@@ -1182,7 +1180,8 @@ static int prism2_ioctl_siwmode(struct net_device *dev,
        if (local->iw_mode == IW_MODE_MONITOR)
                hostap_monitor_mode_disable(local);
 
-       if (local->iw_mode == IW_MODE_ADHOC && *mode == IW_MODE_MASTER) {
+       if ((local->iw_mode == IW_MODE_ADHOC ||
+            local->iw_mode == IW_MODE_MONITOR) && *mode == IW_MODE_MASTER) {
                /* There seems to be a firmware bug in at least STA f/w v1.5.6
                 * that leaves beacon frames to use IBSS type when moving from
                 * IBSS to Host AP mode. Doing double Port0 reset seems to be
@@ -1408,9 +1407,9 @@ static int prism2_ioctl_siwretry(struct net_device *dev,
        /* what could be done, if firmware would support this.. */
 
        if (rrq->flags & IW_RETRY_LIMIT) {
-               if (rrq->flags & IW_RETRY_MAX)
+               if (rrq->flags & IW_RETRY_LONG)
                        HFA384X_RID_LONGRETRYLIMIT = rrq->value;
-               else if (rrq->flags & IW_RETRY_MIN)
+               else if (rrq->flags & IW_RETRY_SHORT)
                        HFA384X_RID_SHORTRETRYLIMIT = rrq->value;
                else {
                        HFA384X_RID_LONGRETRYLIMIT = rrq->value;
@@ -1464,14 +1463,14 @@ static int prism2_ioctl_giwretry(struct net_device *dev,
                                rrq->value = le16_to_cpu(altretry);
                        else
                                rrq->value = local->manual_retry_count;
-               } else if ((rrq->flags & IW_RETRY_MAX)) {
-                       rrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
+               } else if ((rrq->flags & IW_RETRY_LONG)) {
+                       rrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
                        rrq->value = longretry;
                } else {
                        rrq->flags = IW_RETRY_LIMIT;
                        rrq->value = shortretry;
                        if (shortretry != longretry)
-                               rrq->flags |= IW_RETRY_MIN;
+                               rrq->flags |= IW_RETRY_SHORT;
                }
        }
        return 0;
@@ -1795,10 +1794,8 @@ static int prism2_ioctl_siwscan(struct net_device *dev,
 
 #ifndef PRISM2_NO_STATION_MODES
 static char * __prism2_translate_scan(local_info_t *local,
-                                     struct hfa384x_scan_result *scan,
-                                     struct hfa384x_hostscan_result *hscan,
-                                     int hostscan,
-                                     struct hostap_bss_info *bss, u8 *bssid,
+                                     struct hfa384x_hostscan_result *scan,
+                                     struct hostap_bss_info *bss,
                                      char *current_ev, char *end_buf)
 {
        int i, chan;
@@ -1806,17 +1803,18 @@ static char * __prism2_translate_scan(local_info_t *local,
        char *current_val;
        u16 capabilities;
        u8 *pos;
-       u8 *ssid;
+       u8 *ssid, *bssid;
        size_t ssid_len;
        char *buf;
 
        if (bss) {
                ssid = bss->ssid;
                ssid_len = bss->ssid_len;
+               bssid = bss->bssid;
        } else {
-               ssid = hostscan ? hscan->ssid : scan->ssid;
-               ssid_len = le16_to_cpu(hostscan ? hscan->ssid_len :
-                                      scan->ssid_len);
+               ssid = scan->ssid;
+               ssid_len = le16_to_cpu(scan->ssid_len);
+               bssid = scan->bssid;
        }
        if (ssid_len > 32)
                ssid_len = 32;
@@ -1826,13 +1824,6 @@ static char * __prism2_translate_scan(local_info_t *local,
        iwe.cmd = SIOCGIWAP;
        iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
        memcpy(iwe.u.ap_addr.sa_data, bssid, ETH_ALEN);
-       /* FIX:
-        * I do not know how this is possible, but iwe_stream_add_event
-        * seems to re-order memcpy execution so that len is set only
-        * after copying.. Pre-setting len here "fixes" this, but real
-        * problems should be solved (after which these iwe.len
-        * settings could be removed from this function). */
-       iwe.len = IW_EV_ADDR_LEN;
        current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
                                          IW_EV_ADDR_LEN);
 
@@ -1842,7 +1833,6 @@ static char * __prism2_translate_scan(local_info_t *local,
        iwe.cmd = SIOCGIWESSID;
        iwe.u.data.length = ssid_len;
        iwe.u.data.flags = 1;
-       iwe.len = IW_EV_POINT_LEN + iwe.u.data.length;
        current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, ssid);
 
        memset(&iwe, 0, sizeof(iwe));
@@ -1850,8 +1840,7 @@ static char * __prism2_translate_scan(local_info_t *local,
        if (bss) {
                capabilities = bss->capab_info;
        } else {
-               capabilities = le16_to_cpu(hostscan ? hscan->capability :
-                                          scan->capability);
+               capabilities = le16_to_cpu(scan->capability);
        }
        if (capabilities & (WLAN_CAPABILITY_ESS |
                            WLAN_CAPABILITY_IBSS)) {
@@ -1859,15 +1848,14 @@ static char * __prism2_translate_scan(local_info_t *local,
                        iwe.u.mode = IW_MODE_MASTER;
                else
                        iwe.u.mode = IW_MODE_ADHOC;
-               iwe.len = IW_EV_UINT_LEN;
                current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
                                                  IW_EV_UINT_LEN);
        }
 
        memset(&iwe, 0, sizeof(iwe));
        iwe.cmd = SIOCGIWFREQ;
-       if (hscan || scan) {
-               chan = hostscan ? hscan->chid : scan->chid;
+       if (scan) {
+               chan = le16_to_cpu(scan->chid);
        } else if (bss) {
                chan = bss->chan;
        } else {
@@ -1875,26 +1863,28 @@ static char * __prism2_translate_scan(local_info_t *local,
        }
 
        if (chan > 0) {
-               iwe.u.freq.m = freq_list[le16_to_cpu(chan - 1)] * 100000;
+               iwe.u.freq.m = freq_list[chan - 1] * 100000;
                iwe.u.freq.e = 1;
-               iwe.len = IW_EV_FREQ_LEN;
                current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
                                                  IW_EV_FREQ_LEN);
        }
 
-       if (scan || hscan) {
+       if (scan) {
                memset(&iwe, 0, sizeof(iwe));
                iwe.cmd = IWEVQUAL;
-               if (hostscan) {
-                       iwe.u.qual.level = le16_to_cpu(hscan->sl);
-                       iwe.u.qual.noise = le16_to_cpu(hscan->anl);
+               if (local->last_scan_type == PRISM2_HOSTSCAN) {
+                       iwe.u.qual.level = le16_to_cpu(scan->sl);
+                       iwe.u.qual.noise = le16_to_cpu(scan->anl);
                } else {
                        iwe.u.qual.level =
                                HFA384X_LEVEL_TO_dBm(le16_to_cpu(scan->sl));
                        iwe.u.qual.noise =
                                HFA384X_LEVEL_TO_dBm(le16_to_cpu(scan->anl));
                }
-               iwe.len = IW_EV_QUAL_LEN;
+               iwe.u.qual.updated = IW_QUAL_LEVEL_UPDATED
+                       | IW_QUAL_NOISE_UPDATED
+                       | IW_QUAL_QUAL_INVALID
+                       | IW_QUAL_DBM;
                current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
                                                  IW_EV_QUAL_LEN);
        }
@@ -1906,15 +1896,14 @@ static char * __prism2_translate_scan(local_info_t *local,
        else
                iwe.u.data.flags = IW_ENCODE_DISABLED;
        iwe.u.data.length = 0;
-       iwe.len = IW_EV_POINT_LEN + iwe.u.data.length;
        current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, "");
 
        /* TODO: add SuppRates into BSS table */
-       if (scan || hscan) {
+       if (scan) {
                memset(&iwe, 0, sizeof(iwe));
                iwe.cmd = SIOCGIWRATE;
                current_val = current_ev + IW_EV_LCP_LEN;
-               pos = hostscan ? hscan->sup_rates : scan->sup_rates;
+               pos = scan->sup_rates;
                for (i = 0; i < sizeof(scan->sup_rates); i++) {
                        if (pos[i] == 0)
                                break;
@@ -1930,30 +1919,27 @@ static char * __prism2_translate_scan(local_info_t *local,
        }
 
        /* TODO: add BeaconInt,resp_rate,atim into BSS table */
-       buf = kmalloc(MAX_WPA_IE_LEN * 2 + 30, GFP_KERNEL);
-       if (buf && (scan || hscan)) {
+       buf = kmalloc(MAX_WPA_IE_LEN * 2 + 30, GFP_ATOMIC);
+       if (buf && scan) {
                memset(&iwe, 0, sizeof(iwe));
                iwe.cmd = IWEVCUSTOM;
-               sprintf(buf, "bcn_int=%d",
-                       le16_to_cpu(hostscan ? hscan->beacon_interval :
-                                   scan->beacon_interval));
+               sprintf(buf, "bcn_int=%d", le16_to_cpu(scan->beacon_interval));
                iwe.u.data.length = strlen(buf);
                current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe,
                                                  buf);
 
                memset(&iwe, 0, sizeof(iwe));
                iwe.cmd = IWEVCUSTOM;
-               sprintf(buf, "resp_rate=%d", le16_to_cpu(hostscan ?
-                                                        hscan->rate :
-                                                        scan->rate));
+               sprintf(buf, "resp_rate=%d", le16_to_cpu(scan->rate));
                iwe.u.data.length = strlen(buf);
                current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe,
                                                  buf);
 
-               if (hostscan && (capabilities & WLAN_CAPABILITY_IBSS)) {
+               if (local->last_scan_type == PRISM2_HOSTSCAN &&
+                   (capabilities & WLAN_CAPABILITY_IBSS)) {
                        memset(&iwe, 0, sizeof(iwe));
                        iwe.cmd = IWEVCUSTOM;
-                       sprintf(buf, "atim=%d", le16_to_cpu(hscan->atim));
+                       sprintf(buf, "atim=%d", le16_to_cpu(scan->atim));
                        iwe.u.data.length = strlen(buf);
                        current_ev = iwe_stream_add_point(current_ev, end_buf,
                                                          &iwe, buf);
@@ -1986,12 +1972,10 @@ static char * __prism2_translate_scan(local_info_t *local,
 static inline int prism2_translate_scan(local_info_t *local,
                                        char *buffer, int buflen)
 {
-       struct hfa384x_scan_result *scan;
-       struct hfa384x_hostscan_result *hscan;
-       int entries, entry, hostscan;
+       struct hfa384x_hostscan_result *scan;
+       int entry, hostscan;
        char *current_ev = buffer;
        char *end_buf = buffer + buflen;
-       u8 *bssid;
        struct list_head *ptr;
 
        spin_lock_bh(&local->lock);
@@ -2003,14 +1987,9 @@ static inline int prism2_translate_scan(local_info_t *local,
        }
 
        hostscan = local->last_scan_type == PRISM2_HOSTSCAN;
-       entries = hostscan ? local->last_hostscan_results_count :
-               local->last_scan_results_count;
-       for (entry = 0; entry < entries; entry++) {
+       for (entry = 0; entry < local->last_scan_results_count; entry++) {
                int found = 0;
                scan = &local->last_scan_results[entry];
-               hscan = &local->last_hostscan_results[entry];
-
-               bssid = hostscan ? hscan->bssid : scan->bssid;
 
                /* Report every SSID if the AP is using multiple SSIDs. If no
                 * BSS record is found (e.g., when WPA mode is disabled),
@@ -2018,18 +1997,16 @@ static inline int prism2_translate_scan(local_info_t *local,
                list_for_each(ptr, &local->bss_list) {
                        struct hostap_bss_info *bss;
                        bss = list_entry(ptr, struct hostap_bss_info, list);
-                       if (memcmp(bss->bssid, bssid, ETH_ALEN) == 0) {
+                       if (memcmp(bss->bssid, scan->bssid, ETH_ALEN) == 0) {
                                bss->included = 1;
                                current_ev = __prism2_translate_scan(
-                                       local, scan, hscan, hostscan, bss,
-                                       bssid, current_ev, end_buf);
+                                       local, scan, bss, current_ev, end_buf);
                                found++;
                        }
                }
                if (!found) {
                        current_ev = __prism2_translate_scan(
-                               local, scan, hscan, hostscan, NULL, bssid,
-                               current_ev, end_buf);
+                               local, scan, NULL, current_ev, end_buf);
                }
                /* Check if there is space for one more entry */
                if ((end_buf - current_ev) <= IW_EV_ADDR_LEN) {
@@ -2047,9 +2024,8 @@ static inline int prism2_translate_scan(local_info_t *local,
                bss = list_entry(ptr, struct hostap_bss_info, list);
                if (bss->included)
                        continue;
-               current_ev = __prism2_translate_scan(local, NULL, NULL, 0, bss,
-                                                    bss->bssid, current_ev,
-                                                    end_buf);
+               current_ev = __prism2_translate_scan(local, NULL, bss,
+                                                    current_ev, end_buf);
                /* Check if there is space for one more entry */
                if ((end_buf - current_ev) <= IW_EV_ADDR_LEN) {
                        /* Ask user space to try again with a bigger buffer */
@@ -2252,14 +2228,6 @@ static const struct iw_priv_args prism2_priv[] = {
          IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "host_decrypt" },
        { PRISM2_PARAM_HOST_DECRYPT,
          0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "gethost_decrypt" },
-       { PRISM2_PARAM_BUS_MASTER_THRESHOLD_RX,
-         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "busmaster_rx" },
-       { PRISM2_PARAM_BUS_MASTER_THRESHOLD_RX,
-         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getbusmaster_rx" },
-       { PRISM2_PARAM_BUS_MASTER_THRESHOLD_TX,
-         IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "busmaster_tx" },
-       { PRISM2_PARAM_BUS_MASTER_THRESHOLD_TX,
-         0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getbusmaster_tx" },
 #ifndef PRISM2_NO_STATION_MODES
        { PRISM2_PARAM_HOST_ROAMING,
          IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "host_roaming" },
@@ -2508,14 +2476,6 @@ static int prism2_ioctl_priv_prism2_param(struct net_device *dev,
                        ret = -EINVAL;
                break;
 
-       case PRISM2_PARAM_BUS_MASTER_THRESHOLD_RX:
-               local->bus_master_threshold_rx = value;
-               break;
-
-       case PRISM2_PARAM_BUS_MASTER_THRESHOLD_TX:
-               local->bus_master_threshold_tx = value;
-               break;
-
 #ifndef PRISM2_NO_STATION_MODES
        case PRISM2_PARAM_HOST_ROAMING:
                if (value < 0 || value > 2) {
@@ -2812,14 +2772,6 @@ static int prism2_ioctl_priv_get_prism2_param(struct net_device *dev,
                *param = local->host_decrypt;
                break;
 
-       case PRISM2_PARAM_BUS_MASTER_THRESHOLD_RX:
-               *param = local->bus_master_threshold_rx;
-               break;
-
-       case PRISM2_PARAM_BUS_MASTER_THRESHOLD_TX:
-               *param = local->bus_master_threshold_tx;
-               break;
-
        case PRISM2_PARAM_HOST_ROAMING:
                *param = local->host_roaming;
                break;
@@ -2968,7 +2920,7 @@ static int prism2_ioctl_priv_monitor(struct net_device *dev, int *i)
 
        printk(KERN_DEBUG "%s: process %d (%s) used deprecated iwpriv monitor "
               "- update software to use iwconfig mode monitor\n",
-              dev->name, current->pid, current->comm);
+              dev->name, task_pid_nr(current), current->comm);
 
        /* Backward compatibility code - this can be removed at some point */
 
@@ -3125,9 +3077,7 @@ static int prism2_ioctl_priv_download(local_info_t *local, struct iw_point *p)
        ret = local->func->download(local, param);
 
  out:
-       if (param != NULL)
-               kfree(param);
-
+       kfree(param);
        return ret;
 }
 #endif /* PRISM2_DOWNLOAD_SUPPORT */
@@ -3136,7 +3086,7 @@ static int prism2_ioctl_priv_download(local_info_t *local, struct iw_point *p)
 static int prism2_set_genericelement(struct net_device *dev, u8 *elem,
                                     size_t len)
 {
-       struct hostap_interface *iface = dev->priv;
+       struct hostap_interface *iface = netdev_priv(dev);
        local_info_t *local = iface->local;
        u8 *buf;
 
@@ -3164,7 +3114,7 @@ static int prism2_ioctl_siwauth(struct net_device *dev,
                                struct iw_request_info *info,
                                struct iw_param *data, char *extra)
 {
-       struct hostap_interface *iface = dev->priv;
+       struct hostap_interface *iface = netdev_priv(dev);
        local_info_t *local = iface->local;
 
        switch (data->flags & IW_AUTH_INDEX) {
@@ -3230,7 +3180,7 @@ static int prism2_ioctl_giwauth(struct net_device *dev,
                                struct iw_request_info *info,
                                struct iw_param *data, char *extra)
 {
-       struct hostap_interface *iface = dev->priv;
+       struct hostap_interface *iface = netdev_priv(dev);
        local_info_t *local = iface->local;
 
        switch (data->flags & IW_AUTH_INDEX) {
@@ -3269,12 +3219,12 @@ static int prism2_ioctl_siwencodeext(struct net_device *dev,
                                     struct iw_request_info *info,
                                     struct iw_point *erq, char *extra)
 {
-       struct hostap_interface *iface = dev->priv;
+       struct hostap_interface *iface = netdev_priv(dev);
        local_info_t *local = iface->local;
        struct iw_encode_ext *ext = (struct iw_encode_ext *) extra;
        int i, ret = 0;
-       struct hostap_crypto_ops *ops;
-       struct prism2_crypt_data **crypt;
+       struct ieee80211_crypto_ops *ops;
+       struct ieee80211_crypt_data **crypt;
        void *sta_ptr;
        u8 *addr;
        const char *alg, *module;
@@ -3322,15 +3272,15 @@ static int prism2_ioctl_siwencodeext(struct net_device *dev,
        switch (ext->alg) {
        case IW_ENCODE_ALG_WEP:
                alg = "WEP";
-               module = "hostap_crypt_wep";
+               module = "ieee80211_crypt_wep";
                break;
        case IW_ENCODE_ALG_TKIP:
                alg = "TKIP";
-               module = "hostap_crypt_tkip";
+               module = "ieee80211_crypt_tkip";
                break;
        case IW_ENCODE_ALG_CCMP:
                alg = "CCMP";
-               module = "hostap_crypt_ccmp";
+               module = "ieee80211_crypt_ccmp";
                break;
        default:
                printk(KERN_DEBUG "%s: unsupported algorithm %d\n",
@@ -3339,10 +3289,10 @@ static int prism2_ioctl_siwencodeext(struct net_device *dev,
                goto done;
        }
 
-       ops = hostap_get_crypto_ops(alg);
+       ops = ieee80211_get_crypto_ops(alg);
        if (ops == NULL) {
                request_module(module);
-               ops = hostap_get_crypto_ops(alg);
+               ops = ieee80211_get_crypto_ops(alg);
        }
        if (ops == NULL) {
                printk(KERN_DEBUG "%s: unknown crypto alg '%s'\n",
@@ -3361,17 +3311,16 @@ static int prism2_ioctl_siwencodeext(struct net_device *dev,
        }
 
        if (*crypt == NULL || (*crypt)->ops != ops) {
-               struct prism2_crypt_data *new_crypt;
+               struct ieee80211_crypt_data *new_crypt;
 
                prism2_crypt_delayed_deinit(local, crypt);
 
-               new_crypt = (struct prism2_crypt_data *)
-                       kmalloc(sizeof(struct prism2_crypt_data), GFP_KERNEL);
+               new_crypt = kzalloc(sizeof(struct ieee80211_crypt_data),
+                               GFP_KERNEL);
                if (new_crypt == NULL) {
                        ret = -ENOMEM;
                        goto done;
                }
-               memset(new_crypt, 0, sizeof(struct prism2_crypt_data));
                new_crypt->ops = ops;
                new_crypt->priv = new_crypt->ops->init(i);
                if (new_crypt->priv == NULL) {
@@ -3402,10 +3351,6 @@ static int prism2_ioctl_siwencodeext(struct net_device *dev,
        if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
                if (!sta_ptr)
                        local->tx_keyidx = i;
-               else if (i) {
-                       ret = -EINVAL;
-                       goto done;
-               }
        }
 
 
@@ -3448,9 +3393,9 @@ static int prism2_ioctl_giwencodeext(struct net_device *dev,
                                     struct iw_request_info *info,
                                     struct iw_point *erq, char *extra)
 {
-       struct hostap_interface *iface = dev->priv;
+       struct hostap_interface *iface = netdev_priv(dev);
        local_info_t *local = iface->local;
-       struct prism2_crypt_data **crypt;
+       struct ieee80211_crypt_data **crypt;
        void *sta_ptr;
        int max_key_len, i;
        struct iw_encode_ext *ext = (struct iw_encode_ext *) extra;
@@ -3519,8 +3464,8 @@ static int prism2_ioctl_set_encryption(local_info_t *local,
                                       int param_len)
 {
        int ret = 0;
-       struct hostap_crypto_ops *ops;
-       struct prism2_crypt_data **crypt;
+       struct ieee80211_crypto_ops *ops;
+       struct ieee80211_crypt_data **crypt;
        void *sta_ptr;
 
        param->u.crypt.err = 0;
@@ -3558,16 +3503,16 @@ static int prism2_ioctl_set_encryption(local_info_t *local,
                goto done;
        }
 
-       ops = hostap_get_crypto_ops(param->u.crypt.alg);
+       ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
        if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) {
-               request_module("hostap_crypt_wep");
-               ops = hostap_get_crypto_ops(param->u.crypt.alg);
+               request_module("ieee80211_crypt_wep");
+               ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
        } else if (ops == NULL && strcmp(param->u.crypt.alg, "TKIP") == 0) {
-               request_module("hostap_crypt_tkip");
-               ops = hostap_get_crypto_ops(param->u.crypt.alg);
+               request_module("ieee80211_crypt_tkip");
+               ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
        } else if (ops == NULL && strcmp(param->u.crypt.alg, "CCMP") == 0) {
-               request_module("hostap_crypt_ccmp");
-               ops = hostap_get_crypto_ops(param->u.crypt.alg);
+               request_module("ieee80211_crypt_ccmp");
+               ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
        }
        if (ops == NULL) {
                printk(KERN_DEBUG "%s: unknown crypto alg '%s'\n",
@@ -3582,17 +3527,16 @@ static int prism2_ioctl_set_encryption(local_info_t *local,
        local->host_decrypt = local->host_encrypt = 1;
 
        if (*crypt == NULL || (*crypt)->ops != ops) {
-               struct prism2_crypt_data *new_crypt;
+               struct ieee80211_crypt_data *new_crypt;
 
                prism2_crypt_delayed_deinit(local, crypt);
 
-               new_crypt = (struct prism2_crypt_data *)
-                       kmalloc(sizeof(struct prism2_crypt_data), GFP_KERNEL);
+               new_crypt = kzalloc(sizeof(struct ieee80211_crypt_data),
+                               GFP_KERNEL);
                if (new_crypt == NULL) {
                        ret = -ENOMEM;
                        goto done;
                }
-               memset(new_crypt, 0, sizeof(struct prism2_crypt_data));
                new_crypt->ops = ops;
                new_crypt->priv = new_crypt->ops->init(param->u.crypt.idx);
                if (new_crypt->priv == NULL) {
@@ -3656,7 +3600,7 @@ static int prism2_ioctl_get_encryption(local_info_t *local,
                                       struct prism2_hostapd_param *param,
                                       int param_len)
 {
-       struct prism2_crypt_data **crypt;
+       struct ieee80211_crypt_data **crypt;
        void *sta_ptr;
        int max_key_len;
 
@@ -3751,8 +3695,10 @@ static int prism2_ioctl_set_assoc_ap_addr(local_info_t *local,
                                          struct prism2_hostapd_param *param,
                                          int param_len)
 {
-       printk(KERN_DEBUG "%ssta: associated as client with AP " MACSTR "\n",
-              local->dev->name, MAC2STR(param->sta_addr));
+       DECLARE_MAC_BUF(mac);
+       printk(KERN_DEBUG "%ssta: associated as client with AP "
+              "%s\n",
+              local->dev->name, print_mac(mac, param->sta_addr));
        memcpy(local->assoc_ap_addr, param->sta_addr, ETH_ALEN);
        return 0;
 }
@@ -3770,7 +3716,7 @@ static int prism2_ioctl_giwgenie(struct net_device *dev,
                                 struct iw_request_info *info,
                                 struct iw_point *data, char *extra)
 {
-       struct hostap_interface *iface = dev->priv;
+       struct hostap_interface *iface = netdev_priv(dev);
        local_info_t *local = iface->local;
        int len = local->generic_elem_len - 2;
 
@@ -3809,7 +3755,7 @@ static int prism2_ioctl_siwmlme(struct net_device *dev,
                                struct iw_request_info *info,
                                struct iw_point *data, char *extra)
 {
-       struct hostap_interface *iface = dev->priv;
+       struct hostap_interface *iface = netdev_priv(dev);
        local_info_t *local = iface->local;
        struct iw_mlme *mlme = (struct iw_mlme *) extra;
        u16 reason;
@@ -3819,11 +3765,11 @@ static int prism2_ioctl_siwmlme(struct net_device *dev,
        switch (mlme->cmd) {
        case IW_MLME_DEAUTH:
                return prism2_sta_send_mgmt(local, mlme->addr.sa_data,
-                                           WLAN_FC_STYPE_DEAUTH,
+                                           IEEE80211_STYPE_DEAUTH,
                                            (u8 *) &reason, 2);
        case IW_MLME_DISASSOC:
                return prism2_sta_send_mgmt(local, mlme->addr.sa_data,
-                                           WLAN_FC_STYPE_DISASSOC,
+                                           IEEE80211_STYPE_DISASSOC,
                                            (u8 *) &reason, 2);
        default:
                return -EOPNOTSUPP;
@@ -3840,11 +3786,11 @@ static int prism2_ioctl_mlme(local_info_t *local,
        switch (param->u.mlme.cmd) {
        case MLME_STA_DEAUTH:
                return prism2_sta_send_mgmt(local, param->sta_addr,
-                                           WLAN_FC_STYPE_DEAUTH,
+                                           IEEE80211_STYPE_DEAUTH,
                                            (u8 *) &reason, 2);
        case MLME_STA_DISASSOC:
                return prism2_sta_send_mgmt(local, param->sta_addr,
-                                           WLAN_FC_STYPE_DISASSOC,
+                                           IEEE80211_STYPE_DISASSOC,
                                            (u8 *) &reason, 2);
        default:
                return -EOPNOTSUPP;
@@ -3882,7 +3828,7 @@ static int prism2_ioctl_priv_hostapd(local_info_t *local, struct iw_point *p)
            p->length > PRISM2_HOSTAPD_MAX_BUF_SIZE || !p->pointer)
                return -EINVAL;
 
-       param = (struct prism2_hostapd_param *) kmalloc(p->length, GFP_KERNEL);
+       param = kmalloc(p->length, GFP_KERNEL);
        if (param == NULL)
                return -ENOMEM;
 
@@ -3932,9 +3878,7 @@ static int prism2_ioctl_priv_hostapd(local_info_t *local, struct iw_point *p)
        }
 
  out:
-       if (param != NULL)
-               kfree(param);
-
+       kfree(param);
        return ret;
 }
 
@@ -3949,15 +3893,13 @@ static void prism2_get_drvinfo(struct net_device *dev,
        local = iface->local;
 
        strncpy(info->driver, "hostap", sizeof(info->driver) - 1);
-       strncpy(info->version, PRISM2_VERSION,
-               sizeof(info->version) - 1);
        snprintf(info->fw_version, sizeof(info->fw_version) - 1,
                 "%d.%d.%d", (local->sta_fw_ver >> 16) & 0xff,
                 (local->sta_fw_ver >> 8) & 0xff,
                 local->sta_fw_ver & 0xff);
 }
 
-static struct ethtool_ops prism2_ethtool_ops = {
+const struct ethtool_ops prism2_ethtool_ops = {
        .get_drvinfo = prism2_get_drvinfo
 };
 
@@ -4032,11 +3974,11 @@ static const iw_handler prism2_private_handler[] =
        (iw_handler) prism2_ioctl_priv_readmif,         /* 3 */
 };
 
-static const struct iw_handler_def hostap_iw_handler_def =
+const struct iw_handler_def hostap_iw_handler_def =
 {
-       .num_standard   = sizeof(prism2_handler) / sizeof(iw_handler),
-       .num_private    = sizeof(prism2_private_handler) / sizeof(iw_handler),
-       .num_private_args = sizeof(prism2_priv) / sizeof(struct iw_priv_args),
+       .num_standard   = ARRAY_SIZE(prism2_handler),
+       .num_private    = ARRAY_SIZE(prism2_private_handler),
+       .num_private_args = ARRAY_SIZE(prism2_priv),
        .standard       = (iw_handler *) prism2_handler,
        .private        = (iw_handler *) prism2_private_handler,
        .private_args   = (struct iw_priv_args *) prism2_priv,