[PATCH v2] staging: rtl8723au: use list_for_each_entry*()
Use list_for_each_entry*() instead of list_for_each*() to simplify the code. Signed-off-by: Geliang Tang --- Changes in v2: - drop the coding style fixing in v1. --- drivers/staging/rtl8723au/core/rtw_ap.c | 92 ++- drivers/staging/rtl8723au/core/rtw_mlme.c | 38 +++--- drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 15 +--- drivers/staging/rtl8723au/core/rtw_recv.c | 43 --- drivers/staging/rtl8723au/core/rtw_sta_mgt.c | 36 +++-- drivers/staging/rtl8723au/core/rtw_xmit.c | 90 -- drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 22 ++ drivers/staging/rtl8723au/os_dep/usb_ops_linux.c | 9 +-- 8 files changed, 106 insertions(+), 239 deletions(-) diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c b/drivers/staging/rtl8723au/core/rtw_ap.c index 1aa9b26..ce4b589 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) { @@ -1059,7 +1048,7 @@ void rtw_set_macaddr_acl23a(struct rtw_adapter *padapter, int mode) int rtw_acl_add_sta23a(struct rtw_adapter *padapter, u8 *addr) { - struct list_head *plist, *phead; + struct list_head *phead; u8 added = false; int i, ret = 0; struct rtw_wlan_acl_node *paclnode; @@ -1073,12 +1062,8 @@ int rtw_acl_add_sta23a(struct rtw_adapter *padapter, u8 *addr) return -1; spin_lock_bh(&pacl_node_q->lock); - phead = get_list_head(pacl_node_q); - - list_for_each(plist, phead) { - paclnode = container_of(plist, struct rtw_wlan_acl_node, list); - + list_for_each_entry(paclnode, phead, list) { if (!memcmp(paclnode->addr, addr, ETH_ALEN)) { if (paclnode->valid == true) { added = true; @@ -1087,7 +1072,6 @@ int rtw_acl_add_sta23a(struct rtw_adapter *padapter, u8 *addr) } } } - spin_unlock_bh(&pacl_node_q->lock); if (added) @@ -1121,8 +1105,8 @@ int rtw_acl_add_sta23a(struct rtw_adapter *padapter, u8 *addr) int rtw_acl_remove_sta23a(struct rtw_adapter *padapter, u8 *addr) { - struct list_head *plist, *phead, *ptmp; - struct rtw_wlan_acl_node *paclnode; + struct list_head *phead; + struct rtw_wlan_acl_node *paclnode, *ptmp; struct sta_priv *pstapriv = &padapter->stapriv; struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; struct rtw_queue *pacl_node_q = &pacl_list->acl_node_q; @@ -1130,12 +1114,8 @@ int rtw_acl_remove_sta23a(struct rtw_adapter *padapter, u8 *addr) DBG_8723A("%s(acl_num =%d) = %pM\n", __func__, pacl_list->num, addr); spin_lock_bh(&pacl_node_q->lock); - phead = get_list_head(pacl_node_q); - - list_for_each_safe(plist, ptmp, phead) { - paclnode = container_of(plist, struct rtw_wlan_acl_node, list); - + list_for_each_entry_safe(paclnode, ptmp, p
Re: [PATCH v2] staging: rtl8723au: use list_for_each_entry*()
Geliang Tang writes: > Use list_for_each_entry*() instead of list_for_each*() to simplify > the code. > > Signed-off-by: Geliang Tang > --- > Changes in v2: > - drop the coding style fixing in v1. > --- > drivers/staging/rtl8723au/core/rtw_ap.c | 92 > ++- > drivers/staging/rtl8723au/core/rtw_mlme.c | 38 +++--- > drivers/staging/rtl8723au/core/rtw_mlme_ext.c | 15 +--- > drivers/staging/rtl8723au/core/rtw_recv.c | 43 --- > drivers/staging/rtl8723au/core/rtw_sta_mgt.c | 36 +++-- > drivers/staging/rtl8723au/core/rtw_xmit.c | 90 -- > drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 22 ++ > drivers/staging/rtl8723au/os_dep/usb_ops_linux.c | 9 +-- > 8 files changed, 106 insertions(+), 239 deletions(-) You still include too much whitespace and blank line cleaning with the actual code changes. Please split this into two patches, one that changes the code, and one that does the whitespace cleanups. Jes > > diff --git a/drivers/staging/rtl8723au/core/rtw_ap.c > b/drivers/staging/rtl8723au/core/rtw_ap.c > index 1aa9b26..ce4b589 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) { > @@ -1059,7 +1048,7 @@ void rtw_set_macaddr_acl23a(struct rtw_adapter > *padapter, int mode) > > int rtw_acl_add_sta23a(struct rtw_adapter *padapter, u8 *addr) > { > - struct list_head *plist, *phead; > + struct list_head *phead; > u8 added = false; > int i, ret = 0; > struct rtw_wlan_acl_node *paclnode; > @@ -1073,12 +1062,8 @@ int rtw_acl_add_sta23a(struct rtw_adapter *padapter, > u8 *addr) > return -1; > > spin_lock_bh(&pacl_node_q->lock); > - > phead = get_list_head(pacl_node_q); > - > - list_for_each(plist, phead) { > - paclnode = container_of(plist, struct rtw_wlan_acl_node, list); > - > + list_for_each_entry(paclnode, phead, list) { > if (!memcmp(paclnode->addr, addr, ETH_ALEN)) { > if (paclnode->valid == true) { > added = true; > @@ -1087,7 +1072,6 @@ int rtw_acl_add_sta23a(struct rtw_adapter *padapter, u8 > *addr) > } > } > } > - > spin_unlock_bh(&pacl_node_q->lock); > > if (added) > @@ -1121,8 +1105,8 @@ int rtw_acl_add_sta23a(struct rtw_adapter *padapter, u8 > *addr) > > int rtw_acl_remove_sta23a(struct rtw_adapter *padapter, u8 *addr) > { > - struct list_head *plist, *phead, *ptmp; > - struct rtw_wlan_acl_node *paclnode; > + struct list_head *phead; > + struct rtw_wlan_acl_node *paclnode, *ptmp; > struct sta_priv *pstapriv = &padapter->stapriv; > struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; > struct rtw_queue *pacl_node_q = &pacl_list->acl_node_q; > @@ -1130,12 +1114,8 @@ int rtw_acl_remove_sta23a(struct rtw_adapter > *padapter, u8 *a