These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / staging / rtl8712 / rtl871x_ioctl_linux.c
index cb0b638..edfc680 100644 (file)
@@ -72,32 +72,6 @@ static const char * const iw_operation_mode[] = {
         "Monitor"
 };
 
-/**
- * hwaddr_aton - Convert ASCII string to MAC address
- * @txt: MAC address as a string (e.g., "00:11:22:33:44:55")
- * @addr: Buffer for the MAC address (ETH_ALEN = 6 bytes)
- * Returns: 0 on success, -1 on failure (e.g., string not a MAC address)
- */
-static int hwaddr_aton_i(const char *txt, u8 *addr)
-{
-       int i;
-
-       for (i = 0; i < 6; i++) {
-               int a, b;
-
-               a = hex_to_bin(*txt++);
-               if (a < 0)
-                       return -1;
-               b = hex_to_bin(*txt++);
-               if (b < 0)
-                       return -1;
-               *addr++ = (a << 4) | b;
-               if (i < 5 && *txt++ != ':')
-                       return -1;
-       }
-       return 0;
-}
-
 void r8712_indicate_wx_assoc_event(struct _adapter *padapter)
 {
        union iwreq_data wrqu;
@@ -140,16 +114,17 @@ static inline void handle_pairwise_key(struct sta_info *psta,
 static inline void handle_group_key(struct ieee_param *param,
                                    struct _adapter *padapter)
 {
-       if (0 < param->u.crypt.idx &&
+       if (param->u.crypt.idx > 0 &&
            param->u.crypt.idx < 3) {
                /* group key idx is 1 or 2 */
                memcpy(padapter->securitypriv.XGrpKey[param->u.crypt.
-                       idx-1].skey, param->u.crypt.key, (param->u.crypt.key_len
-                       > 16 ? 16 : param->u.crypt.key_len));
+                       idx - 1].skey, param->u.crypt.key,
+                       (param->u.crypt.key_len > 16 ? 16 :
+                        param->u.crypt.key_len));
                memcpy(padapter->securitypriv.XGrptxmickey[param->
-                       u.crypt.idx-1].skey, &(param->u.crypt.key[16]), 8);
+                       u.crypt.idx - 1].skey, &(param->u.crypt.key[16]), 8);
                memcpy(padapter->securitypriv. XGrprxmickey[param->
-                       u.crypt.idx-1].skey, &(param->u.crypt.key[24]), 8);
+                       u.crypt.idx - 1].skey, &(param->u.crypt.key[24]), 8);
                padapter->securitypriv.binstallGrpkey = true;
                r8712_set_key(padapter, &padapter->securitypriv,
                        param->u.crypt.idx);
@@ -203,20 +178,18 @@ static inline char *translate_scan(struct _adapter *padapter,
        }
        /* Add the protocol name */
        iwe.cmd = SIOCGIWNAME;
