From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751479AbdJRTa4 (ORCPT ); Wed, 18 Oct 2017 15:30:56 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:43760 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751110AbdJRTaz (ORCPT ); Wed, 18 Oct 2017 15:30:55 -0400 X-Google-Smtp-Source: ABhQp+Q3o0ooJ/TC+iB2dI5hYIio2fBx418jO7zaaffPnonhOUlrR1htHKNjZnNnkLmexkditS9kYw== From: Srishti Sharma To: gregkh@linuxfoundation.org Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, outreachy-kernel@googlegroups.com, Srishti Sharma Subject: [PATCH 1/4] Staging: rtl8188eu: core: rtw_xmit: Use list_for_each_entry_safe Date: Thu, 19 Oct 2017 01:00:49 +0530 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/staging/rtl8188eu/core/rtw_xmit.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c index e8d9858..5255c27 100644 --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c @@ -1866,6 +1866,7 @@ void stop_sta_xmit(struct adapter *padapter, struct sta_info *psta) void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) { + struct xmit_frame *tmp; u8 update_mask = 0, wmmps_ac = 0; struct sta_info *psta_bmc; struct list_head *xmitframe_plist, *xmitframe_phead; @@ -1877,11 +1878,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) xmitframe_phead = get_list_head(&psta->sleep_q); xmitframe_plist = xmitframe_phead->next; - while (xmitframe_phead != xmitframe_plist) { - pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); - - xmitframe_plist = xmitframe_plist->next; - + list_for_each_entry_safe(pxmitframe, tmp, xmitframe_plist, list) { list_del_init(&pxmitframe->list); switch (pxmitframe->attrib.priority) { @@ -1958,11 +1955,8 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) xmitframe_phead = get_list_head(&psta_bmc->sleep_q); xmitframe_plist = xmitframe_phead->next; - while (xmitframe_phead != xmitframe_plist) { - pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); - - xmitframe_plist = xmitframe_plist->next; - + list_for_each_entry_safe(pxmitframe, tmp, xmitframe_plist, + list) { list_del_init(&pxmitframe->list); psta_bmc->sleepq_len--; @@ -1997,7 +1991,7 @@ void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *pst { u8 wmmps_ac = 0; struct list_head *xmitframe_plist, *xmitframe_phead; - struct xmit_frame *pxmitframe = NULL; + struct xmit_frame *pxmitframe = NULL, *tmp; struct sta_priv *pstapriv = &padapter->stapriv; spin_lock_bh(&psta->sleep_q.lock); @@ -2005,11 +1999,7 @@ void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *pst xmitframe_phead = get_list_head(&psta->sleep_q); xmitframe_plist = xmitframe_phead->next; - while (xmitframe_phead != xmitframe_plist) { - pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); - - xmitframe_plist = xmitframe_plist->next; - + list_for_each_entry_safe(pxmitframe, tmp, xmitframe_plist, list) { switch (pxmitframe->attrib.priority) { case 1: case 2: -- 2.7.4