From: Jes Sorensen Date: Fri, 9 May 2014 13:03:47 +0000 (+0200) Subject: staging: rtl8723au: Eliminate stainfo_by_offset spaghetti X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=6964213a949d73681b4abe7a7ad3570e49851d7b;p=openwrt%2Fstaging%2Fblogic.git staging: rtl8723au: Eliminate stainfo_by_offset spaghetti Signed-off-by: Jes Sorensen Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 432f0a29892f..9cf91a732405 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -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); diff --git a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c index 71addf6ec14e..e032d77d6e5d 100644 --- a/drivers/staging/rtl8723au/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8723au/core/rtw_sta_mgt.c @@ -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) { diff --git a/drivers/staging/rtl8723au/include/sta_info.h b/drivers/staging/rtl8723au/include/sta_info.h index c02947f6bd9b..3a490d6dcbcc 100644 --- a/drivers/staging/rtl8723au/include/sta_info.h +++ b/drivers/staging/rtl8723au/include/sta_info.h @@ -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);