-       if ((r8712_is_cckratesonly_included((u8 *)&pnetwork->network.
-            SupportedRates)) == true) {
-               if (ht_cap == true)
+       if (r8712_is_cckratesonly_included(pnetwork->network.rates)) {
+               if (ht_cap)
                        snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bn");
                else
                        snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11b");
-       } else if ((r8712_is_cckrates_included((u8 *)&pnetwork->network.
-                   SupportedRates)) == true) {
-               if (ht_cap == true)
+       } else if (r8712_is_cckrates_included(pnetwork->network.rates)) {
+               if (ht_cap)
                        snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bgn");
                else
                        snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bg");
        } else {
-               if (ht_cap == true)
+               if (ht_cap)
                        snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11gn");
                else
                        snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11g");
@@ -227,7 +200,7 @@ static inline char *translate_scan(struct _adapter *padapter,
        memcpy((u8 *)&cap, r8712_get_capability_from_ie(pnetwork->network.IEs),
                2);
        cap = le16_to_cpu(cap);
-       if (cap & (WLAN_CAPABILITY_IBSS|WLAN_CAPABILITY_BSS)) {
+       if (cap & (WLAN_CAPABILITY_IBSS | WLAN_CAPABILITY_BSS)) {
                if (cap & WLAN_CAPABILITY_BSS)
                        iwe.u.mode = (u32)IW_MODE_MASTER;
                else
@@ -270,9 +243,9 @@ static inline char *translate_scan(struct _adapter *padapter,
        iwe.u.bitrate.disabled = 0;
        iwe.u.bitrate.value = 0;
        i = 0;
-       while (pnetwork->network.SupportedRates[i] != 0) {
+       while (pnetwork->network.rates[i] != 0) {
                /* Bit rate given in 500 kb/s units */
-               iwe.u.bitrate.value = (pnetwork->network.SupportedRates[i++] &
+               iwe.u.bitrate.value = (pnetwork->network.rates[i++] &
                                      0x7F) * 500000;
                current_val = iwe_stream_add_value(info, start, current_val,
                              stop, &iwe, IW_EV_PARAM_LEN);
@@ -338,7 +311,7 @@ static inline char *translate_scan(struct _adapter *padapter,
 
                if (r8712_get_wps_ie(pnetwork->network.IEs,
                    pnetwork->network.IELength,
-                   wps_ie, &wps_ielen) == true) {
+                   wps_ie, &wps_ielen)) {
                        if (wps_ielen > 2) {
                                iwe.cmd = IWEVGENIE;
                                iwe.u.data.length = (u16)wps_ielen;
@@ -384,8 +357,9 @@ static int wpa_set_auth_algs(struct net_device *dev, u32 value)
                                                 Ndis802_11AuthModeOpen;
                        padapter->securitypriv.AuthAlgrthm = 0;
                }
-       } else
+       } else {
                ret = -EINVAL;
+       }
        return ret;
 }
 
@@ -409,8 +383,9 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
                        /* for large key indices, set the default (0) */
                        param->u.crypt.idx = 0;
                }
-       } else
+       } else {
                return -EINVAL;
+       }
        if (strcmp(param->u.crypt.alg, "WEP") == 0) {
                netdev_info(dev, "r8712u: %s: crypt.alg = WEP\n", __func__);
                padapter->securitypriv.ndisencryptstatus =
@@ -439,8 +414,9 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
                                padapter->securitypriv.XGrpPrivacy =
                                         _WEP104_;
                        }
-               } else
+               } else {
                        return -EINVAL;
+               }
                pwep->KeyIndex = wep_key_idx;
                pwep->KeyIndex |= 0x80000000;
                memcpy(pwep->KeyMaterial, param->u.crypt.key, pwep->KeyLength);
@@ -471,7 +447,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
                struct sta_priv *pstapriv = &padapter->stapriv;
 
                if (check_fwstate(pmlmepriv, WIFI_STATION_STATE |
-                   WIFI_MP_STATE) == true) { /* sta mode */
+                   WIFI_MP_STATE)) { /* sta mode */
                        psta = r8712_get_stainfo(pstapriv,
                                                 get_bssid(pmlmepriv));
                        if (psta) {
@@ -600,10 +576,10 @@ static int r871x_set_wpa_ie(struct _adapter *padapter, char *pie,
                                eid = buf[cnt];
 
                                if ((eid == _VENDOR_SPECIFIC_IE_) &&
-                                   (!memcmp(&buf[cnt+2], wps_oui, 4))) {
+                                   (!memcmp(&buf[cnt + 2], wps_oui, 4))) {
                                        netdev_info(padapter->pnetdev, "r8712u: SET WPS_IE\n");
                                        padapter->securitypriv.wps_ie_len =
-                                           ((buf[cnt+1] + 2) <
+                                           ((buf[cnt + 1] + 2) <
                                            (MAX_WPA_IE_LEN << 2)) ?
                                            (buf[cnt + 1] + 2) :
                                            (MAX_WPA_IE_LEN << 2);
@@ -613,10 +589,11 @@ static int r871x_set_wpa_ie(struct _adapter *padapter, char *pie,
                                        padapter->securitypriv.wps_phase =
                                                                 true;
                                        netdev_info(padapter->pnetdev, "r8712u: SET WPS_IE, wps_phase==true\n");
-                                       cnt += buf[cnt+1]+2;
+                                       cnt += buf[cnt + 1] + 2;
                                        break;
-                               } else
+                               } else {
                                        cnt += buf[cnt + 1] + 2;
+                               }
                        }
                }
        }
@@ -634,41 +611,42 @@ static int r8711_wx_get_name(struct net_device *dev,
        char *p;
        u8 ht_cap = false;
        struct  mlme_priv       *pmlmepriv = &(padapter->mlmepriv);
-       struct ndis_wlan_bssid_ex  *pcur_bss = &pmlmepriv->cur_network.network;
-       NDIS_802_11_RATES_EX *prates = NULL;
+       struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
+       u8 *prates;
 
-       if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) ==
+       if (check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE) ==
            true) {
                /* parsing HT_CAP_IE */
                p = r8712_get_ie(&pcur_bss->IEs[12], _HT_CAPABILITY_IE_,
                                 &ht_ielen, pcur_bss->IELength - 12);
                if (p && ht_ielen > 0)
                        ht_cap = true;
-               prates = &pcur_bss->SupportedRates;
-               if (r8712_is_cckratesonly_included((u8 *)prates) == true) {
-                       if (ht_cap == true)
+               prates = pcur_bss->rates;
+               if (r8712_is_cckratesonly_included(prates)) {
+                       if (ht_cap)
                                snprintf(wrqu->name, IFNAMSIZ,
                                         "IEEE 802.11bn");
                        else
                                snprintf(wrqu->name, IFNAMSIZ,
                                         "IEEE 802.11b");
-               } else if ((r8712_is_cckrates_included((u8 *)prates)) == true) {
-                       if (ht_cap == true)
+               } else if (r8712_is_cckrates_included(prates)) {
+                       if (ht_cap)
                                snprintf(wrqu->name, IFNAMSIZ,
                                         "IEEE 802.11bgn");
                        else
                                snprintf(wrqu->name, IFNAMSIZ,
                                         "IEEE 802.11bg");
                } else {
-                       if (ht_cap == true)
+                       if (ht_cap)
                                snprintf(wrqu->name, IFNAMSIZ,
                                         "IEEE 802.11gn");
                        else
                                snprintf(wrqu->name, IFNAMSIZ,
                                         "IEEE 802.11g");
                }
-       } else
+       } else {
                snprintf(wrqu->name, IFNAMSIZ, "unassociated");
+       }
        return 0;
 }
 
