From patchwork Sat Oct 29 17:23:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kaiser X-Patchwork-Id: 12757 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1439774wru; Sat, 29 Oct 2022 10:26:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM72IZJpILWRaXqJpNHTtK0brfpFlZ/KMY6nt8iNe8pqM8bDA2ikejnCvD4NmPAL3i/8mKl8 X-Received: by 2002:a17:902:ea06:b0:185:4c1f:7460 with SMTP id s6-20020a170902ea0600b001854c1f7460mr5349187plg.99.1667064375709; Sat, 29 Oct 2022 10:26:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667064375; cv=none; d=google.com; s=arc-20160816; b=z8gI7XDUOvZVOnfVPBcNKoNtM696OGZd9/mCx2ZkEYdOAIFulNGJngMclTrxk4ErL8 gexyn64ft7CPSmHsADsVIaY9n1lhP5YBQLsUkjmZFpuySqSL3u40k3rnTFUuvPlAauXk BgO3X+ZZl6zYAMXK4lL2YHoyRCHJqDf/riD7HXEQKgU23UVX07lZs910FpyLNpFBvrDK 7s20eIabVCBBnH2rcCiNg/R1U1n9GWe+PlmTEiQZHOzGt+MgSrUQqb8+JS6jtxO8aBB/ wUHsgI/1ZgGEefLrYSjLZa2o1PK+cok8lsu55wDXdvDveHJ7u3BPoBZxGp0uUoLRISis IhpA== 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=FkrmJMZAdfdPZ4DqRcA1q6PC2/U6TCB84npT0+HwJd4=; b=HSpHHbS3Si8m+Rv5rXCM8cgd3sXgVP0CTO7vySg6nm14uLAVETyG+AKxwxKIfRaxlQ 3PBIfL2IznCAmhd6ECw/T9kj9oWzddkmxMpr7z6f6QbtHaf9myCnQaCyHCFu5iN1f19m vEeV/pyzoAdNuMcNY3MrCukQFf+EAnLGGAlY8OG/g/bKWuesPMTp8UntLQF1bwuuCxsR dwsG4jZlFUy31OiCZZfsthSv94YYKgt8CaBLEEDRG6nwFwKJkSQG8lnKHALeRKofgaC2 8s86hwX95hMyRJTdYs4LeTWhk6V4sVaLs80h29fgDCusZkqCBccUSqJVEHbZPqXpyDEm HuAg== 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 eb9-20020a056a004c8900b0056cb09fe0besi2473328pfb.191.2022.10.29.10.26.03; Sat, 29 Oct 2022 10:26:15 -0700 (PDT) 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 S229536AbiJ2RYi (ORCPT + 99 others); Sat, 29 Oct 2022 13:24:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229886AbiJ2RYN (ORCPT ); Sat, 29 Oct 2022 13:24:13 -0400 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 1C2384CA0A for ; Sat, 29 Oct 2022 10:24:04 -0700 (PDT) Received: from dslb-188-097-213-253.188.097.pools.vodafone-ip.de ([188.97.213.253] 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 1oopYu-00074v-Cy; Sat, 29 Oct 2022 19:24:00 +0200 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 09/13] staging: r8188eu: clean up on_action_public Date: Sat, 29 Oct 2022 19:23:33 +0200 Message-Id: <20221029172337.1574593-10-martin@kaiser.cx> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221029172337.1574593-1-martin@kaiser.cx> References: <20221029172337.1574593-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?1748043694716741156?= X-GMAIL-MSGID: =?utf-8?q?1748043694716741156?= Use the struct mgmt to read the action_code. This is much simpler than parsing the message ourselves. Add a comment about reading the action code. All members of the action enum start with an action_code byte. It does not matter which member we use. Signed-off-by: Martin Kaiser --- drivers/staging/r8188eu/core/rtw_mlme_ext.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index 40539fa3b5a2..b3cef3504ad3 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -3813,24 +3813,16 @@ static unsigned int on_action_public_default(struct recv_frame *precv_frame) static void on_action_public(struct adapter *padapter, struct recv_frame *precv_frame) { struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)precv_frame->rx_data; - unsigned int ret = _FAIL; - u8 *pframe = precv_frame->rx_data; - u8 *frame_body = pframe + sizeof(struct ieee80211_hdr_3addr); - u8 action; /* check RA matches or not */ if (memcmp(myid(&padapter->eeprompriv), mgmt->da, ETH_ALEN)) return; - action = frame_body[1]; - switch (action) { - case ACT_PUBLIC_VENDOR: - ret = on_action_public_vendor(precv_frame); - break; - default: - ret = on_action_public_default(precv_frame); - break; - } + /* All members of the action enum start with action_code. */ + if (mgmt->u.action.u.s1g.action_code == WLAN_PUB_ACTION_VENDOR_SPECIFIC) + on_action_public_vendor(precv_frame); + else + on_action_public_default(precv_frame); } static void OnAction_p2p(struct adapter *padapter, struct recv_frame *precv_frame)