staging: rtl8192e: Remove rtllib_network::last_associate
[pandora-kernel.git] / drivers / staging / rtl8192e / rtllib_rx.c
index 58c9cf2..48a188a 100644 (file)
@@ -45,8 +45,9 @@
 #include "dot11d.h"
 
 static inline void rtllib_monitor_rx(struct rtllib_device *ieee,
-                               struct sk_buff *skb, struct rtllib_rx_stats *rx_status,
-                               size_t hdr_length)
+                                    struct sk_buff *skb,
+                                    struct rtllib_rx_stats *rx_status,
+                                    size_t hdr_length)
 {
        skb->dev = ieee->dev;
        skb_reset_mac_header(skb);
@@ -101,7 +102,8 @@ rtllib_frag_cache_get(struct rtllib_device *ieee,
        struct rtllib_hdr_4addrqos *hdr_4addrqos;
        u8 tid;
 
-       if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) && RTLLIB_QOS_HAS_SEQ(fc)) {
+       if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) &&
+           RTLLIB_QOS_HAS_SEQ(fc)) {
                hdr_4addrqos = (struct rtllib_hdr_4addrqos *)hdr;
                tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID;
                tid = UP2AC(tid);
@@ -123,7 +125,8 @@ rtllib_frag_cache_get(struct rtllib_device *ieee,
                                    2 /* alignment */ +
                                    8 /* WEP */ +
                                    ETH_ALEN /* WDS */ +
-                                   (RTLLIB_QOS_HAS_SEQ(fc) ? 2 : 0) /* QOS Control */);
+                                   /* QOS Control */
+                                   (RTLLIB_QOS_HAS_SEQ(fc) ? 2 : 0));
                if (skb == NULL)
                        return NULL;
 
