staging: rtl8723au: Eliminate stainfo_by_offset spaghetti
authorJes Sorensen <Jes.Sorensen@redhat.com>
Fri, 9 May 2014 13:03:47 +0000 (15:03 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 15 May 2014 20:11:59 +0000 (13:11 -0700)
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8723au/core/rtw_ap.c
drivers/staging/rtl8723au/core/rtw_sta_mgt.c
drivers/staging/rtl8723au/include/sta_info.h

index 432f0a29892fb4bfb543226534f14c4558c3794c..9cf91a7324057a3a9bfc714362b3da7f21613c3f 100644 (file)
@@ -186,7 +186,7 @@ void        expire_timeout_chk23a(struct rtw_adapter *padapter)
        struct sta_info *psta;
        struct sta_priv *pstapriv = &padapter->stapriv;
        u8 chk_alive_num = 0;
-       char chk_alive_list[NUM_STA];
+       struct sta_info *chk_alive_list[NUM_STA];
        int i;
 
        spin_lock_bh(&pstapriv->auth_list_lock);
@@ -260,13 +260,7 @@ void       expire_timeout_chk23a(struct rtw_adapter *padapter)
                        }
 
                        if (pmlmeext->active_keep_alive_check) {
-                               int stainfo_offset;
-
-                               stainfo_offset = rtw_stainfo_offset23a(pstapriv, psta);
-                               if (stainfo_offset_valid(stainfo_offset)) {
-                                       chk_alive_list[chk_alive_num++] = stainfo_offset;
-                               }
-
+                               chk_alive_list[chk_alive_num++] = psta;
                                continue;
                        }
 
