From patchwork Wed Aug 25 18:33:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 502699 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D54A3C4320A for ; Wed, 25 Aug 2021 18:33:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BD04261076 for ; Wed, 25 Aug 2021 18:33:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238418AbhHYSek (ORCPT ); Wed, 25 Aug 2021 14:34:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237509AbhHYSej (ORCPT ); Wed, 25 Aug 2021 14:34:39 -0400 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10990C0613C1 for ; Wed, 25 Aug 2021 11:33:53 -0700 (PDT) Received: by mail-pg1-x52e.google.com with SMTP id s11so555585pgr.11 for ; Wed, 25 Aug 2021 11:33:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Ggf+LpJPCzqcDcd2e/5j3m/TAA3DFUus0qxXI93OXMw=; b=CsfwSRyoDWtqTpvJN2VE9yqMc//0Dh3+4OBPgIbZC04ZCSC8Zpvrla7s3FECoQzFyR er96tpvXPhXPStl9lnMkpniY1tQrHmKcBBU4ECKzgxCNsp4yg32j2wOlyRn1YvOYwPcB dLRSn1ySg03S/IoQasZzd2kEnMVVEqfN7is1Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Ggf+LpJPCzqcDcd2e/5j3m/TAA3DFUus0qxXI93OXMw=; b=iJRSJzmaWbcwMuxlIcWkJphphA0WeOiiTw2ZWlj0O3qkg/90VTJWPNN/Ig9K2gLwrf TDECueOu9xov7PgBDB3GNPDEXxRXsS/5MJVbSu58thPvoGVGCDeCYOu0OrDYyTG9bKAq dyHOIVoC143IjLPJ9tC/XbHRJC9wBSpLN6Y8N4loVZ6I1gX3D6+/OMj1lMMddvVN52QV z3Vp51rtN8UqGf3SZUa3Ds/T7pG7uGPifDV1ZRU8MtnUFBZjTTupFmR099qGd6ZHfhbI ErsTDRiZkmxaTVSozH8QfTY6/XB138/sMleNl8F+eW2tVYNLeTMkHlfI0qfeEYOQ/iGJ vWhQ== X-Gm-Message-State: AOAM530YtujIhzxr27JeCi2Xl4DeWaauB0Fd9plaHgnZCRANwpaXAT4R 1SBY2P0MOxwrf7h9ZoAIf9eZog== X-Google-Smtp-Source: ABdhPJzvLkiLyiR8okGaSKcAVrW2SnLai1N911vjm8Gmj6lrRbWXY5pWPjjrAAUnXeI5gXGvK7YUrA== X-Received: by 2002:a62:e116:0:b0:3e1:57a4:e501 with SMTP id q22-20020a62e116000000b003e157a4e501mr45763002pfh.36.1629916432644; Wed, 25 Aug 2021 11:33:52 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id br3sm4801088pjb.52.2021.08.25.11.33.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Aug 2021 11:33:52 -0700 (PDT) From: Kees Cook To: Ping-Ke Shih Cc: Kees Cook , Kalle Valo , "David S. Miller" , Jakub Kicinski , Larry Finger , Colin Ian King , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, Joe Perches , Kaixu Xia , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH] rtlwifi: rtl8192de: Style clean-ups Date: Wed, 25 Aug 2021 11:33:50 -0700 Message-Id: <20210825183350.1145441-1-keescook@chromium.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2542; h=from:subject; bh=WiI8i3mVA5kMq1xjzJQkl4VAkYEYT2HU/B+WViFz08k=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBhJo0NkICAybEIi3bCEwhqPsG25+Mb1MpwZyumlIsh CtJ5dJaJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCYSaNDQAKCRCJcvTf3G3AJqCXD/ 0SV/fuu4BuMqqjwabMcvyFOrQX+6BYxq4R9SGvGsvGBzn4cDaoGlC/DKqGSE4gHnCQjd3B7UsLHD/c Y6nWJ+7LpvVYO9IRwIDfIPn/ahXGNEy7OOp1VLkP9f8NMtHBwsFynMr4re77KztB5A3idqT3W5t0KA V4PTpJrKFwiBKQJ4Xfm8y2dmn7hoz8+Agq7Y8QHBy63FR5RHs9LO/7y1flQ9as9mIidNxhV3gozvW2 324af4kHsg+ECMUat7mkUzL4wKPVfakuxF2iW+kY++hRK5HESb51ov2ZF9GpWOIu3xpHMws719ZE3Z gQrQ9KhSKTX602mr/mp1UVZhLVB0PQGXoHm/ydi1bustMKpPG7pyOkQEPkAxdbyArmGkfM2Ucm+xJ4 vxy35LlOsrZN6fM9HWV75yy9Ta1fsBcUJN5mCazaJmXlMJdLYYzG8tbHBR4m0++ASGgzEjLfsJm3iO NL56mC4bu+/QMuhoZWhGG+yMRHGexC3bE/CZuReAs9+fl3QUgkP4cOvB5ikc00qO46kJX29oAKTVpX PFGyq3bvBEU7L5/3z4WNoohsjAyWrmNeCMrNrNF/2shq7BxyUBiqpS7qt3EtutjCdA/s0UmR8/CV+G d5Ryhn2BQUZiUhBy9UkBaRFVqfspXa7kngyIKpHoYRdeM1vo6TjjeIJ23L+Q== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Clean up some style issues: - Use ARRAY_SIZE() even though it's a u8 array. - Remove redundant CHANNEL_MAX_NUMBER_2G define. Additionally fix some dead code WARNs. Cc: Ping-Ke Shih Cc: Kalle Valo Cc: "David S. Miller" Cc: Jakub Kicinski Cc: Larry Finger Cc: Colin Ian King Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Kees Cook Acked-by: Ping-Ke Shih --- drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c | 8 +++----- drivers/net/wireless/realtek/rtlwifi/wifi.h | 1 - 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c index b32fa7a75f17..9807c9e91998 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c @@ -899,7 +899,7 @@ static u8 _rtl92c_phy_get_rightchnlplace(u8 chnl) u8 place = chnl; if (chnl > 14) { - for (place = 14; place < sizeof(channel5g); place++) { + for (place = 14; place < ARRAY_SIZE(channel5g); place++) { if (channel5g[place] == chnl) { place++; break; @@ -2861,16 +2861,14 @@ u8 rtl92d_phy_sw_chnl(struct ieee80211_hw *hw) case BAND_ON_5G: /* Get first channel error when change between * 5G and 2.4G band. */ - if (channel <= 14) + if (WARN_ONCE(channel <= 14, "rtl8192de: 5G but channel<=14\n")) return 0; - WARN_ONCE((channel <= 14), "rtl8192de: 5G but channel<=14\n"); break; case BAND_ON_2_4G: /* Get first channel error when change between * 5G and 2.4G band. */ - if (channel > 14) + if (WARN_ONCE(channel > 14, "rtl8192de: 2G but channel>14\n")) return 0; - WARN_ONCE((channel > 14), "rtl8192de: 2G but channel>14\n"); break; default: WARN_ONCE(true, "rtl8192de: Invalid WirelessMode(%#x)!!\n", diff --git a/drivers/net/wireless/realtek/rtlwifi/wifi.h b/drivers/net/wireless/realtek/rtlwifi/wifi.h index aa07856411b1..31f9e9e5c680 100644 --- a/drivers/net/wireless/realtek/rtlwifi/wifi.h +++ b/drivers/net/wireless/realtek/rtlwifi/wifi.h @@ -108,7 +108,6 @@ #define CHANNEL_GROUP_IDX_5GM 6 #define CHANNEL_GROUP_IDX_5GH 9 #define CHANNEL_GROUP_MAX_5G 9 -#define CHANNEL_MAX_NUMBER_2G 14 #define AVG_THERMAL_NUM 8 #define AVG_THERMAL_NUM_88E 4 #define AVG_THERMAL_NUM_8723BE 4