[PATCH] staging: rtl8723au: use list_for_each_entry*()
Use list_for_each_entry*() instead of list_for_each*() to simplify the code. Fix coding style by the way. Signed-off-by: Geliang Tang --- drivers/staging/rtl8723au/core/rtw_ap.c | 166 -- drivers/staging/rtl8723au/core/rtw_mlme.c | 38 ++--- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 13 +- drivers/staging/rtl8723au/core/rtw_recv.c | 43 ++ drivers/staging/rtl8723au/core/rtw_sta_mgt.c | 34 ++--- drivers/staging/rtl8723au/core/rtw_xmit.c | 84 --- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 22 +-- drivers/staging/rtl8723au/os_dep/usb_ops_linux.c | 9 +- 8 files changed, 140 insertions(+), 269 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 1aa9b26..66315f9 100644 --- a/drivers/staging/rtl8723au/core/rtw_ap.c +++ b/drivers/staging/rtl8723au/core/rtw_ap.c @@ -171,24 +171,20 @@ static u8 chk_sta_is_alive(struct sta_info *psta) return ret; } -void expire_timeout_chk23a(struct rtw_adapter *padapter) +void expire_timeout_chk23a(struct rtw_adapter *padapter) { - struct list_head *phead, *plist, *ptmp; + struct list_head *phead; u8 updated = 0; - struct sta_info *psta; + struct sta_info *psta, *ptmp; struct sta_priv *pstapriv = &padapter->stapriv; u8 chk_alive_num = 0; struct sta_info *chk_alive_list[NUM_STA]; int i; spin_lock_bh(&pstapriv->auth_list_lock); - phead = &pstapriv->auth_list; - /* check auth_queue */ - list_for_each_safe(plist, ptmp, phead) { - psta = container_of(plist, struct sta_info, auth_list); - + list_for_each_entry_safe(psta, ptmp, phead, auth_list) { if (psta->expire_to > 0) { psta->expire_to--; if (psta->expire_to == 0) { @@ -206,19 +202,13 @@ void expire_timeout_chk23a(struct rtw_adapter *padapter) spin_lock_bh(&pstapriv->auth_list_lock); } } - } - spin_unlock_bh(&pstapriv->auth_list_lock); spin_lock_bh(&pstapriv->asoc_list_lock); - phead = &pstapriv->asoc_list; - /* check asoc_queue */ - list_for_each_safe(plist, ptmp, phead) { - psta = container_of(plist, struct sta_info, asoc_list); - + list_for_each_entry_safe(psta, ptmp, phead, asoc_list) { if (chk_sta_is_alive(psta) || !psta->expire_to) { psta->expire_to = pstapriv->expire_to; psta->keep_alive_trycnt = 0; @@ -283,7 +273,6 @@ voidexpire_timeout_chk23a(struct rtw_adapter *padapter) } } } - spin_unlock_bh(&pstapriv->asoc_list_lock); if (chk_alive_num) { @@ -299,51 +288,55 @@ void expire_timeout_chk23a(struct rtw_adapter *padapter) SelectChannel23a(padapter, pmlmeext->cur_channel); } - /* issue null data to check sta alive */ - for (i = 0; i < chk_alive_num; i++) { + /* issue null data to check sta alive */ + for (i = 0; i < chk_alive_num; i++) { - int ret = _FAIL; + int ret = _FAIL; - psta = chk_alive_list[i]; - if (!(psta->state & _FW_LINKED)) - continue; + psta = chk_alive_list[i]; + if (!(psta->state & _FW_LINKED)) + continue; - if (psta->state & WIFI_SLEEP_STATE) - ret = issue_nulldata23a(padapter, psta->hwaddr, 0, 1, 50); - else - ret = issue_nulldata23a(padapter, psta->hwaddr, 0, 3, 50); + if (psta->state & WIFI_SLEEP_STATE) + ret = issue_nulldata23a(padapter, psta->hwaddr, + 0, 1, 50); + else + ret = issue_nulldata23a(padapter, psta->hwaddr, + 0, 3, 50); + + psta->keep_alive_trycnt++; + if (ret == _SUCCESS) { + DBG_8723A("asoc check, sta(%pM) is alive\n", + psta->hwaddr); + psta->expire_to = pstapriv->expire_to; + psta->keep_alive_trycnt = 0; + continue; + } else if (psta->keep_alive_trycnt <= 3) { + DBG_8723A("ack check for asoc expire, keep_alive_trycnt = %d\n", + psta->keep_alive_trycnt); + psta->expire_to = 1; +
Re: [PATCH] staging: rtl8723au: use list_for_each_entry*()
Geliang Tang writes: > Use list_for_each_entry*() instead of list_for_each*() to simplify > the code. Fix coding style by the way. > > Signed-off-by: Geliang Tang > --- > drivers/staging/rtl8723au/core/rtw_ap.c | 166 > -- > drivers/staging/rtl8723au/core/rtw_mlme.c | 38 ++--- > drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 13 +- > drivers/staging/rtl8723au/core/rtw_recv.c | 43 ++ > drivers/staging/rtl8723au/core/rtw_sta_mgt.c | 34 ++--- > drivers/staging/rtl8723au/core/rtw_xmit.c | 84 --- > drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 22 +-- > drivers/staging/rtl8723au/os_dep/usb_ops_linux.c | 9 +- > 8 files changed, 140 insertions(+), 269 deletions(-) In principle this is fine, but you need to stick to doing one thing per patch. Do the list_for_each_entry() in one patch, and the formatting issues in another. Jes > diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c > b/drivers/staging/rtl8723au/core/rtw_ap.c > index 1aa9b26..66315f9 100644 > --- a/drivers/staging/rtl8723au/core/rtw_ap.c > +++ b/drivers/staging/rtl8723au/core/rtw_ap.c > @@ -171,24 +171,20 @@ static u8 chk_sta_is_alive(struct sta_info *psta) > return ret; > } > > -void expire_timeout_chk23a(struct rtw_adapter *padapter) > +void expire_timeout_chk23a(struct rtw_adapter *padapter) > { > - struct list_head *phead, *plist, *ptmp; > + struct list_head *phead; > u8 updated = 0; > - struct sta_info *psta; > + struct sta_info *psta, *ptmp; > struct sta_priv *pstapriv = &padapter->stapriv; > u8 chk_alive_num = 0; > struct sta_info *chk_alive_list[NUM_STA]; > int i; > > spin_lock_bh(&pstapriv->auth_list_lock); > - > phead = &pstapriv->auth_list; > - > /* check auth_queue */ > - list_for_each_safe(plist, ptmp, phead) { > - psta = container_of(plist, struct sta_info, auth_list); > - > + list_for_each_entry_safe(psta, ptmp, phead, auth_list) { > if (psta->expire_to > 0) { > psta->expire_to--; > if (psta->expire_to == 0) { > @@ -206,19 +202,13 @@ voidexpire_timeout_chk23a(struct rtw_adapter > *padapter) > spin_lock_bh(&pstapriv->auth_list_lock); > } > } > - > } > - > spin_unlock_bh(&pstapriv->auth_list_lock); > > spin_lock_bh(&pstapriv->asoc_list_lock); > - > phead = &pstapriv->asoc_list; > - > /* check asoc_queue */ > - list_for_each_safe(plist, ptmp, phead) { > - psta = container_of(plist, struct sta_info, asoc_list); > - > + list_for_each_entry_safe(psta, ptmp, phead, asoc_list) { > if (chk_sta_is_alive(psta) || !psta->expire_to) { > psta->expire_to = pstapriv->expire_to; > psta->keep_alive_trycnt = 0; > @@ -283,7 +273,6 @@ void expire_timeout_chk23a(struct rtw_adapter > *padapter) > } > } > } > - > spin_unlock_bh(&pstapriv->asoc_list_lock); > > if (chk_alive_num) { > @@ -299,51 +288,55 @@ voidexpire_timeout_chk23a(struct rtw_adapter > *padapter) > SelectChannel23a(padapter, pmlmeext->cur_channel); > } > > - /* issue null data to check sta alive */ > - for (i = 0; i < chk_alive_num; i++) { > + /* issue null data to check sta alive */ > + for (i = 0; i < chk_alive_num; i++) { > > - int ret = _FAIL; > + int ret = _FAIL; > > - psta = chk_alive_list[i]; > - if (!(psta->state & _FW_LINKED)) > - continue; > + psta = chk_alive_list[i]; > + if (!(psta->state & _FW_LINKED)) > + continue; > > - if (psta->state & WIFI_SLEEP_STATE) > - ret = issue_nulldata23a(padapter, psta->hwaddr, 0, 1, > 50); > - else > - ret = issue_nulldata23a(padapter, psta->hwaddr, 0, 3, > 50); > + if (psta->state & WIFI_SLEEP_STATE) > + ret = issue_nulldata23a(padapter, psta->hwaddr, > + 0, 1, 50); > + else > + ret = issue_nulldata23a(padapter, psta->hwaddr, > + 0, 3, 50); > + > + psta->keep_alive_trycnt++; > + if (ret == _SUCCESS) { > + DBG_8723A("asoc check, sta(%pM) is alive\n", > + psta->hwaddr); > + psta->expire_to = pstapriv->expire_to; > + psta->keep_alive_trycnt = 0; > + continue; > + } else if (