@@ -300,14 +294,14 @@ void      expire_timeout_chk23a(struct rtw_adapter *padapter)
                if (rtw_get_oper_ch23a(padapter) != pmlmeext->cur_channel) {
                        backup_oper_channel = rtw_get_oper_ch23a(padapter);
                        SelectChannel23a(padapter, pmlmeext->cur_channel);
-       }
+               }
 
        /* issue null data to check sta alive*/
        for (i = 0; i < chk_alive_num; i++) {
 
                int ret = _FAIL;
 
-               psta = rtw_get_stainfo23a_by_offset23a(pstapriv, chk_alive_list[i]);
+               psta = chk_alive_list[i];
                if (!(psta->state &_FW_LINKED))
                        continue;
 
@@ -1811,7 +1805,7 @@ int rtw_sta_flush23a(struct rtw_adapter *padapter)
        struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
        u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
        u8 chk_alive_num = 0;
-       char chk_alive_list[NUM_STA];
+       struct sta_info *chk_alive_list[NUM_STA];
        int i;
 
        DBG_8723A(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(padapter->pnetdev));
@@ -1823,8 +1817,6 @@ int rtw_sta_flush23a(struct rtw_adapter *padapter)
        phead = &pstapriv->asoc_list;
 
        list_for_each_safe(plist, ptmp, phead) {
-               int stainfo_offset;
-
                psta = container_of(plist, struct sta_info, asoc_list);
 
                /* Remove sta from asoc_list */
@@ -1832,18 +1824,14 @@ int rtw_sta_flush23a(struct rtw_adapter *padapter)
                pstapriv->asoc_list_cnt--;
 
                /* Keep sta for ap_free_sta23a() beyond this asoc_list loop */
-               stainfo_offset = rtw_stainfo_offset23a(pstapriv, psta);
-               if (stainfo_offset_valid(stainfo_offset)) {
-                       chk_alive_list[chk_alive_num++] = stainfo_offset;
-               }
+               chk_alive_list[chk_alive_num++] = psta;
        }
        spin_unlock_bh(&pstapriv->asoc_list_lock);
 
        /* For each sta in chk_alive_list, call ap_free_sta23a */
-       for (i = 0; i < chk_alive_num; i++) {
-               psta = rtw_get_stainfo23a_by_offset23a(pstapriv, chk_alive_list[i]);
-               ap_free_sta23a(padapter, psta, true, WLAN_REASON_DEAUTH_LEAVING);
-       }
+       for (i = 0; i < chk_alive_num; i++)
+               ap_free_sta23a(padapter, chk_alive_list[i], true,
+                              WLAN_REASON_DEAUTH_LEAVING);
 
        issue_deauth23a(padapter, bc_addr, WLAN_REASON_DEAUTH_LEAVING);
 
@@ -1904,7 +1892,7 @@ void rtw_ap_restore_network(struct rtw_adapter *padapter)
        struct security_priv *psecuritypriv = &padapter->securitypriv;
        struct list_head *phead, *plist, *ptmp;
        u8 chk_alive_num = 0;
-       char chk_alive_list[NUM_STA];
+       struct sta_info *chk_alive_list[NUM_STA];
        int i;
 
        rtw_setopmode_cmd23a(padapter, Ndis802_11APMode);
@@ -1931,26 +1919,17 @@ void rtw_ap_restore_network(struct rtw_adapter *padapter)
        phead = &pstapriv->asoc_list;
 
        list_for_each_safe(plist, ptmp, phead) {
-               int stainfo_offset;
-
                psta = container_of(plist, struct sta_info, asoc_list);
 
-               stainfo_offset = rtw_stainfo_offset23a(pstapriv, psta);
-               if (stainfo_offset_valid(stainfo_offset)) {
-                       chk_alive_list[chk_alive_num++] = stainfo_offset;
-               }
+               chk_alive_list[chk_alive_num++] = psta;
        }
 
        spin_unlock_bh(&pstapriv->asoc_list_lock);
 
        for (i = 0; i < chk_alive_num; i++) {
-               psta = rtw_get_stainfo23a_by_offset23a(pstapriv, chk_alive_list[i]);
+               psta = chk_alive_list[i];
 
-               if (psta == NULL) {
-                       DBG_8723A(FUNC_ADPT_FMT" sta_info is null\n", FUNC_ADPT_ARG(padapter));
-               }
-               else if (psta->state &_FW_LINKED)
-               {
+               if (psta->state &_FW_LINKED) {
                        Update_RA_Entry23a(padapter, psta);
                        /* pairwise key */
                        rtw_setstakey_cmd23a(padapter, (unsigned char *)psta, true);
index 71addf6ec14ea42d276c9a2162746cb8c08cffc9..e032d77d6e5dc2fda54cce481a96c1c17abaa6f7 100644 (file)
@@ -92,22 +92,6 @@ u32 _rtw_init_sta_priv23a(struct sta_priv *pstapriv)
        return _SUCCESS;
 }
 
-inline int rtw_stainfo_offset23a(struct sta_priv *stapriv, struct sta_info *sta)
-{
-       int offset = (((u8 *)sta) - stapriv->pstainfo_buf)/sizeof(struct sta_info);
-
-       if (!stainfo_offset_valid(offset))
-               DBG_8723A("%s invalid offset(%d), out of range!!!", __func__, offset);
-       return offset;
-}
-
-inline struct sta_info *rtw_get_stainfo23a_by_offset23a(struct sta_priv *stapriv, int offset)
-{
-       if (!stainfo_offset_valid(offset))
-               DBG_8723A("%s invalid offset(%d), out of range!!!", __func__, offset);
-       return (struct sta_info *)(stapriv->pstainfo_buf + offset * sizeof(struct sta_info));
-}
-
 /*  this function is used to free the memory of lock || sema for all stainfos */
 static void rtw_mfree_all_stainfo(struct sta_priv *pstapriv)
 {
index c02947f6bd9b37f7dd381dc0f942ebb022175234..3a490d6dcbcc1cc7e2abcfd524f7090f1cae9a45 100644 (file)
@@ -369,11 +369,6 @@ static inline u32 wifi_mac_hash(const u8 *mac)
 u32    _rtw_init_sta_priv23a(struct sta_priv *pstapriv);
 u32    _rtw_free_sta_priv23a(struct sta_priv *pstapriv);
 
-#define stainfo_offset_valid(offset) (offset < NUM_STA && offset >= 0)
-int rtw_stainfo_offset23a(struct sta_priv *stapriv, struct sta_info *sta);
-struct sta_info *rtw_get_stainfo23a_by_offset23a(struct sta_priv *stapriv,
-                                          int offset);
-
 struct sta_info *rtw_alloc_stainfo23a(struct sta_priv *pstapriv, u8 *hwaddr);
 u32 rtw_free_stainfo23a(struct rtw_adapter *padapter, struct sta_info *psta);
 void rtw_free_all_stainfo23a(struct rtw_adapter *padapter);