headers: remove sched.h from interrupt.h
[safe/jmp/linux-2.6] / drivers / net / wireless / prism54 / isl_ioctl.c
index 5b375b2..bc08464 100644 (file)
@@ -19,6 +19,7 @@
  *
  */
 
+#include <linux/capability.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/if_arp.h>
@@ -71,7 +72,7 @@ prism54_mib_mode_helper(islpci_private *priv, u32 iw_mode)
        if (iw_mode == IW_MODE_REPEAT || iw_mode == IW_MODE_SECOND) {
                printk(KERN_DEBUG
                       "%s(): Sorry, Repeater mode and Secondary mode "
-                      "are not yet supported by this driver.\n", __FUNCTION__);
+                      "are not yet supported by this driver.\n", __func__);
                return -EINVAL;
        }
 
@@ -333,7 +334,7 @@ prism54_set_mode(struct net_device *ndev, struct iw_request_info *info,
        if (*uwrq > IW_MODE_MONITOR || *uwrq < IW_MODE_AUTO) {
                printk(KERN_DEBUG
                       "%s: %s() You passed a non-valid init_mode.\n",
-                      priv->ndev->name, __FUNCTION__);
+                      priv->ndev->name, __func__);
                return -EINVAL;
        }
 
@@ -571,8 +572,9 @@ prism54_set_scan(struct net_device *dev, struct iw_request_info *info,
  */
 
 static char *
-prism54_translate_bss(struct net_device *ndev, char *current_ev,
-                     char *end_buf, struct obj_bss *bss, char noise)
+prism54_translate_bss(struct net_device *ndev, struct iw_request_info *info,
+                     char *current_ev, char *end_buf, struct obj_bss *bss,
+                     char noise)
 {
        struct iw_event iwe;    /* Temporary buffer */
        short cap;
@@ -584,8 +586,8 @@ prism54_translate_bss(struct net_device *ndev, char *current_ev,
        memcpy(iwe.u.ap_addr.sa_data, bss->address, 6);
        iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
        iwe.cmd = SIOCGIWAP;
-       current_ev =
-           iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_ADDR_LEN);
+       current_ev = iwe_stream_add_event(info, current_ev, end_buf,
+                                         &iwe, IW_EV_ADDR_LEN);
 
        /* The following entries will be displayed in the same order we give them */
 
@@ -593,7 +595,7 @@ prism54_translate_bss(struct net_device *ndev, char *current_ev,
        iwe.u.data.length = bss->ssid.length;
        iwe.u.data.flags = 1;
        iwe.cmd = SIOCGIWESSID;
-       current_ev = iwe_stream_add_point(current_ev, end_buf,
+       current_ev = iwe_stream_add_point(info, current_ev, end_buf,
                                          &iwe, bss->ssid.octets);
 
        /* Capabilities */
@@ -610,9 +612,8 @@ prism54_translate_bss(struct net_device *ndev, char *current_ev,
                iwe.u.mode = IW_MODE_ADHOC;
        iwe.cmd = SIOCGIWMODE;
        if (iwe.u.mode)
-               current_ev =
-                   iwe_stream_add_event(current_ev, end_buf, &iwe,
-                                        IW_EV_UINT_LEN);
+               current_ev = iwe_stream_add_event(info, current_ev, end_buf,
+                                                 &iwe, IW_EV_UINT_LEN);
 
        /* Encryption capability */
        if (cap & CAP_CRYPT)
@@ -621,14 +622,15 @@ prism54_translate_bss(struct net_device *ndev, char *current_ev,
                iwe.u.data.flags = IW_ENCODE_DISABLED;
        iwe.u.data.length = 0;
        iwe.cmd = SIOCGIWENCODE;
-       current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, NULL);
+       current_ev = iwe_stream_add_point(info, current_ev, end_buf,
+                                         &iwe, NULL);
 
        /* Add frequency. (short) bss->channel is the frequency in MHz */
        iwe.u.freq.m = bss->channel;
        iwe.u.freq.e = 6;
        iwe.cmd = SIOCGIWFREQ;
-       current_ev =
-           iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
+       current_ev = iwe_stream_add_event(info, current_ev, end_buf,
+                                         &iwe, IW_EV_FREQ_LEN);
 
        /* Add quality statistics */
        iwe.u.qual.level = bss->rssi;
@@ -636,20 +638,20 @@ prism54_translate_bss(struct net_device *ndev, char *current_ev,
        /* do a simple SNR for quality */
        iwe.u.qual.qual = bss->rssi - noise;
        iwe.cmd = IWEVQUAL;
-       current_ev =
-           iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
+       current_ev = iwe_stream_add_event(info, current_ev, end_buf,
+                                         &iwe, IW_EV_QUAL_LEN);
 
        /* Add WPA/RSN Information Element, if any */
        wpa_ie_len = prism54_wpa_bss_ie_get(priv, bss->address, wpa_ie);
        if (wpa_ie_len > 0) {
                iwe.cmd = IWEVGENIE;
                iwe.u.data.length = min(wpa_ie_len, (size_t)MAX_WPA_IE_LEN);
-               current_ev = iwe_stream_add_point(current_ev, end_buf,
-                               &iwe, wpa_ie);
+               current_ev = iwe_stream_add_point(info, current_ev, end_buf,
+                                                 &iwe, wpa_ie);
        }
        /* Do the bitrates */
        {
-               char *  current_val = current_ev + IW_EV_LCP_LEN;
+               char *current_val = current_ev + iwe_stream_lcp_len(info);
                int i;
                int mask;
 
@@ -662,14 +664,14 @@ prism54_translate_bss(struct net_device *ndev, char *current_ev,
                for(i = 0; i < sizeof(scan_rate_list); i++) {
                        if(bss->rates & mask) {
                                iwe.u.bitrate.value = (scan_rate_list[i] * 500000);
-                               current_val = iwe_stream_add_value(current_ev, current_val,
-                                                                  end_buf, &iwe,
-                                                                  IW_EV_PARAM_LEN);
+                               current_val = iwe_stream_add_value(
+                                       info, current_ev, current_val,
+                                       end_buf, &iwe, IW_EV_PARAM_LEN);
                        }
                        mask <<= 1;
                }
                /* Check if we added any event */
-               if ((current_val - current_ev) > IW_EV_LCP_LEN)
+               if ((current_val - current_ev) > iwe_stream_lcp_len(info))
                        current_ev = current_val;
        }
 
@@ -710,7 +712,7 @@ prism54_get_scan(struct net_device *ndev, struct iw_request_info *info,
 
        /* ok now, scan the list and translate its info */
        for (i = 0; i < (int) bsslist->nr; i++) {
-               current_ev = prism54_translate_bss(ndev, current_ev,
+               current_ev = prism54_translate_bss(ndev, info, current_ev,
                                                   extra + dwrq->length,
                                                   &(bsslist->bsslist[i]),
                                                   noise);
@@ -1233,7 +1235,7 @@ prism54_set_txpower(struct net_device *ndev, struct iw_request_info *info,
                /* don't know how to disable radio */
                printk(KERN_DEBUG
                       "%s: %s() disabling radio is not yet supported.\n",
-                      priv->ndev->name, __FUNCTION__);
+                      priv->ndev->name, __func__);
                return -ENOTSUPP;
        } else if (vwrq->fixed)
                /* currently only fixed value is supported */
@@ -1241,7 +1243,7 @@ prism54_set_txpower(struct net_device *ndev, struct iw_request_info *info,
        else {
                printk(KERN_DEBUG
                       "%s: %s() auto power will be implemented later.\n",
-                      priv->ndev->name, __FUNCTION__);
+                      priv->ndev->name, __func__);
                return -ENOTSUPP;
        }
 }
@@ -2027,12 +2029,11 @@ static void
 format_event(islpci_private *priv, char *dest, const char *str,
             const struct obj_mlme *mlme, u16 *length, int error)
 {
-       DECLARE_MAC_BUF(mac);
        int n = snprintf(dest, IW_CUSTOM_MAX,
-                        "%s %s %s %s (%2.2X)",
+                        "%s %s %pM %s (%2.2X)",
                         str,
                         ((priv->iw_mode == IW_MODE_MASTER) ? "from" : "to"),
-                        print_mac(mac, mlme->address),
+                        mlme->address,
                         (error ? (mlme->code ? " : REJECTED " : " : ACCEPTED ")
                          : ""), mlme->code);
        BUG_ON(n > IW_CUSTOM_MAX);
@@ -2112,7 +2113,6 @@ prism54_wpa_bss_ie_add(islpci_private *priv, u8 *bssid,
 {
        struct list_head *ptr;
        struct islpci_bss_wpa_ie *bss = NULL;
-       DECLARE_MAC_BUF(mac);
 
        if (wpa_ie_len > MAX_WPA_IE_LEN)
                wpa_ie_len = MAX_WPA_IE_LEN;
@@ -2153,7 +2153,7 @@ prism54_wpa_bss_ie_add(islpci_private *priv, u8 *bssid,
                bss->last_update = jiffies;
        } else {
                printk(KERN_DEBUG "Failed to add BSS WPA entry for "
-                      "%s\n", print_mac(mac, bssid));
+                      "%pM\n", bssid);
        }
 
        /* expire old entries from WPA list */
@@ -2218,7 +2218,6 @@ prism54_process_bss_data(islpci_private *priv, u32 oid, u8 *addr,
 {
        struct ieee80211_beacon_phdr *hdr;
        u8 *pos, *end;
-       DECLARE_MAC_BUF(mac);
 
        if (!priv->wpa)
                return;
@@ -2229,7 +2228,7 @@ prism54_process_bss_data(islpci_private *priv, u32 oid, u8 *addr,
        while (pos < end) {
                if (pos + 2 + pos[1] > end) {
                        printk(KERN_DEBUG "Parsing Beacon/ProbeResp failed "
-                              "for %s\n", print_mac(mac, addr));
+                              "for %pM\n", addr);
                        return;
                }
                if (pos[0] == WLAN_EID_GENERIC && pos[1] >= 4 &&
@@ -2268,7 +2267,6 @@ prism54_process_trap_helper(islpci_private *priv, enum oid_num_t oid,
        size_t len = 0; /* u16, better? */
        u8 *payload = NULL, *pos = NULL;
        int ret;
-       DECLARE_MAC_BUF(mac);
 
        /* I think all trapable objects are listed here.
         * Some oids have a EX version. The difference is that they are emitted
@@ -2357,8 +2355,8 @@ prism54_process_trap_helper(islpci_private *priv, enum oid_num_t oid,
                        break;
 
                memcpy(&confirm->address, mlmeex->address, ETH_ALEN);
-               printk(KERN_DEBUG "Authenticate from: address:\t%s\n",
-                      print_mac(mac, mlmeex->address));
+               printk(KERN_DEBUG "Authenticate from: address:\t%pM\n",
+                      mlmeex->address);
                confirm->id = -1; /* or mlmeex->id ? */
                confirm->state = 0; /* not used */
                confirm->code = 0;
@@ -2403,8 +2401,8 @@ prism54_process_trap_helper(islpci_private *priv, enum oid_num_t oid,
                wpa_ie_len = prism54_wpa_bss_ie_get(priv, mlmeex->address, wpa_ie);
 
                if (!wpa_ie_len) {
-                       printk(KERN_DEBUG "No WPA IE found from address:\t%s\n",
-                              print_mac(mac, mlmeex->address));
+                       printk(KERN_DEBUG "No WPA IE found from address:\t%pM\n",
+                              mlmeex->address);
                        kfree(confirm);
                        break;
                }
@@ -2440,8 +2438,8 @@ prism54_process_trap_helper(islpci_private *priv, enum oid_num_t oid,
                wpa_ie_len = prism54_wpa_bss_ie_get(priv, mlmeex->address, wpa_ie);
 
                if (!wpa_ie_len) {
-                       printk(KERN_DEBUG "No WPA IE found from address:\t%s\n",
-                              print_mac(mac, mlmeex->address));
+                       printk(KERN_DEBUG "No WPA IE found from address:\t%pM\n",
+                              mlmeex->address);
                        kfree(confirm);
                        break;
                }
@@ -2517,7 +2515,7 @@ enum {
 
 #define PRISM2_HOSTAPD_MAX_BUF_SIZE 1024
 #define PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN \
-((int) (&((struct prism2_hostapd_param *) 0)->u.generic_elem.data))
+       offsetof(struct prism2_hostapd_param, u.generic_elem.data)
 
 /* Maximum length for algorithm names (-1 for nul termination)
  * used in ioctl() */
@@ -2704,6 +2702,7 @@ prism2_ioctl_scan_req(struct net_device *ndev,
                      struct prism2_hostapd_param *param)
 {
        islpci_private *priv = netdev_priv(ndev);
+       struct iw_request_info info;
        int i, rvalue;
        struct obj_bsslist *bsslist;
        u32 noise = 0;
@@ -2727,9 +2726,12 @@ prism2_ioctl_scan_req(struct net_device *ndev,
        rvalue |= mgt_get_request(priv, DOT11_OID_BSSLIST, 0, NULL, &r);
        bsslist = r.ptr;
 
+       info.cmd = PRISM54_HOSTAPD;
+       info.flags = 0;
+
        /* ok now, scan the list and translate its info */
        for (i = 0; i < min(IW_MAX_AP, (int) bsslist->nr); i++)
-               current_ev = prism54_translate_bss(ndev, current_ev,
+               current_ev = prism54_translate_bss(ndev, &info, current_ev,
                                                   extra + IW_SCAN_MAX_DATA,
                                                   &(bsslist->bsslist[i]),
                                                   noise);
@@ -2980,7 +2982,8 @@ prism54_set_spy(struct net_device *ndev,
                union iwreq_data *uwrq, char *extra)
 {
        islpci_private *priv = netdev_priv(ndev);
-       u32 u, oid = OID_INL_CONFIG;
+       u32 u;
+       enum oid_num_t oid = OID_INL_CONFIG;
 
        down_write(&priv->mib_sem);
        mgt_get(priv, OID_INL_CONFIG, &u);