From patchwork Mon Jan 23 20:53:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kaiser X-Patchwork-Id: 47383 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1811090wrn; Mon, 23 Jan 2023 12:56:26 -0800 (PST) X-Google-Smtp-Source: AMrXdXtUE8ztkb2VUE6c+0Sn+st1fu3zwJAmtGExc38tPkcYKmKqMxUrO9FX+P67EL3PKX1C0FV6 X-Received: by 2002:a17:906:3b01:b0:84d:4767:734 with SMTP id g1-20020a1709063b0100b0084d47670734mr38363207ejf.6.1674507386147; Mon, 23 Jan 2023 12:56:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674507386; cv=none; d=google.com; s=arc-20160816; b=ti8URcOKegR0mK4x74wxmnYpJWYbt+mPyl5EpiKiwG7Y0FgCfE6lqZv9BuX4Dekntr Cdutuh/KIrcHsq8Dz78r+KhfaFcjw7Pm9VZ7QDDbOKNTtVDoSUPpI60lhlgoh8zBH4WO Sx0cT/KvhNwa+5E8sGQXyaApF1DhX5Tss7bfimQN137yseYnQEUXbiBXq/CWNpUm1SFf Ip/hLKTP9FS6smZBx5z028zrvO8VHil55Myhym0DUpJ1Ov/wYi02aCOwK8YrBXfmUc/h q7uhBJXkjilvsy6rsonV7+n7qN0zgLE/t2297QbbyFefl0jmPF9wdViifY7mW25raYci /K8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=LPKH1RUVJdvMtNgmkDeMmBeBEhsmqniwrmDsFWbcwuQ=; b=sZFzpTrGRH5zE0OrAbBWB2dkO048tV9cUQQJBWn5/+N/hgwFsp/rzFSZNoTSwKeZp9 OGNCpvlDlgzDLoh/W7ERg6JGyDPsCCeznRuTDtshrIRyCeqwDf+Yme2Pz9+8E3WV8KXh zdDKkJ2toKfA/RNo62L8jrO4mkPIcvm4/wqAUuLHDckWlg67hcyF7ZYMK3rk+HomAaZ8 aHEjL7GsqqHqY5VW4TsY6BYoSanmLKoF9OM76a6hU6qHcL3ZxJCpc0O6YnVNT9yOgmh6 pdcOB+QTVEi60L6S78KzC4rWqn6AiF23DItLuc/sFa4vFs2HEIhBUjX/hFQib0FWCLoN GOrA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f4-20020a1709063f4400b00877a9863006si9843812ejj.282.2023.01.23.12.56.02; Mon, 23 Jan 2023 12:56:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231981AbjAWUyR (ORCPT + 99 others); Mon, 23 Jan 2023 15:54:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231652AbjAWUyF (ORCPT ); Mon, 23 Jan 2023 15:54:05 -0500 Received: from viti.kaiser.cx (viti.kaiser.cx [IPv6:2a01:238:43fe:e600:cd0c:bd4a:7a3:8e9f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3897C7DB5 for ; Mon, 23 Jan 2023 12:54:05 -0800 (PST) Received: from ipservice-092-217-089-134.092.217.pools.vodafone-ip.de ([92.217.89.134] helo=martin-debian-2.paytec.ch) by viti.kaiser.cx with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1pK3pH-0000Lk-7J; Mon, 23 Jan 2023 21:53:59 +0100 From: Martin Kaiser To: Greg Kroah-Hartman Cc: Larry Finger , Phillip Potter , Michael Straube , Pavel Skripkin , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Martin Kaiser Subject: [PATCH 05/23] staging: r8188eu: simplify the sta loop in rtw_dequeue_xframe Date: Mon, 23 Jan 2023 21:53:24 +0100 Message-Id: <20230123205342.229589-6-martin@kaiser.cx> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230123205342.229589-1-martin@kaiser.cx> References: <20230123205342.229589-1-martin@kaiser.cx> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755848256632498318?= X-GMAIL-MSGID: =?utf-8?q?1755848256632498318?= Use list_for_each_entry_safe to iterate over the station entries in function rtw_dequeue_xframe instead of coding the loop manually. We have to use the safe version, the loop body may remove a station from the list over which we iterate. Signed-off-by: Martin Kaiser --- drivers/staging/r8188eu/core/rtw_xmit.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c index 5f2426be6c11..b07a1ce21a38 100644 --- a/drivers/staging/r8188eu/core/rtw_xmit.c +++ b/drivers/staging/r8188eu/core/rtw_xmit.c @@ -1377,9 +1377,9 @@ static struct xmit_frame *dequeue_one_xmitframe(struct xmit_priv *pxmitpriv, str struct xmit_frame *rtw_dequeue_xframe(struct xmit_priv *pxmitpriv, struct hw_xmit *phwxmit_i) { - struct list_head *sta_plist, *sta_phead; + struct list_head *sta_phead; struct hw_xmit *phwxmit; - struct tx_servq *ptxservq = NULL; + struct tx_servq *ptxservq, *tmp_txservq; struct __queue *pframe_queue = NULL; struct xmit_frame *pxmitframe = NULL; struct adapter *padapter = pxmitpriv->adapter; @@ -1401,10 +1401,8 @@ struct xmit_frame *rtw_dequeue_xframe(struct xmit_priv *pxmitpriv, struct hw_xmi phwxmit = phwxmit_i + inx[i]; sta_phead = get_list_head(phwxmit->sta_queue); - sta_plist = sta_phead->next; - while (sta_phead != sta_plist) { - ptxservq = container_of(sta_plist, struct tx_servq, tx_pending); + list_for_each_entry_safe(ptxservq, tmp_txservq, sta_phead, tx_pending) { pframe_queue = &ptxservq->sta_pending; @@ -1418,8 +1416,6 @@ struct xmit_frame *rtw_dequeue_xframe(struct xmit_priv *pxmitpriv, struct hw_xmi list_del_init(&ptxservq->tx_pending); goto exit; } - - sta_plist = sta_plist->next; } } exit: