]> nv-tegra.nvidia Code Review - linux-3.10.git/blobdiff - drivers/net/wireless/sd8797/mlinux/moal_uap_wext.c
net: wireless: Update Marvell SD8797 SD8897 WLAN/BT driver
[linux-3.10.git] / drivers / net / wireless / sd8797 / mlinux / moal_uap_wext.c
index d50f399ced5c84bd90e6b96fab1609a39f70c4f7..7f5d0e931b9057b24fe97958b431bdbbec9227c6 100644 (file)
@@ -149,7 +149,7 @@ channel_to_frequency(t_u16 channel, t_u8 band)
        int i = 0;
 
        ENTER();
-       for (i = 0; i < sizeof(chan_to_freq) / sizeof(chan_to_freq_t); i++) {
+       for (i = 0; i < ARRAY_SIZE(chan_to_freq); i++) {
                if (channel == chan_to_freq[i].channel &&
                    band == chan_to_freq[i].band) {
                        LEAVE();
@@ -219,11 +219,10 @@ woal_get_wap(struct net_device *dev, struct iw_request_info *info,
 
        ENTER();
 
-       if (priv->bss_started) {
+       if (priv->bss_started)
                memcpy(awrq->sa_data, priv->current_addr, MLAN_MAC_ADDR_LENGTH);
-       } else {
+       else
                memset(awrq->sa_data, 0, MLAN_MAC_ADDR_LENGTH);
-       }
        awrq->sa_family = ARPHRD_ETHER;
 
        LEAVE();
@@ -358,10 +357,8 @@ woal_set_freq(struct net_device *dev, struct iw_request_info *info,
        }
 
 done:
-       if (sys_cfg)
-               kfree(sys_cfg);
-       if (ap_cfg)
-               kfree(ap_cfg);
+       kfree(sys_cfg);
+       kfree(ap_cfg);
        LEAVE();
        return ret;
 }
@@ -395,10 +392,11 @@ woal_get_freq(struct net_device *dev, struct iw_request_info *info,
                LEAVE();
                return -EFAULT;
        }
+
        band = ap_cfg.band_cfg & BAND_CONFIG_5GHZ;
+       fwrq->m = (long)channel_to_frequency(ap_cfg.channel, band);
        fwrq->i = (long)ap_cfg.channel;
-       fwrq->m = (long)(channel_to_frequency(ap_cfg.channel, band)) * 100000;
-       fwrq->e = 1;
+       fwrq->e = 6;
 
        LEAVE();
        return ret;
@@ -544,10 +542,17 @@ woal_set_encode(struct net_device *dev, struct iw_request_info *info,
                                pkey = &sys_cfg->wep_cfg.key2;
                        if (ap_cfg->wep_cfg.key3.is_default)
                                pkey = &sys_cfg->wep_cfg.key3;
+                       else {  /* Something wrong, select first key as default
+                                */
+                               PRINTM(MERROR,
+                                      "No default key set! Selecting first key.\n");
+                               pkey = &sys_cfg->wep_cfg.key0;
+                       }
                }
 
                sys_cfg->protocol = PROTOCOL_STATIC_WEP;
-               memcpy(pkey->key, extra, dwrq->length);
+               if (extra)
+                       memcpy(pkey->key, extra, dwrq->length);
                /* Set the length */
                if (dwrq->length > MIN_WEP_KEY_SIZE)
                        pkey->length = MAX_WEP_KEY_SIZE;
@@ -621,10 +626,8 @@ woal_set_encode(struct net_device *dev, struct iw_request_info *info,
        }
 
 done:
-       if (sys_cfg)
-               kfree(sys_cfg);
-       if (ap_cfg)
-               kfree(ap_cfg);
+       kfree(sys_cfg);
+       kfree(ap_cfg);
        LEAVE();
        return ret;
 }
@@ -998,8 +1001,7 @@ woal_set_encode_ext(struct net_device *dev,
        }
 
 done:
-       if (req)
-               kfree(req);
+       kfree(req);
        LEAVE();
        return ret;
 }
@@ -1053,8 +1055,9 @@ woal_set_mlme(struct net_device *dev,
        memset(sta_addr, 0, ETH_ALEN);
        if ((mlme->cmd == IW_MLME_DEAUTH) || (mlme->cmd == IW_MLME_DISASSOC)) {
                memcpy(sta_addr, (t_u8 *) mlme->addr.sa_data, ETH_ALEN);
-               PRINTM(MIOCTL, "Deauth station: " MACSTR ", "
-                      "reason=%d\n", MAC2STR(sta_addr), mlme->reason_code);
+               PRINTM(MIOCTL,
+                      "Deauth station: " MACSTR ", reason=%d\n",
+                      MAC2STR(sta_addr), mlme->reason_code);
 
                /* FIXME: For flushing all stations we need to use zero MAC,
                   but right now the FW does not support this. So, manually
@@ -1087,10 +1090,8 @@ woal_set_mlme(struct net_device *dev,
                        }
                        memcpy(sta_list, &pinfo->param.sta_list,
                               sizeof(mlan_ds_sta_list));
-                       if (req) {
-                               kfree(req);
-                               req = NULL;
-                       }
+                       kfree(req);
+                       req = NULL;
                }
                req = woal_alloc_mlan_ioctl_req(sizeof(mlan_ds_bss));
                if (req == NULL) {
@@ -1130,11 +1131,8 @@ woal_set_mlme(struct net_device *dev,
        }
 
 done:
-       if (req)
-               kfree(req);
-       if (sta_list)
-               kfree(sta_list);
-
+       kfree(req);
+       kfree(sta_list);
        LEAVE();
        return ret;
 }
@@ -1165,9 +1163,15 @@ woal_set_auth(struct net_device *dev, struct iw_request_info *info,
        switch (vwrq->flags & IW_AUTH_INDEX) {
        case IW_AUTH_CIPHER_PAIRWISE:
                /* Rest are not supported now */
-               if (vwrq->value & IW_AUTH_CIPHER_NONE) ;
-               else if (vwrq->value & IW_AUTH_CIPHER_WEP40) ;
-               else if (vwrq->value & IW_AUTH_CIPHER_WEP104) ;
+               if (vwrq->value & IW_AUTH_CIPHER_NONE)
+                       /* XXX Do not delete no-operation line */
+                       ;
+               else if (vwrq->value & IW_AUTH_CIPHER_WEP40)
+                       /* XXX Do not delete no-operation line */
+                       ;
+               else if (vwrq->value & IW_AUTH_CIPHER_WEP104)
+                       /* XXX Do not delete no-operation line */
+                       ;
                else if (vwrq->value == IW_AUTH_CIPHER_TKIP) {
                        sys_cfg.wpa_cfg.pairwise_cipher_wpa = CIPHER_TKIP;
                        sys_cfg.wpa_cfg.pairwise_cipher_wpa2 = CIPHER_TKIP;
@@ -1196,9 +1200,15 @@ woal_set_auth(struct net_device *dev, struct iw_request_info *info,
                break;
        case IW_AUTH_CIPHER_GROUP:
                /* Rest are not supported now */
-               if (vwrq->value & IW_AUTH_CIPHER_NONE) ;
-               else if (vwrq->value & IW_AUTH_CIPHER_WEP40) ;
-               else if (vwrq->value & IW_AUTH_CIPHER_WEP104) ;
+               if (vwrq->value & IW_AUTH_CIPHER_NONE)
+                       /* XXX Do not delete no-operation line */
+                       ;
+               else if (vwrq->value & IW_AUTH_CIPHER_WEP40)
+                       /* XXX Do not delete no-operation line */
+                       ;
+               else if (vwrq->value & IW_AUTH_CIPHER_WEP104)
+                       /* XXX Do not delete no-operation line */
+                       ;
                else if (vwrq->value & IW_AUTH_CIPHER_TKIP) {
                        sys_cfg.wpa_cfg.group_cipher = CIPHER_TKIP;
                        priv->group_cipher = CIPHER_TKIP;
@@ -1388,7 +1398,7 @@ woal_get_auth(struct net_device *dev, struct iw_request_info *info,
  *  Infra       G(12)           A(8)    B(4)    G(12)
  *  Adhoc       A+B(12)         A(8)    B(4)    B(4)
  *      non-MULTI_BANDS:
-                                        b       b/g
+                                                                               b       b/g
  *  Infra                               B(4)    G(12)
  *  Adhoc                               B(4)    B(4)
  */
@@ -1748,10 +1758,9 @@ static const iw_handler woal_private_handler[] = {
 
 /** wlan_handler_def */
 struct iw_handler_def woal_uap_handler_def = {
-num_standard:sizeof(woal_handler) / sizeof(iw_handler),
-num_private:sizeof(woal_private_handler) / sizeof(iw_handler),
-num_private_args:sizeof(woal_uap_priv_args) /
-               sizeof(struct iw_priv_args),
+num_standard:ARRAY_SIZE(woal_handler),
+num_private:ARRAY_SIZE(woal_private_handler),
+num_private_args:ARRAY_SIZE(woal_uap_priv_args),
 standard:(iw_handler *) woal_handler,
 private:(iw_handler *) woal_private_handler,
 private_args:(struct iw_priv_args *)woal_uap_priv_args,