[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <869f4d40ae746a70e2b7456a143a6f966fbe05c9.1508354332.git.srishtishar@gmail.com>
Date: Thu, 19 Oct 2017 01:01:14 +0530
From: Srishti Sharma <srishtishar@...il.com>
To: gregkh@...uxfoundation.org
Cc: devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org,
outreachy-kernel@...glegroups.com,
Srishti Sharma <srishtishar@...il.com>
Subject: [PATCH 2/4] Staging: rtl8188eu: core: rtw_ap: Use list_for_each_entry_safe
This is a cleanup patch and doesn't change runtime behaviour. It
changes an open coded list traversal to use list_for_each_entry_safe.
Done using the following semantic patch by coccinelle.
@r@
struct list_head* l;
expression e;
identifier m,list_del_init,f;
type T1;
T1* pos;
iterator name list_for_each_entry_safe;
@@
f(...){
+T1* tmp;
<+...
-while(...)
+list_for_each_entry_safe(pos,tmp,l,m)
{
...
-pos = container_of(l,T1,m);
...
-l=e;
<+...
list_del_init(&pos->m)
...+>
}
...+>
}
Signed-off-by: Srishti Sharma <srishtishar@...il.com>
---
drivers/staging/rtl8188eu/core/rtw_ap.c | 34 +++++++++------------------------
1 file changed, 9 insertions(+), 25 deletions(-)
diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c
index 32a4837..551af9e 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ap.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
@@ -280,7 +280,7 @@ void expire_timeout_chk(struct adapter *padapter)
{
struct list_head *phead, *plist;
u8 updated = 0;
- struct sta_info *psta = NULL;
+ struct sta_info *psta = NULL, *tmp;
struct sta_priv *pstapriv = &padapter->stapriv;
u8 chk_alive_num = 0;
char chk_alive_list[NUM_STA];
@@ -292,10 +292,7 @@ void expire_timeout_chk(struct adapter *padapter)
plist = phead->next;
/* check auth_queue */
- while (phead != plist) {
- psta = container_of(plist, struct sta_info, auth_list);
- plist = plist->next;
-
+ list_for_each_entry_safe(psta, tmp, plist, auth_list) {
if (psta->expire_to > 0) {
psta->expire_to--;
if (psta->expire_to == 0) {
@@ -326,10 +323,7 @@ void expire_timeout_chk(struct adapter *padapter)
plist = phead->next;
/* check asoc_queue */
- while (phead != plist) {
- psta = container_of(plist, struct sta_info, asoc_list);
- plist = plist->next;
-
+ list_for_each_entry_safe(psta, tmp, plist, asoc_list) {
if (chk_sta_is_alive(psta) || !psta->expire_to) {
psta->expire_to = pstapriv->expire_to;
psta->keep_alive_trycnt = 0;
@@ -1196,7 +1190,7 @@ int rtw_acl_add_sta(struct adapter *padapter, u8 *addr)
int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr)
{
struct list_head *plist, *phead;
- struct rtw_wlan_acl_node *paclnode;
+ struct rtw_wlan_acl_node *paclnode, *tmp;
struct sta_priv *pstapriv = &padapter->stapriv;
struct wlan_acl_pool *pacl_list = &pstapriv->acl_list;
struct __queue *pacl_node_q = &pacl_list->acl_node_q;
@@ -1208,10 +1202,7 @@ int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr)
phead = get_list_head(pacl_node_q);
plist = phead->next;
- while (phead != plist) {
- paclnode = container_of(plist, struct rtw_wlan_acl_node, list);
- plist = plist->next;
-
+ list_for_each_entry_safe(paclnode, tmp, plist, list) {
if (!memcmp(paclnode->addr, addr, ETH_ALEN)) {
if (paclnode->valid) {
paclnode->valid = false;
@@ -1711,7 +1702,7 @@ u8 ap_free_sta(struct adapter *padapter, struct sta_info *psta,
int rtw_sta_flush(struct adapter *padapter)
{
struct list_head *phead, *plist;
- struct sta_info *psta = NULL;
+ struct sta_info *psta = NULL, *tmp;
struct sta_priv *pstapriv = &padapter->stapriv;
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;
@@ -1727,11 +1718,7 @@ int rtw_sta_flush(struct adapter *padapter)
plist = phead->next;
/* free sta asoc_queue */
- while (phead != plist) {
- psta = container_of(plist, struct sta_info, asoc_list);
-
- plist = plist->next;
-
+ list_for_each_entry_safe(psta, tmp, plist, asoc_list) {
list_del_init(&psta->asoc_list);
pstapriv->asoc_list_cnt--;
@@ -1833,7 +1820,7 @@ void start_ap_mode(struct adapter *padapter)
void stop_ap_mode(struct adapter *padapter)
{
struct list_head *phead, *plist;
- struct rtw_wlan_acl_node *paclnode;
+ struct rtw_wlan_acl_node *paclnode, *tmp;
struct sta_info *psta = NULL;
struct sta_priv *pstapriv = &padapter->stapriv;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
@@ -1855,10 +1842,7 @@ void stop_ap_mode(struct adapter *padapter)
spin_lock_bh(&pacl_node_q->lock);
phead = get_list_head(pacl_node_q);
plist = phead->next;
- while (phead != plist) {
- paclnode = container_of(plist, struct rtw_wlan_acl_node, list);
- plist = plist->next;
-
+ list_for_each_entry_safe(paclnode, tmp, plist, list) {
if (paclnode->valid) {
paclnode->valid = false;
--
2.7.4
Powered by blists - more mailing lists