@@ -702,14 +680,14 @@ static int r8711_wx_set_freq(struct net_device *dev,
                fwrq->m = c + 1;
        }
        /* Setting by channel number */
-       if ((fwrq->m > 14) || (fwrq->e > 0))
+       if ((fwrq->m > 14) || (fwrq->e > 0)) {
                rc = -EOPNOTSUPP;
-       else {
+       else {
                int channel = fwrq->m;
 
-               if ((channel < 1) || (channel > 14))
+               if ((channel < 1) || (channel > 14)) {
                        rc = -EINVAL;
-               else {
+               else {
                        /* Yes ! We can set it !!! */
                        padapter->registrypriv.channel = channel;
                }
@@ -723,11 +701,11 @@ static int r8711_wx_get_freq(struct net_device *dev,
 {
        struct _adapter *padapter = netdev_priv(dev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct ndis_wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
+       struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
 
-       if (check_fwstate(pmlmepriv, _FW_LINKED) == true) {
+       if (check_fwstate(pmlmepriv, _FW_LINKED)) {
                wrqu->freq.m = ieee80211_wlan_frequencies[
-                              pcur_bss->Configuration.DSConfig-1] * 100000;
+                              pcur_bss->Configuration.DSConfig - 1] * 100000;
                wrqu->freq.e = 1;
                wrqu->freq.i = pcur_bss->Configuration.DSConfig;
        } else {
@@ -774,12 +752,12 @@ static int r8711_wx_get_mode(struct net_device *dev, struct iw_request_info *a,
        struct _adapter *padapter = netdev_priv(dev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
 
-       if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true)
+       if (check_fwstate(pmlmepriv, WIFI_STATION_STATE))
                wrqu->mode = IW_MODE_INFRA;
        else if (check_fwstate(pmlmepriv,
-                WIFI_ADHOC_MASTER_STATE|WIFI_ADHOC_STATE) == true)
+                WIFI_ADHOC_MASTER_STATE | WIFI_ADHOC_STATE))
                wrqu->mode = IW_MODE_ADHOC;
-       else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true)
+       else if (check_fwstate(pmlmepriv, WIFI_AP_STATE))
                wrqu->mode = IW_MODE_MASTER;
        else
                wrqu->mode = IW_MODE_AUTO;
@@ -799,13 +777,13 @@ static int r871x_wx_set_pmkid(struct net_device *dev,
        int intReturn = false;
 
 /*
      There are the BSSID information in the bssid.sa_data array.
      If cmd is IW_PMKSA_FLUSH, it means the wpa_supplicant wants to clear
      all the PMKID information. If cmd is IW_PMKSA_ADD, it means the
      wpa_supplicant wants to add a PMKID/BSSID to driver.
      If cmd is IW_PMKSA_REMOVE, it means the wpa_supplicant wants to
      remove a PMKID/BSSID from driver.
-*/
*     There are the BSSID information in the bssid.sa_data array.
*     If cmd is IW_PMKSA_FLUSH, it means the wpa_supplicant wants to clear
*     all the PMKID information. If cmd is IW_PMKSA_ADD, it means the
*     wpa_supplicant wants to add a PMKID/BSSID to driver.
*     If cmd is IW_PMKSA_REMOVE, it means the wpa_supplicant wants to
*     remove a PMKID/BSSID from driver.
+ */
        if (pPMK == NULL)
                return -EINVAL;
        memcpy(strIssueBssid, pPMK->bssid.sa_data, ETH_ALEN);
@@ -813,15 +791,15 @@ static int r871x_wx_set_pmkid(struct net_device *dev,
        case IW_PMKSA_ADD:
                if (!memcmp(strIssueBssid, strZeroMacAddress, ETH_ALEN))
                        return intReturn;
-               else
-                       intReturn = true;
+               intReturn = true;
                blInserted = false;
                /* overwrite PMKID */
                for (j = 0; j < NUM_PMKID_CACHE; j++) {
                        if (!memcmp(psecuritypriv->PMKIDList[j].Bssid,
                            strIssueBssid, ETH_ALEN)) {
                                /* BSSID is matched, the same AP => rewrite
-                                * with new PMKID. */
+                                * with new PMKID.
+                                */
                                netdev_info(dev, "r8712u: %s: BSSID exists in the PMKList.\n",
                                            __func__);
                                memcpy(psecuritypriv->PMKIDList[j].PMKID,
@@ -853,7 +831,8 @@ static int r871x_wx_set_pmkid(struct net_device *dev,
                        if (!memcmp(psecuritypriv->PMKIDList[j].Bssid,
                            strIssueBssid, ETH_ALEN)) {
                                /* BSSID is matched, the same AP => Remove
-                                * this PMKID information and reset it. */
+                                * this PMKID information and reset it.
+                                */
                                eth_zero_addr(psecuritypriv->PMKIDList[j].Bssid);
                                psecuritypriv->PMKIDList[j].bUsed = false;
                                break;
@@ -912,7 +891,7 @@ static int r8711_wx_get_range(struct net_device *dev,
        range->max_qual.updated = 7; /* Updated all three */
        range->avg_qual.qual = 92; /* > 8% missed beacons is 'bad' */
        /* TODO: Find real 'good' to 'bad' threshold value for RSSI */
-       range->avg_qual.level = 20 + -98;
+       range->avg_qual.level = 0x100 - 78;
        range->avg_qual.noise = 0;
        range->avg_qual.updated = 7; /* Updated all three */
        range->num_bitrates = RATE_COUNT;
@@ -960,24 +939,24 @@ static int r871x_wx_set_priv(struct net_device *dev,
        if (IS_ERR(ext))
                return PTR_ERR(ext);
 
-       if (0 == strcasecmp(ext, "RSSI")) {
+       if (!strcasecmp(ext, "RSSI")) {
                /*Return received signal strength indicator in -db for */
                /* current AP */
                /*<ssid> Rssi xx */
                struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
                struct wlan_network *pcur_network = &pmlmepriv->cur_network;
                /*static u8 xxxx; */
-               if (check_fwstate(pmlmepriv, _FW_LINKED) == true) {
+               if (check_fwstate(pmlmepriv, _FW_LINKED)) {
                        sprintf(ext, "%s rssi %d",
                                pcur_network->network.Ssid.Ssid,
                                /*(xxxx=xxxx+10) */
-                               ((padapter->recvpriv.fw_rssi)>>1)-95
+                               ((padapter->recvpriv.fw_rssi) >> 1) - 95
                                /*pcur_network->network.Rssi */
                                );
                } else {
                        sprintf(ext, "OK");
                }
-       } else if (0 == strcasecmp(ext, "LINKSPEED")) {
+       } else if (!strcasecmp(ext, "LINKSPEED")) {
                /*Return link speed in MBPS */
                /*LinkSpeed xx */
                union iwreq_data wrqd;
@@ -985,30 +964,30 @@ static int r871x_wx_set_priv(struct net_device *dev,
                int mbps;
 
                ret_inner = r8711_wx_get_rate(dev, info, &wrqd, extra);
-               if (0 != ret_inner)
+               if (ret_inner != 0)
                        mbps = 0;
                else
                        mbps = wrqd.bitrate.value / 1000000;
                sprintf(ext, "LINKSPEED %d", mbps);
-       } else if (0 == strcasecmp(ext, "MACADDR")) {
+       } else if (!strcasecmp(ext, "MACADDR")) {
                /*Return mac address of the station */
                /* Macaddr = xx:xx:xx:xx:xx:xx */
                sprintf(ext, "MACADDR = %pM", dev->dev_addr);
-       } else if (0 == strcasecmp(ext, "SCAN-ACTIVE")) {
+       } else if (!strcasecmp(ext, "SCAN-ACTIVE")) {
                /*Set scan type to active */
                /*OK if successful */
                struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
 
                pmlmepriv->passive_mode = 1;
                sprintf(ext, "OK");
-       } else if (0 == strcasecmp(ext, "SCAN-PASSIVE")) {
+       } else if (!strcasecmp(ext, "SCAN-PASSIVE")) {
                /*Set scan type to passive */
                /*OK if successful */
                struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
 
                pmlmepriv->passive_mode = 0;
                sprintf(ext, "OK");
-       } else if (0 == strncmp(ext, "DCE-E", 5)) {
+       } else if (!strncmp(ext, "DCE-E", 5)) {
                /*Set scan type to passive */
                /*OK if successful */
                r8712_disconnectCtrlEx_cmd(padapter
@@ -1018,7 +997,7 @@ static int r871x_wx_set_priv(struct net_device *dev,
                        , 5000 /*u32 firstStageTO */
                );
                sprintf(ext, "OK");
-       } else if (0 == strncmp(ext, "DCE-D", 5)) {
+       } else if (!strncmp(ext, "DCE-D", 5)) {
                /*Set scan type to passive */
                /*OK if successfu */
                r8712_disconnectCtrlEx_cmd(padapter
@@ -1034,7 +1013,7 @@ static int r871x_wx_set_priv(struct net_device *dev,
                goto FREE_EXT;
        }
        if (copy_to_user(dwrq->pointer, ext,
-                               min(dwrq->length, (__u16)(strlen(ext)+1))))
+                               min(dwrq->length, (__u16)(strlen(ext) + 1))))
                ret = -EFAULT;
 
 FREE_EXT:
@@ -1071,9 +1050,9 @@ static int r8711_wx_set_wap(struct net_device *dev,
        struct wlan_network *pnetwork = NULL;
        enum NDIS_802_11_AUTHENTICATION_MODE    authmode;
 
-       if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true)
+       if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY))
                return -EBUSY;
-       if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true)
+       if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING))
                return ret;
        if (temp->sa_family != ARPHRD_ETHER)
                return -EINVAL;
@@ -1082,7 +1061,7 @@ static int r8711_wx_set_wap(struct net_device *dev,
        phead = &queue->queue;
        pmlmepriv->pscanned = phead->next;
        while (1) {
-               if (end_of_queue_search(phead, pmlmepriv->pscanned) == true)
+               if (end_of_queue_search(phead, pmlmepriv->pscanned))
                        break;
                pnetwork = LIST_CONTAINOR(pmlmepriv->pscanned,
                           struct wlan_network, list);
@@ -1096,9 +1075,9 @@ static int r8711_wx_set_wap(struct net_device *dev,
        }
        spin_unlock_irqrestore(&queue->lock, irqL);
        if (!ret) {
-               if (!r8712_set_802_11_authentication_mode(padapter, authmode))
+               if (!r8712_set_802_11_authentication_mode(padapter, authmode)) {
                        ret = -ENOMEM;
-               else {
+               else {
                        if (!r8712_set_802_11_bssid(padapter, temp->sa_data))
                                ret = -1;
                }
@@ -1112,7 +1091,7 @@ static int r8711_wx_get_wap(struct net_device *dev,
 {
        struct _adapter *padapter = netdev_priv(dev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct ndis_wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
+       struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
 
        wrqu->ap_addr.sa_family = ARPHRD_ETHER;
        if (check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE |
@@ -1164,17 +1143,17 @@ static int r8711_wx_set_scan(struct net_device *dev,
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        u8 status = true;
 
-       if (padapter->bDriverStopped == true) {
+       if (padapter->bDriverStopped) {
                netdev_info(dev, "In %s: bDriverStopped=%d\n",
                            __func__, padapter->bDriverStopped);
                return -1;
        }
-       if (padapter->bup == false)
+       if (!padapter->bup)
                return -ENETDOWN;
-       if (padapter->hw_init_completed == false)
+       if (!padapter->hw_init_completed)
                return -1;
-       if ((check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING)) ||
-           (pmlmepriv->sitesurveyctrl.traffic_busy == true))
+       if ((check_fwstate(pmlmepriv, _FW_UNDER_SURVEY | _FW_UNDER_LINKING)) ||
+           (pmlmepriv->sitesurveyctrl.traffic_busy))
                return 0;
        if (wrqu->data.length == sizeof(struct iw_scan_req)) {
                struct iw_scan_req *req = (struct iw_scan_req *)extra;
@@ -1191,16 +1170,18 @@ static int r8711_wx_set_scan(struct net_device *dev,
                        spin_lock_irqsave(&pmlmepriv->lock, irqL);
                        if ((check_fwstate(pmlmepriv, _FW_UNDER_SURVEY |
                             _FW_UNDER_LINKING)) ||
-                           (pmlmepriv->sitesurveyctrl.traffic_busy == true)) {
+                           (pmlmepriv->sitesurveyctrl.traffic_busy)) {
                                if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING))
                                        status = false;
-                       } else
+                       } else {
                                status = r8712_sitesurvey_cmd(padapter, &ssid);
+                       }
                        spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
                }
-       } else
+       } else {
                status = r8712_set_802_11_bssid_list_scan(padapter);
-       if (status == false)
+       }
+       if (!status)
                return -1;
        return 0;
 }
@@ -1221,7 +1202,8 @@ static int r8711_wx_get_scan(struct net_device *dev,
 
        if (padapter->bDriverStopped)
                return -EINVAL;
-       while (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING)) {
+       while (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY |
+                            _FW_UNDER_LINKING)) {
                msleep(30);
                cnt++;
                if (cnt > 100)
@@ -1231,7 +1213,7 @@ static int r8711_wx_get_scan(struct net_device *dev,
        phead = &queue->queue;
        plist = phead->next;
        while (1) {
-               if (end_of_queue_search(phead, plist) == true)
+               if (end_of_queue_search(phead, plist))
                        break;
                if ((stop - ev) < SCAN_ITEM_SIZE) {
                        ret = -E2BIG;
@@ -1328,10 +1310,10 @@ static int r8711_wx_get_essid(struct net_device *dev,
 {
        struct _adapter *padapter = netdev_priv(dev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct ndis_wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
+       struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
        u32 len, ret = 0;
 
-       if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE)) {
+       if (check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE)) {
                len = pcur_bss->Ssid.SsidLength;
                wrqu->essid.length = len;
                memcpy(extra, pcur_bss->Ssid.Ssid, len);
@@ -1406,8 +1388,9 @@ set_rate:
                        datarates[i] = mpdatarate[i];
                        if (fixed == 0)
                                break;
-               } else
+               } else {
                        datarates[i] = 0xff;
+               }
        }
        if (r8712_setdatarate_cmd(padapter, datarates) != _SUCCESS)
                ret = -ENOMEM;
@@ -1420,7 +1403,7 @@ static int r8711_wx_get_rate(struct net_device *dev,
 {
        struct _adapter *padapter = netdev_priv(dev);
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
-       struct ndis_wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
+       struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
        struct ieee80211_ht_cap *pht_capie;
        unsigned char rf_type = padapter->registrypriv.rf_config;
        int i;
@@ -1431,7 +1414,7 @@ static int r8711_wx_get_rate(struct net_device *dev,
        u16 mcs_rate = 0;
 
        i = 0;
-       if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE)) {
+       if (check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE)) {
                p = r8712_get_ie(&pcur_bss->IEs[12],
                                 _HT_CAPABILITY_IE_, &ht_ielen,
                    pcur_bss->IELength - 12);
@@ -1445,19 +1428,19 @@ static int r8711_wx_get_rate(struct net_device *dev,
                                    (IEEE80211_HT_CAP_SGI_20 |
                                    IEEE80211_HT_CAP_SGI_40)) ? 1 : 0;
                }
-               while ((pcur_bss->SupportedRates[i] != 0) &&
-                       (pcur_bss->SupportedRates[i] != 0xFF)) {
-                       rate = pcur_bss->SupportedRates[i] & 0x7F;
+               while ((pcur_bss->rates[i] != 0) &&
+                       (pcur_bss->rates[i] != 0xFF)) {
+                       rate = pcur_bss->rates[i] & 0x7F;
                        if (rate > max_rate)
                                max_rate = rate;
                        wrqu->bitrate.fixed = 0;        /* no auto select */
-                       wrqu->bitrate.value = rate*500000;
+                       wrqu->bitrate.value = rate * 500000;
                        i++;
                }
-               if (ht_cap == true) {
+               if (ht_cap) {
                        if (mcs_rate & 0x8000 /* MCS15 */
                                &&
-                               RTL8712_RF_2T2R == rf_type)
+                               rf_type == RTL8712_RF_2T2R)
                                max_rate = (bw_40MHz) ? ((short_GI) ? 300 :
                                            270) : ((short_GI) ? 144 : 130);
                        else /* default MCS7 */
@@ -1466,8 +1449,9 @@ static int r8711_wx_get_rate(struct net_device *dev,
                        max_rate *= 2; /* Mbps/2 */
                }
                wrqu->bitrate.value = max_rate * 500000;
-       } else
+       } else {
                return -ENOLINK;
+       }
        return 0;
 }
 
@@ -1488,9 +1472,9 @@ static int r8711_wx_set_frag(struct net_device *dev,
 {
        struct _adapter *padapter = netdev_priv(dev);
 
-       if (wrqu->frag.disabled)
+       if (wrqu->frag.disabled) {
                padapter->xmitpriv.frag_len = MAX_FRAG_THRESHOLD;
-       else {
+       else {
                if (wrqu->frag.value < MIN_FRAG_THRESHOLD ||
                    wrqu->frag.value > MAX_FRAG_THRESHOLD)
                        return -EINVAL;
@@ -1590,7 +1574,8 @@ static int r8711_wx_set_enc(struct net_device *dev,
        } else {
                wep.KeyLength = 0;
                if (keyindex_provided == 1) { /* set key_id only, no given
-                                              * KeyMaterial(erq->length==0).*/
+                                              * KeyMaterial(erq->length==0).
+                                              */
                        padapter->securitypriv.PrivacyKeyIndex = key;
                        switch (padapter->securitypriv.DefKeylen[key]) {
                        case 5:
@@ -1625,7 +1610,7 @@ static int r8711_wx_get_enc(struct net_device *dev,
        struct iw_point *erq = &(wrqu->encoding);
        struct  mlme_priv       *pmlmepriv = &(padapter->mlmepriv);
 
-       if (check_fwstate(pmlmepriv, _FW_LINKED) == false) {
+       if (!check_fwstate(pmlmepriv, _FW_LINKED)) {
                if (!check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) {
                        erq->length = 0;
                        erq->flags |= IW_ENCODE_DISABLED;
@@ -1814,8 +1799,7 @@ static int r871x_wx_set_enc_ext(struct net_device *dev,
        if (param == NULL)
                return -ENOMEM;
        param->cmd = IEEE_CMD_SET_ENCRYPTION;
-       memset(param->sta_addr, 0xff, ETH_ALEN);
-
+       eth_broadcast_addr(param->sta_addr);
        strncpy((char *)param->u.crypt.alg, alg_name, IEEE_CRYPT_ALG_NAME_LEN);
        if (pext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
                param->u.crypt.set_tx = 0;
@@ -1871,7 +1855,7 @@ static int r8711_wx_write32(struct net_device *dev,
        u32 data32;
 
        get_user(addr, (u32 __user *)wrqu->data.pointer);
-       data32 = ((u32)wrqu->data.length<<16) | (u32)wrqu->data.flags;
+       data32 = ((u32)wrqu->data.length << 16) | (u32)wrqu->data.flags;
        r8712_write32(padapter, addr, data32);
        return 0;
 }
@@ -1925,9 +1909,9 @@ static int r871x_mp_ioctl_hdl(struct net_device *dev,
                ret = -EINVAL;
                goto _r871x_mp_ioctl_hdl_exit;
        }
-       if (phandler->oid == 0 && phandler->handler)
+       if (phandler->oid == 0 && phandler->handler) {
                status = phandler->handler(&oid_par);
-       else if (phandler->handler) {
+       else if (phandler->handler) {
                oid_par.adapter_context = padapter;
                oid_par.oid = phandler->oid;
                oid_par.information_buf = poidparam->data;
@@ -1984,7 +1968,8 @@ static int r871x_get_ap_info(struct net_device *dev,
 
        if (padapter->bDriverStopped || (pdata == NULL))
                return -EINVAL;
-       while (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING)) {
+       while (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY |
+                            _FW_UNDER_LINKING)) {
                msleep(30);
                cnt++;
                if (cnt > 100)
@@ -1994,16 +1979,17 @@ static int r871x_get_ap_info(struct net_device *dev,
        if (pdata->length >= 32) {
                if (copy_from_user(data, pdata->pointer, 32))
                        return -EINVAL;
-       } else
+       } else {
                 return -EINVAL;
+       }
        spin_lock_irqsave(&(pmlmepriv->scanned_queue.lock), irqL);
        phead = &queue->queue;
        plist = phead->next;
        while (1) {
-               if (end_of_queue_search(phead, plist) == true)
+               if (end_of_queue_search(phead, plist))
                        break;
                pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list);
-               if (hwaddr_aton_i(data, bssid)) {
+               if (!mac_pton(data, bssid)) {
                        netdev_info(dev, "r8712u: Invalid BSSID '%s'.\n",
                                    (u8 *)data);
                        spin_unlock_irqrestore(&(pmlmepriv->scanned_queue.lock),
@@ -2011,16 +1997,16 @@ static int r871x_get_ap_info(struct net_device *dev,
                        return -EINVAL;
                }
                netdev_info(dev, "r8712u: BSSID:%pM\n", bssid);
-               if (!memcmp(bssid, pnetwork->network.MacAddress, ETH_ALEN)) {
+               if (ether_addr_equal(bssid, pnetwork->network.MacAddress)) {
                        /* BSSID match, then check if supporting wpa/wpa2 */
                        pbuf = r8712_get_wpa_ie(&pnetwork->network.IEs[12],
-                              &wpa_ielen, pnetwork->network.IELength-12);
+                              &wpa_ielen, pnetwork->network.IELength - 12);
                        if (pbuf && (wpa_ielen > 0)) {
                                pdata->flags = 1;
                                break;
                        }
                        pbuf = r8712_get_wpa2_ie(&pnetwork->network.IEs[12],
-                              &wpa_ielen, pnetwork->network.IELength-12);
+                              &wpa_ielen, pnetwork->network.IELength - 12);
                        if (pbuf && (wpa_ielen > 0)) {
                                pdata->flags = 2;
                                break;
@@ -2105,7 +2091,7 @@ static int wpa_set_param(struct net_device *dev, u8 name, u32 value)
        switch (name) {
        case IEEE_PARAM_WPA_ENABLED:
                padapter->securitypriv.AuthAlgrthm = 2; /* 802.1x */
-               switch ((value)&0xff) {
+               switch ((value) & 0xff) {
                case 1: /* WPA */
                        padapter->securitypriv.ndisauthtype =
                                Ndis802_11AuthModeWPAPSK; /* WPA_PSK */
@@ -2244,7 +2230,8 @@ static iw_handler r8711_handlers[] = {
        r8711_wx_set_wap,               /* SIOCSIWAP */
        r8711_wx_get_wap,               /* SIOCGIWAP */
        r871x_wx_set_mlme,              /* request MLME operation;
-                                        *  uses struct iw_mlme */
+                                        *  uses struct iw_mlme
+                                        */
        dummy,                          /* SIOCGIWAPLIST -- deprecated */
        r8711_wx_set_scan,              /* SIOCSIWSCAN */
        r8711_wx_get_scan,              /* SIOCGIWSCAN */