@@ -169,7 +172,8 @@ static int rtllib_frag_cache_invalidate(struct rtllib_device *ieee,
        struct rtllib_hdr_4addrqos *hdr_4addrqos;
        u8 tid;
 
-       if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) && RTLLIB_QOS_HAS_SEQ(fc)) {
+       if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) &&
+           RTLLIB_QOS_HAS_SEQ(fc)) {
                hdr_4addrqos = (struct rtllib_hdr_4addrqos *)hdr;
                tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID;
                tid = UP2AC(tid);
@@ -291,7 +295,8 @@ rtllib_rx_frame_decrypt(struct rtllib_device *ieee, struct sk_buff *skb,
                return 0;
 
        if (ieee->hwsec_active) {
-               struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
+               struct cb_desc *tcb_desc = (struct cb_desc *)
+                                               (skb->cb + MAX_DEV_ADDR_SIZE);
 
                tcb_desc->bHwSec = 1;
 
@@ -331,7 +336,8 @@ rtllib_rx_frame_decrypt_msdu(struct rtllib_device *ieee, struct sk_buff *skb,
        if (crypt == NULL || crypt->ops->decrypt_msdu == NULL)
                return 0;
        if (ieee->hwsec_active) {
-               struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
+               struct cb_desc *tcb_desc = (struct cb_desc *)
+                                               (skb->cb + MAX_DEV_ADDR_SIZE);
 
                tcb_desc->bHwSec = 1;
 
@@ -346,8 +352,9 @@ rtllib_rx_frame_decrypt_msdu(struct rtllib_device *ieee, struct sk_buff *skb,
        res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv);
        atomic_dec(&crypt->refcnt);
        if (res < 0) {
-               printk(KERN_DEBUG "%s: MSDU decryption/MIC verification failed (SA= %pM keyidx=%d)\n",
-                      ieee->dev->name, hdr->addr2, keyidx);
+               netdev_dbg(ieee->dev,
+                          "MSDU decryption/MIC verification failed (SA= %pM keyidx=%d)\n",
+                          hdr->addr2, keyidx);
                return -1;
        }
 
@@ -370,7 +377,8 @@ static int is_duplicate_packet(struct rtllib_device *ieee,
        struct rtllib_hdr_4addrqos *hdr_4addrqos;
        u8 tid;
 
-       if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) && RTLLIB_QOS_HAS_SEQ(fc)) {
+       if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) &&
+           RTLLIB_QOS_HAS_SEQ(fc)) {
                hdr_4addrqos = (struct rtllib_hdr_4addrqos *)header;
                tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID;
                tid = UP2AC(tid);
@@ -398,7 +406,8 @@ static int is_duplicate_packet(struct rtllib_device *ieee,
                                break;
                }
                if (p == &ieee->ibss_mac_hash[index]) {
-                       entry = kmalloc(sizeof(struct ieee_ibss_seq), GFP_ATOMIC);
+                       entry = kmalloc(sizeof(struct ieee_ibss_seq),
+                                       GFP_ATOMIC);
                        if (!entry)
                                return 0;
 
@@ -468,7 +477,8 @@ static bool AddReorderEntry(struct rx_ts_record *pTS,
        return true;
 }
 
-void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb **prxbIndicateArray, u8 index)
+void rtllib_indicate_packets(struct rtllib_device *ieee,
+                            struct rtllib_rxb **prxbIndicateArray, u8 index)
 {
        struct net_device_stats *stats = &ieee->stats;
        u8 i = 0, j = 0;
@@ -483,9 +493,12 @@ void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb **prx
                /* convert hdr + possible LLC headers into Ethernet header */
                        ethertype = (sub_skb->data[6] << 8) | sub_skb->data[7];
                        if (sub_skb->len >= 8 &&
-                           ((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 &&
-                           ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
-                           memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) {
+                           ((memcmp(sub_skb->data, rfc1042_header,
+                                    SNAP_SIZE) == 0 &&
+                             ethertype != ETH_P_AARP &&
+                             ethertype != ETH_P_IPX) ||
+                           memcmp(sub_skb->data, bridge_tunnel_header,
+                                  SNAP_SIZE) == 0)) {
                                /* remove RFC1042 or Bridge-Tunnel encapsulation
                                 * and replace EtherType
                                 */
@@ -507,11 +520,13 @@ void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb **prx
                                stats->rx_bytes += sub_skb->len;
 
                                memset(sub_skb->cb, 0, sizeof(sub_skb->cb));
-                               sub_skb->protocol = eth_type_trans(sub_skb, ieee->dev);
+                               sub_skb->protocol = eth_type_trans(sub_skb,
+                                                                  ieee->dev);
                                sub_skb->dev = ieee->dev;
                                sub_skb->dev->stats.rx_packets++;
                                sub_skb->dev->stats.rx_bytes += sub_skb->len;
-                               sub_skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */
+                               /* 802.11 crc not sufficient */
+                               sub_skb->ip_summed = CHECKSUM_NONE;
                                ieee->last_rx_ps_time = jiffies;
                                netif_rx(sub_skb);
                        }
@@ -521,7 +536,8 @@ void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb **prx
        }
 }
 
-void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee,   struct rx_ts_record *pTS)
+void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee,
+                                struct rx_ts_record *pTS)
 {
        struct rx_reorder_entry *pRxReorderEntry;
        u8 RfdCnt = 0;
@@ -535,7 +551,9 @@ void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee,        struct rx_ts_record
                        break;
                }
 
-               pRxReorderEntry = (struct rx_reorder_entry *)list_entry(pTS->RxPendingPktList.prev, struct rx_reorder_entry, List);
+               pRxReorderEntry = (struct rx_reorder_entry *)
+                                 list_entry(pTS->RxPendingPktList.prev,
+                                            struct rx_reorder_entry, List);
                netdev_dbg(ieee->dev, "%s(): Indicate SeqNum %d!\n", __func__,
                           pRxReorderEntry->SeqNum);
                list_del_init(&pRxReorderEntry->List);
@@ -543,7 +561,8 @@ void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee,        struct rx_ts_record
                ieee->RfdArray[RfdCnt] = pRxReorderEntry->prxb;
 
                RfdCnt = RfdCnt + 1;
-               list_add_tail(&pRxReorderEntry->List, &ieee->RxReorder_Unused_List);
+               list_add_tail(&pRxReorderEntry->List,
+                             &ieee->RxReorder_Unused_List);
        }
        rtllib_indicate_packets(ieee, ieee->RfdArray, RfdCnt);
 
@@ -602,7 +621,8 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee,
                if (SeqNum >= (WinSize - 1))
                        pTS->RxIndicateSeq = SeqNum + 1 - WinSize;
                else
-                       pTS->RxIndicateSeq = 4095 - (WinSize - (SeqNum + 1)) + 1;
+                       pTS->RxIndicateSeq = 4095 -
+                                            (WinSize - (SeqNum + 1)) + 1;
                netdev_dbg(ieee->dev,
                           "Window Shift! IndicateSeq: %d, NewSeq: %d\n",
                           pTS->RxIndicateSeq, SeqNum);
@@ -620,7 +640,8 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee,
         */
        if (bMatchWinStart) {
                /* Current packet is going to be indicated.*/
-               netdev_dbg(ieee->dev, "Packets indication! IndicateSeq: %d, NewSeq: %d\n",
+               netdev_dbg(ieee->dev,
+                          "Packets indication! IndicateSeq: %d, NewSeq: %d\n",
                           pTS->RxIndicateSeq, SeqNum);
                ieee->prxbIndicateArray[0] = prxb;
                index = 1;
@@ -632,24 +653,26 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee,
                                        struct rx_reorder_entry, List);
                        list_del_init(&pReorderEntry->List);
 
-                       /* Make a reorder entry and insert into a the packet list.*/
+                       /* Make a reorder entry and insert
+                        * into a the packet list.
+                        */
                        pReorderEntry->SeqNum = SeqNum;
                        pReorderEntry->prxb = prxb;
 
                        if (!AddReorderEntry(pTS, pReorderEntry)) {
+                               int i;
+
                                netdev_dbg(ieee->dev,
                                           "%s(): Duplicate packet is dropped. IndicateSeq: %d, NewSeq: %d\n",
                                           __func__, pTS->RxIndicateSeq,
                                           SeqNum);
                                list_add_tail(&pReorderEntry->List,
-                                             &ieee->RxReorder_Unused_List); {
-                                       int i;
+                                             &ieee->RxReorder_Unused_List);
 
-                                       for (i = 0; i < prxb->nr_subframes; i++)
-                                               dev_kfree_skb(prxb->subframes[i]);
-                                       kfree(prxb);
-                                       prxb = NULL;
-                               }
+                               for (i = 0; i < prxb->nr_subframes; i++)
+                                       dev_kfree_skb(prxb->subframes[i]);
+                               kfree(prxb);
+                               prxb = NULL;
                        } else {
                                netdev_dbg(ieee->dev,
                                           "Pkt insert into struct buffer. IndicateSeq: %d, NewSeq: %d\n",
@@ -680,10 +703,12 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee,
                netdev_dbg(ieee->dev, "%s(): start RREORDER indicate\n",
                           __func__);
 
-               pReorderEntry = (struct rx_reorder_entry *)list_entry(pTS->RxPendingPktList.prev,
-                                struct rx_reorder_entry, List);
+               pReorderEntry = (struct rx_reorder_entry *)
+                                       list_entry(pTS->RxPendingPktList.prev,
+                                                  struct rx_reorder_entry,
+                                                  List);
                if (SN_LESS(pReorderEntry->SeqNum, pTS->RxIndicateSeq) ||
-                               SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq)) {
+                   SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq)) {
                        /* This protect struct buffer from overflow. */
                        if (index >= REORDER_WIN_SIZE) {
                                netdev_err(ieee->dev,
@@ -696,7 +721,8 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee,
                        list_del_init(&pReorderEntry->List);
 
                        if (SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq))
-                               pTS->RxIndicateSeq = (pTS->RxIndicateSeq + 1) % 4096;
+                               pTS->RxIndicateSeq = (pTS->RxIndicateSeq + 1) %
+                                                    4096;
 
                        ieee->prxbIndicateArray[index] = pReorderEntry->prxb;
                        netdev_dbg(ieee->dev, "%s(): Indicate SeqNum %d!\n",
@@ -911,7 +937,8 @@ static int rtllib_rx_check_duplicate(struct rtllib_device *ieee,
                !ieee->current_network.qos_data.active ||
                !IsDataFrame(skb->data) ||
                IsLegacyDataFrame(skb->data)) {
-               if (!((type == RTLLIB_FTYPE_MGMT) && (stype == RTLLIB_STYPE_BEACON))) {
+               if (!((type == RTLLIB_FTYPE_MGMT) &&
+                     (stype == RTLLIB_STYPE_BEACON))) {
                        if (is_duplicate_packet(ieee, hdr))
                                return -1;
                }
@@ -1014,7 +1041,8 @@ static int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc,
 
                /* {broad,multi}cast packets to our BSS go through */
                if (is_multicast_ether_addr(dst)) {
-                       if (memcmp(bssid, ieee->current_network.bssid, ETH_ALEN))
+                       if (memcmp(bssid, ieee->current_network.bssid,
+                                  ETH_ALEN))
                                return -1;
                }
        }
@@ -1192,7 +1220,8 @@ static int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb,
        return 0;
 }
 
-static void rtllib_rx_check_leave_lps(struct rtllib_device *ieee, u8 unicast, u8 nr_subframes)
+static void rtllib_rx_check_leave_lps(struct rtllib_device *ieee, u8 unicast,
+                                     u8 nr_subframes)
 {
        if (unicast) {
 
@@ -1227,14 +1256,16 @@ static void rtllib_rx_indicate_pkt_legacy(struct rtllib_device *ieee,
                struct sk_buff *sub_skb = rxb->subframes[i];
 
                if (sub_skb) {
-                       /* convert hdr + possible LLC headers into Ethernet header */
+                       /* convert hdr + possible LLC headers
+                        * into Ethernet header
+                        */
                        ethertype = (sub_skb->data[6] << 8) | sub_skb->data[7];
                        if (sub_skb->len >= 8 &&
                                ((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 &&
                                ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
                                memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) {
-                               /* remove RFC1042 or Bridge-Tunnel encapsulation and
-                                * replace EtherType
+                               /* remove RFC1042 or Bridge-Tunnel encapsulation
+                                * and replace EtherType
                                 */
                                skb_pull(sub_skb, SNAP_SIZE);
                                ether_addr_copy(skb_push(sub_skb, ETH_ALEN),
@@ -1243,7 +1274,9 @@ static void rtllib_rx_indicate_pkt_legacy(struct rtllib_device *ieee,
                                                dst);
                        } else {
                                u16 len;
-                               /* Leave Ethernet header part of hdr and full payload */
+                               /* Leave Ethernet header part of hdr
+                                * and full payload
+                                */
                                len = sub_skb->len;
                                memcpy(skb_push(sub_skb, 2), &len, 2);
                                ether_addr_copy(skb_push(sub_skb, ETH_ALEN),
@@ -1264,7 +1297,8 @@ static void rtllib_rx_indicate_pkt_legacy(struct rtllib_device *ieee,
                        sub_skb->dev = dev;
                        sub_skb->dev->stats.rx_packets++;
                        sub_skb->dev->stats.rx_bytes += sub_skb->len;
-                       sub_skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */
+                       /* 802.11 crc not sufficient */
+                       sub_skb->ip_summed = CHECKSUM_NONE;
                        netif_rx(sub_skb);
                }
        }
@@ -1309,7 +1343,8 @@ static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb,
        /*Filter pkt has too small length */
        hdrlen = rtllib_rx_get_hdrlen(ieee, skb, rx_stats);
        if (skb->len < hdrlen) {
-               netdev_info(dev, "%s():ERR!!! skb->len is smaller than hdrlen\n",
+               netdev_info(dev,
+                           "%s():ERR!!! skb->len is smaller than hdrlen\n",
                            __func__);
                goto rx_dropped;
        }
@@ -1354,10 +1389,13 @@ static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb,
                goto rx_dropped;
 
        /* Send pspoll based on moredata */
-       if ((ieee->iw_mode == IW_MODE_INFRA)  && (ieee->sta_sleep == LPS_IS_SLEEP)
-               && (ieee->polling) && (!bToOtherSTA)) {
+       if ((ieee->iw_mode == IW_MODE_INFRA)  &&
+           (ieee->sta_sleep == LPS_IS_SLEEP) &&
+           (ieee->polling) && (!bToOtherSTA)) {
                if (WLAN_FC_MORE_DATA(fc)) {
-                       /* more data bit is set, let's request a new frame from the AP */
+                       /* more data bit is set, let's request a new frame
+                        * from the AP
+                        */
                        rtllib_sta_ps_send_pspoll_frame(ieee);
                } else {
                        ieee->polling =  false;
@@ -1383,7 +1421,8 @@ static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb,
                && (!bToOtherSTA)) {
                TID = Frame_QoSTID(skb->data);
                SeqNum = WLAN_GET_SEQ_SEQ(sc);
-               GetTs(ieee, (struct ts_common_info **) &pTS, hdr->addr2, TID, RX_DIR, true);
+               GetTs(ieee, (struct ts_common_info **) &pTS, hdr->addr2, TID,
+                     RX_DIR, true);
                if (TID != 0 && TID != 3)
                        ieee->bis_any_nonbepkts = true;
        }
@@ -1398,7 +1437,9 @@ static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb,
        /* to parse amsdu packets */
        /* qos data packets & reserved bit is 1 */
        if (parse_subframe(ieee, skb, rx_stats, rxb, src, dst) == 0) {
-               /* only to free rxb, and not submit the packets to upper layer */
+               /* only to free rxb, and not submit the packets
+                * to upper layer
+                */
                for (i = 0; i < rxb->nr_subframes; i++)
                        dev_kfree_skb(rxb->subframes[i]);
                kfree(rxb);
@@ -1420,7 +1461,8 @@ static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb,
        }
 
        /* Indicate packets to upper layer or Rx Reorder */
-       if (ieee->pHTInfo->bCurRxReorderEnable == false || pTS == NULL || bToOtherSTA)
+       if (ieee->pHTInfo->bCurRxReorderEnable == false || pTS == NULL ||
+           bToOtherSTA)
                rtllib_rx_indicate_pkt_legacy(ieee, rx_stats, rxb, dst, src);
        else
                RxReorderIndicatePacket(ieee, rxb, pTS, SeqNum);
@@ -1549,8 +1591,9 @@ static int rtllib_verify_qos_info(struct rtllib_qos_information_element
 
 /* Parse a QoS parameter element */
 static int rtllib_read_qos_param_element(struct rtllib_qos_parameter_info
-                                           *element_param, struct rtllib_info_element
-                                           *info_element)
+                                                       *element_param,
+                                        struct rtllib_info_element
+                                                       *info_element)
 {
        int ret = 0;
        u16 size = sizeof(struct rtllib_qos_parameter_info) - 2;
@@ -1572,10 +1615,10 @@ static int rtllib_read_qos_param_element(struct rtllib_qos_parameter_info
 }
 
 /* Parse a QoS information element */
-static int rtllib_read_qos_info_element(struct
-                                          rtllib_qos_information_element
-                                          *element_info, struct rtllib_info_element
-                                          *info_element)
+static int rtllib_read_qos_info_element(struct rtllib_qos_information_element
+                                                       *element_info,
+                                       struct rtllib_info_element
+                                                       *info_element)
 {
        int ret = 0;
        u16 size = sizeof(struct rtllib_qos_information_element) - 2;
@@ -1585,7 +1628,8 @@ static int rtllib_read_qos_info_element(struct
        if (info_element == NULL)
                return -1;
 
-       if ((info_element->id == QOS_ELEMENT_ID) && (info_element->len == size)) {
+       if ((info_element->id == QOS_ELEMENT_ID) &&
+           (info_element->len == size)) {
                memcpy(element_info->qui, info_element->data,
                       info_element->len);
                element_info->elementID = info_element->id;
@@ -1595,14 +1639,14 @@ static int rtllib_read_qos_info_element(struct
 
        if (ret == 0)
                ret = rtllib_verify_qos_info(element_info,
-                                               QOS_OUI_INFO_SUB_TYPE);
+                                            QOS_OUI_INFO_SUB_TYPE);
        return ret;
 }
 
 
 /* Write QoS parameters from the ac parameters. */
 static int rtllib_qos_convert_ac_to_parameters(struct rtllib_qos_parameter_info *param_elm,
-               struct rtllib_qos_data *qos_data)
+                                              struct rtllib_qos_data *qos_data)
 {
        struct rtllib_qos_ac_parameter *ac_params;
        struct rtllib_qos_parameters *qos_param = &(qos_data->parameters);
@@ -1646,11 +1690,13 @@ static int rtllib_qos_convert_ac_to_parameters(struct rtllib_qos_parameter_info
                qos_param->aifs[aci] = (ac_params->aci_aifsn) & 0x0f;
 
                /* WMM spec P.11: The minimum value for AIFSN shall be 2 */
-               qos_param->aifs[aci] = (qos_param->aifs[aci] < 2) ? 2 : qos_param->aifs[aci];
+               qos_param->aifs[aci] = max_t(u8, qos_param->aifs[aci], 2);
 
-               qos_param->cw_min[aci] = cpu_to_le16(ac_params->ecw_min_max & 0x0F);
+               qos_param->cw_min[aci] = cpu_to_le16(ac_params->ecw_min_max &
+                                                    0x0F);
 
-               qos_param->cw_max[aci] = cpu_to_le16((ac_params->ecw_min_max & 0xF0) >> 4);
+               qos_param->cw_max[aci] = cpu_to_le16((ac_params->ecw_min_max &
+                                                     0xF0) >> 4);
 
                qos_param->flag[aci] =
                    (ac_params->aci_aifsn & 0x10) ? 0x01 : 0x00;
@@ -1741,15 +1787,19 @@ static inline void rtllib_extract_country_ie(
 {
        if (IS_DOT11D_ENABLE(ieee)) {
                if (info_element->len != 0) {
-                       memcpy(network->CountryIeBuf, info_element->data, info_element->len);
+                       memcpy(network->CountryIeBuf, info_element->data,
+                              info_element->len);
                        network->CountryIeLen = info_element->len;
 
                        if (!IS_COUNTRY_IE_VALID(ieee)) {
-                               if (rtllib_act_scanning(ieee, false) && ieee->FirstIe_InScan)
+                               if (rtllib_act_scanning(ieee, false) &&
+                                   ieee->FirstIe_InScan)
                                        netdev_info(ieee->dev,
                                                    "Received beacon ContryIE, SSID: <%s>\n",
                                                    network->ssid);
-                               Dot11d_UpdateCountryIe(ieee, addr2, info_element->len, info_element->data);
+                               Dot11d_UpdateCountryIe(ieee, addr2,
+                                                      info_element->len,
+                                                      info_element->data);
                        }
                }
 
@@ -1790,11 +1840,10 @@ static void rtllib_parse_mife_generic(struct rtllib_device *ieee,
 
        if (*tmp_htcap_len == 0) {
                if (info_element->len >= 4 &&
-                  info_element->data[0] == 0x00 &&
-                  info_element->data[1] == 0x90 &&
-                  info_element->data[2] == 0x4c &&
-                  info_element->data[3] == 0x033) {
-
+                   info_element->data[0] == 0x00 &&
+                   info_element->data[1] == 0x90 &&
+                   info_element->data[2] == 0x4c &&
+                   info_element->data[3] == 0x033) {
                        *tmp_htcap_len = min_t(u8, info_element->len,
                                               MAX_IE_LEN);
                        if (*tmp_htcap_len != 0) {
@@ -1928,7 +1977,8 @@ static void rtllib_parse_mife_generic(struct rtllib_device *ieee,
                        network->MBssidMask = network->CcxRmState[1] & 0x07;
                        if (network->MBssidMask != 0) {
                                network->bMBssidValid = true;
-                               network->MBssidMask = 0xff << (network->MBssidMask);
+                               network->MBssidMask = 0xff <<
+                                                     (network->MBssidMask);
                                ether_addr_copy(network->MBssid,
                                                network->bssid);
                                network->MBssid[5] &= network->MBssidMask;
@@ -1964,6 +2014,33 @@ static void rtllib_parse_mife_generic(struct rtllib_device *ieee,
        }
 }
 
+static void rtllib_parse_mfie_ht_cap(struct rtllib_info_element *info_element,
+                                    struct rtllib_network *network,
+                                    u16 *tmp_htcap_len)
+{
+       struct bss_ht *ht = &network->bssht;
+
+       *tmp_htcap_len = min_t(u8, info_element->len, MAX_IE_LEN);
+       if (*tmp_htcap_len != 0) {
+               ht->bdHTSpecVer = HT_SPEC_VER_EWC;
+               ht->bdHTCapLen = min_t(u16, *tmp_htcap_len,
+                                      sizeof(ht->bdHTCapBuf));
+               memcpy(ht->bdHTCapBuf, info_element->data, ht->bdHTCapLen);
+
+               ht->bdSupportHT = true;
+               ht->bdHT1R = ((((struct ht_capab_ele *)
+                               ht->bdHTCapBuf))->MCS[1]) == 0;
+
+               ht->bdBandWidth = (enum ht_channel_width)
+                                            (((struct ht_capab_ele *)
+                                            (ht->bdHTCapBuf))->ChlWidth);
+       } else {
+               ht->bdSupportHT = false;
+               ht->bdHT1R = false;
+               ht->bdBandWidth = HT_CHANNEL_WIDTH_20;
+       }
+}
+
 int rtllib_parse_info_param(struct rtllib_device *ieee,
                struct rtllib_info_element *info_element,
                u16 length,
@@ -2000,7 +2077,8 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
 
                        network->ssid_len = min(info_element->len,
                                                (u8) IW_ESSID_MAX_SIZE);
-                       memcpy(network->ssid, info_element->data, network->ssid_len);
+                       memcpy(network->ssid, info_element->data,
+                              network->ssid_len);
                        if (network->ssid_len < IW_ESSID_MAX_SIZE)
                                memset(network->ssid + network->ssid_len, 0,
                                       IW_ESSID_MAX_SIZE - network->ssid_len);
@@ -2144,34 +2222,17 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
                case MFIE_TYPE_HT_CAP:
                        netdev_dbg(ieee->dev, "MFIE_TYPE_HT_CAP: %d bytes\n",
                                   info_element->len);
-                       tmp_htcap_len = min_t(u8, info_element->len, MAX_IE_LEN);
-                       if (tmp_htcap_len != 0) {
-                               network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
-                               network->bssht.bdHTCapLen = tmp_htcap_len > sizeof(network->bssht.bdHTCapBuf) ?
-                                       sizeof(network->bssht.bdHTCapBuf) : tmp_htcap_len;
-                               memcpy(network->bssht.bdHTCapBuf,
-                                      info_element->data,
-                                      network->bssht.bdHTCapLen);
 
-                               network->bssht.bdSupportHT = true;
-                               network->bssht.bdHT1R = ((((struct ht_capab_ele *)
-                                                       network->bssht.bdHTCapBuf))->MCS[1]) == 0;
-
-                               network->bssht.bdBandWidth = (enum ht_channel_width)
-                                                            (((struct ht_capab_ele *)
-                                                            (network->bssht.bdHTCapBuf))->ChlWidth);
-                       } else {
-                               network->bssht.bdSupportHT = false;
-                               network->bssht.bdHT1R = false;
-                               network->bssht.bdBandWidth = HT_CHANNEL_WIDTH_20;
-                       }
+                       rtllib_parse_mfie_ht_cap(info_element, network,
+                                                &tmp_htcap_len);
                        break;
 
 
                case MFIE_TYPE_HT_INFO:
                        netdev_dbg(ieee->dev, "MFIE_TYPE_HT_INFO: %d bytes\n",
                                   info_element->len);
-                       tmp_htinfo_len = min_t(u8, info_element->len, MAX_IE_LEN);
+                       tmp_htinfo_len = min_t(u8, info_element->len,
+                                              MAX_IE_LEN);
                        if (tmp_htinfo_len) {
                                network->bssht.bdHTSpecVer = HT_SPEC_VER_IEEE;
                                network->bssht.bdHTInfoLen = tmp_htinfo_len >
@@ -2265,7 +2326,6 @@ static inline int rtllib_network_init(
        /* Where to pull this? beacon->listen_interval;*/
        network->listen_interval = 0x0A;
        network->rates_len = network->rates_ex_len = 0;
-       network->last_associate = 0;
        network->ssid_len = 0;
        network->hidden_ssid_len = 0;
        memset(network->hidden_ssid, 0, sizeof(network->hidden_ssid));
@@ -2443,7 +2503,6 @@ static inline void update_network(struct rtllib_device *ieee,
        dst->qos_data.active = qos_active;
        dst->qos_data.old_param_count = old_param;
 
-       /* dst->last_associate is not overwritten */
        dst->wmm_info = src->wmm_info;
        if (src->wmm_param[0].ac_aci_acm_aifsn ||
           src->wmm_param[1].ac_aci_acm_aifsn ||