From patchwork Sat Feb 11 17:02:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kaiser X-Patchwork-Id: 55857 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1580345wrn; Sat, 11 Feb 2023 09:11:28 -0800 (PST) X-Google-Smtp-Source: AK7set8lMqqGoiMIhWsjSElaP01tOiSTLxN2EZbQeeCKk2/nEa+LU6g5j30YvhuQe6jJKO1Lv7vG X-Received: by 2002:a17:906:c401:b0:88d:ba89:1837 with SMTP id u1-20020a170906c40100b0088dba891837mr14733990ejz.8.1676135488305; Sat, 11 Feb 2023 09:11:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676135488; cv=none; d=google.com; s=arc-20160816; b=X0Q9F0OLOUjjo6UkKVxF4ZAI5nGD1z7bh+p0IrPeNo/KGp/VjNYs6ygMAJRMaXZNXi MJzmW/7hUwcCltzlKll40lrvGYZOvdk8c5pTzUM3kzeospz4Pb/Q3fB3V71X1IhDQsl7 FwttcHedZOkfIczoci2cl4sGk0r8CDNunjXN/E3mhiJlxPq9fHdiNVeZv658GCq/nzfZ iPWxy4r7M9ECTE1lo2lCpDpA+JUlEkchpOTDJuZPVW0jVTXm3auNN4uDEtyHYEn+kSEJ K+aa5NLaH3M51tLi0LFjxdzAMX66aZtONvlBsde2DoWaALce/Et2PzqboB5bHqCGdNn3 u+xQ== 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 :message-id:date:subject:cc:to:from; bh=hvgfsIesF/uQDt9SsK9IeIXb2sU+PhVGC4X9pPGw6Fk=; b=Jrpz7MMDvpylgfxc4Q/+gmZokBu/+LdlVkjIb3e+LqPzo8TaDz6mlSmZAH9zsV2/ry /VGgFoaETIMbsj9vtNrkJhQ/TKPMYU4j+PUFiM8LYRIrl8qhdw8b5EviTq9snXxzT6zk kou4CQcnaA2xfSgadtRyKX8tLr1I6MWKl52ydjRqAN1qTBRRphV8lHkEr0Hx2JGQ52FP ATL5Ah5szeq5BEG2qy5nSmOkzImESYB7/Sze8Ok22Nlfpon6BIyXsP0ANYVuU34C0qWy 5Wc5U8hat71ruVekguiceslcn4/vIdYL0qO04GwaBGJnWWtgPc1zoYI+qWrImZevmLyf fhBw== 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 c4-20020aa7c984000000b0049e43606268si8848146edt.7.2023.02.11.09.10.59; Sat, 11 Feb 2023 09:11:28 -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 S229554AbjBKRCi (ORCPT + 99 others); Sat, 11 Feb 2023 12:02:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229457AbjBKRCh (ORCPT ); Sat, 11 Feb 2023 12:02:37 -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 0BA5C2D59 for ; Sat, 11 Feb 2023 09:02:36 -0800 (PST) Received: from dslb-094-219-036-079.094.219.pools.vodafone-ip.de ([94.219.36.79] 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 1pQtGf-0006zn-Mt; Sat, 11 Feb 2023 18:02:29 +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] staging: r8188eu: replace hand coded loop with list_for_each_entry Date: Sat, 11 Feb 2023 18:02:23 +0100 Message-Id: <20230211170223.419205-1-martin@kaiser.cx> X-Mailer: git-send-email 2.30.2 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?1757555445734556012?= X-GMAIL-MSGID: =?utf-8?q?1757555445734556012?= In function rtw_get_stainfo, we can use list_for_each_entry to iterate over the list of stations and make the code a bit simpler. Signed-off-by: Martin Kaiser Tested-by: Philipp Hortmann # Edimax N150 --- drivers/staging/r8188eu/core/rtw_sta_mgt.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/staging/r8188eu/core/rtw_sta_mgt.c b/drivers/staging/r8188eu/core/rtw_sta_mgt.c index a9c29b2bf230..e1ae1859686e 100644 --- a/drivers/staging/r8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/r8188eu/core/rtw_sta_mgt.c @@ -391,8 +391,7 @@ void rtw_free_all_stainfo(struct adapter *padapter) /* any station allocated can be searched by hash list */ struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) { - struct list_head *plist, *phead; - struct sta_info *psta = NULL; + struct sta_info *ploop, *psta = NULL; u32 index; u8 *addr; u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; @@ -409,18 +408,11 @@ struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) spin_lock_bh(&pstapriv->sta_hash_lock); - phead = &pstapriv->sta_hash[index]; - plist = phead->next; - - while (phead != plist) { - psta = container_of(plist, struct sta_info, hash_list); - - if ((!memcmp(psta->hwaddr, addr, ETH_ALEN))) { - /* if found the matched address */ + list_for_each_entry(ploop, &pstapriv->sta_hash[index], hash_list) { + if (!memcmp(ploop->hwaddr, addr, ETH_ALEN)) { + psta = ploop; break; } - psta = NULL; - plist = plist->next; } spin_unlock_bh(&pstapriv->sta_hash_lock);