[5/9] staging: r8188eu: use kernel helper to iterate over a list

Message ID 20230130195303.138941-6-martin@kaiser.cx
State New
Headers
Series staging: r8188eu: another round of xmit cleanups |

Commit Message

Martin Kaiser Jan. 30, 2023, 7:52 p.m. UTC
  rtw_free_xmitframe_list iterates over the list of xmit_frames and frees
each entry. We can use list_for_each_entry_safe instead of coding this
manually. We need the _safe version as the current pxmitframe will be
removed from the list by rtw_free_xmitframe.

Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
 drivers/staging/r8188eu/core/rtw_xmit.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
  

Patch

diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c
index 24cf11e7b4bc..c2b1e6f1d358 100644
--- a/drivers/staging/r8188eu/core/rtw_xmit.c
+++ b/drivers/staging/r8188eu/core/rtw_xmit.c
@@ -1327,18 +1327,10 @@  s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv, struct xmit_frame *pxmitfram
 
 void rtw_free_xmitframe_list(struct xmit_priv *pxmitpriv, struct list_head *xframe_list)
 {
-	struct list_head *plist;
-	struct	xmit_frame	*pxmitframe;
-
-	plist = xframe_list->next;
-
-	while (xframe_list != plist) {
-		pxmitframe = container_of(plist, struct xmit_frame, list);
-
-		plist = plist->next;
+	struct	xmit_frame *pxmitframe, *tmp_xmitframe;
 
+	list_for_each_entry_safe(pxmitframe, tmp_xmitframe, xframe_list, list)
 		rtw_free_xmitframe(pxmitpriv, pxmitframe);
-	}
 }
 
 struct xmit_frame *rtw_dequeue_xframe(struct xmit_priv *pxmitpriv, struct hw_xmit *phwxmit_i)