From patchwork Tue Aug 3 14:49:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin King X-Patchwork-Id: 12416543 X-Patchwork-Delegate: kuba@kernel.org 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=-18.8 required=3.0 tests=BAYES_00,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 56DC5C4320A for ; Tue, 3 Aug 2021 14:50:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3E3E960FC2 for ; Tue, 3 Aug 2021 14:50:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235942AbhHCOuC (ORCPT ); Tue, 3 Aug 2021 10:50:02 -0400 Received: from smtp-relay-canonical-0.canonical.com ([185.125.188.120]:59402 "EHLO smtp-relay-canonical-0.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232748AbhHCOuC (ORCPT ); Tue, 3 Aug 2021 10:50:02 -0400 Received: from localhost (1.general.cking.uk.vpn [10.172.193.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPSA id A126F3F237; Tue, 3 Aug 2021 14:49:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1628002189; bh=NiVUhx/JAom6b6NYddYVcs0padMYBQPXPuWaKQhjOPc=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=IQeQmkWo4IIG36PuLt3BuPlcs6dLoGXLoioFFBPySG5XJuLbR+PVSeAMhcUZ3eSD0 A1x5Fv9uMg5OiB/MAkOqVc8YIR4SNOJ6YIl07R0lk+yXeag4rGULpaxnPVP8jMTH8g /uuVennK05KOihQ25LvfJ93TYiS/0nD2hDJqqcAKuPiQjGH9efL7HcZ2NBLFyimE2x 1LNNu9IBtCBSqJcJZ9t5NvIB/Qh8baVqwjkX77j/fZCAPjdm2xt0+KDRqCD6ThX6/q B+YDcSWLCcIIEKc9LuEScd/HDOV18X6loA6WdCHEHjrqeWNi7Hv5UOkqzu2+07bAEb 87c63L4QNKBig== From: Colin King To: Ping-Ke Shih , Kalle Valo , "David S . Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, Joe Perches , linux-kernel@vger.kernel.org Subject: [PATCH 1/3][RESEND] rtlwifi: rtl8192de: Remove redundant variable initializations Date: Tue, 3 Aug 2021 15:49:47 +0100 Message-Id: <20210803144949.79433-1-colin.king@canonical.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Colin Ian King The variables rtstatus and place are being initialized with a values that are never read, the initializations are redundant and can be removed. Addresses-Coverity: ("Unused value") Signed-off-by: Colin Ian King Acked-by: Ping-Ke Shih --- drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c index 76dd881ef9bb..50c2d8f6f9c0 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c @@ -681,7 +681,7 @@ static bool _rtl92d_phy_bb_config(struct ieee80211_hw *hw) struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_phy *rtlphy = &(rtlpriv->phy); struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); - bool rtstatus = true; + bool rtstatus; rtl_dbg(rtlpriv, COMP_INIT, DBG_TRACE, "==>\n"); rtstatus = _rtl92d_phy_config_bb_with_headerfile(hw, @@ -887,7 +887,7 @@ static void _rtl92d_ccxpower_index_check(struct ieee80211_hw *hw, static u8 _rtl92c_phy_get_rightchnlplace(u8 chnl) { - u8 place = chnl; + u8 place; if (chnl > 14) { for (place = 14; place < sizeof(channel5g); place++) { From patchwork Tue Aug 3 14:49:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin King X-Patchwork-Id: 12416539 X-Patchwork-Delegate: kuba@kernel.org 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=-18.8 required=3.0 tests=BAYES_00,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 65ADCC4320E for ; Tue, 3 Aug 2021 14:49:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4C3D860F58 for ; Tue, 3 Aug 2021 14:49:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236415AbhHCOuF (ORCPT ); Tue, 3 Aug 2021 10:50:05 -0400 Received: from smtp-relay-canonical-1.canonical.com ([185.125.188.121]:55830 "EHLO smtp-relay-canonical-1.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234524AbhHCOuC (ORCPT ); Tue, 3 Aug 2021 10:50:02 -0400 Received: from localhost (1.general.cking.uk.vpn [10.172.193.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id 0C69B3F0FA; Tue, 3 Aug 2021 14:49:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1628002190; bh=AuuIcnFkWh+0MWsN35BTfKmOqzjfjcwoZ+u0/Q+59dA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=vOBGGw6eyp2iriBNOPZLV0Nhg8P7OFyNNQ+oAgd8xLrM/8Z4Q+O6m+Q/o4D4iyjxX fvYUzcC+l2f1IAnX9jaCNmm9Rv9NYRHBoVC/tZ7kP5SQAzNEtzsC/z7ah+jJ9IXgUC KxEX1Yql0IEYOS9xKgbqezIEDzj2RLW7a1hq8paQioN48IyIf6WbNoWxaWDJwSjwRU oE4VBuoeZ19FQq1yjTaeFaYFIJtgRTn260dygEVDl/FMGsyNfPPKqXUdA/R6WJYIYT 9uKTmidrgNAtZc3wmiU5ikkObfXjmt1RQcoRmk569yy9k7Bufx5znKIOKlKSnJFHpL YYAXG0vc/jQgw== From: Colin King To: Ping-Ke Shih , Kalle Valo , "David S . Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, Joe Perches , linux-kernel@vger.kernel.org Subject: [PATCH 2/3][V2] rtlwifi: rtl8192de: make arrays static const, makes object smaller Date: Tue, 3 Aug 2021 15:49:48 +0100 Message-Id: <20210803144949.79433-2-colin.king@canonical.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210803144949.79433-1-colin.king@canonical.com> References: <20210803144949.79433-1-colin.king@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Colin Ian King Don't populate arrays the stack but instead make them static const. Replace array channel_info with channel_all since it contains the same data as channel_all. Makes object code smaller by 961 bytes. Before: text data bss dec hex filename 128147 44250 1024 173421 2a56d ../realtek/rtlwifi/rtl8192de/phy.o After text data bss dec hex filename 127122 44314 1024 172460 2a1ac ../realtek/rtlwifi/rtl8192de/phy.o (gcc version 10.2.0) Signed-off-by: Colin Ian King --- V2: Remove channel_info and replace with channel_all since it is the same as channel_info. Thanks to Joe Perches for spotting this. --- .../wireless/realtek/rtlwifi/rtl8192de/phy.c | 48 ++++++++----------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c index 50c2d8f6f9c0..8ae69d914312 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c @@ -160,6 +160,15 @@ static u32 targetchnl_2g[TARGET_CHNL_NUM_2G] = { 25711, 25658, 25606, 25554, 25502, 25451, 25328 }; +static const u8 channel_all[59] = { + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, + 60, 62, 64, 100, 102, 104, 106, 108, 110, 112, + 114, 116, 118, 120, 122, 124, 126, 128, 130, + 132, 134, 136, 138, 140, 149, 151, 153, 155, + 157, 159, 161, 163, 165 +}; + static u32 _rtl92d_phy_calculate_bit_shift(u32 bitmask) { u32 i = ffs(bitmask); @@ -1354,14 +1363,6 @@ static void _rtl92d_phy_switch_rf_setting(struct ieee80211_hw *hw, u8 channel) u8 rtl92d_get_rightchnlplace_for_iqk(u8 chnl) { - u8 channel_all[59] = { - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, - 60, 62, 64, 100, 102, 104, 106, 108, 110, 112, - 114, 116, 118, 120, 122, 124, 126, 128, 130, - 132, 134, 136, 138, 140, 149, 151, 153, 155, - 157, 159, 161, 163, 165 - }; u8 place = chnl; if (chnl > 14) { @@ -3220,37 +3221,28 @@ void rtl92d_phy_config_macphymode_info(struct ieee80211_hw *hw) u8 rtl92d_get_chnlgroup_fromarray(u8 chnl) { u8 group; - u8 channel_info[59] = { - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, - 58, 60, 62, 64, 100, 102, 104, 106, 108, - 110, 112, 114, 116, 118, 120, 122, 124, - 126, 128, 130, 132, 134, 136, 138, 140, - 149, 151, 153, 155, 157, 159, 161, 163, - 165 - }; - if (channel_info[chnl] <= 3) + if (channel_all[chnl] <= 3) group = 0; - else if (channel_info[chnl] <= 9) + else if (channel_all[chnl] <= 9) group = 1; - else if (channel_info[chnl] <= 14) + else if (channel_all[chnl] <= 14) group = 2; - else if (channel_info[chnl] <= 44) + else if (channel_all[chnl] <= 44) group = 3; - else if (channel_info[chnl] <= 54) + else if (channel_all[chnl] <= 54) group = 4; - else if (channel_info[chnl] <= 64) + else if (channel_all[chnl] <= 64) group = 5; - else if (channel_info[chnl] <= 112) + else if (channel_all[chnl] <= 112) group = 6; - else if (channel_info[chnl] <= 126) + else if (channel_all[chnl] <= 126) group = 7; - else if (channel_info[chnl] <= 140) + else if (channel_all[chnl] <= 140) group = 8; - else if (channel_info[chnl] <= 153) + else if (channel_all[chnl] <= 153) group = 9; - else if (channel_info[chnl] <= 159) + else if (channel_all[chnl] <= 159) group = 10; else group = 11; From patchwork Tue Aug 3 14:49:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin King X-Patchwork-Id: 12416541 X-Patchwork-Delegate: kuba@kernel.org 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=-18.8 required=3.0 tests=BAYES_00,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 B8484C4338F for ; Tue, 3 Aug 2021 14:49:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A107660F35 for ; Tue, 3 Aug 2021 14:49:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236682AbhHCOuH (ORCPT ); Tue, 3 Aug 2021 10:50:07 -0400 Received: from smtp-relay-canonical-1.canonical.com ([185.125.188.121]:55850 "EHLO smtp-relay-canonical-1.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235368AbhHCOuC (ORCPT ); Tue, 3 Aug 2021 10:50:02 -0400 Received: from localhost (1.general.cking.uk.vpn [10.172.193.212]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id 7AEE73F0FF; Tue, 3 Aug 2021 14:49:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1628002190; bh=OSXLs7UOCDaUH/Z2FsCqFS59Zra8YYCA6HkdQfm7sZs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=Hg+RoLzmfw1V6/+4j87RoskXSf8QvgpdifyL0u9L6WCu0Dfd1NG/wkWZcAdNsIoZM /be4sQu/GOR8IZgQn+aZb+Ni6oDufNdQ0pEnm9lSLk1Noje3T6yKt1yZi0jSbS1GNs Lr0iwTqtN/uPqcdlxTEd3ZZQ6mb59ctSeEqW4DCw0NtLr0QP93gCC2Px8QZquLs5t3 u7Cc45+7pyX+rdTKNGtaWG84QP1Di6JwoKWTDNfZ7CNAL9i3CGMPzsGPDI+Z/3BwRZ WUAsCd//Q67GcvTbZY9VzC6/nUPUukrmECBHp7wYVW8Lb2HRbnCsTg5Q5PNGMWzzup 5K+PqEdEtF2mQ== From: Colin King To: Ping-Ke Shih , Kalle Valo , "David S . Miller" , Jakub Kicinski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, Joe Perches , linux-kernel@vger.kernel.org Subject: [PATCH 3/3] rtlwifi: rtl8192de: fix array size limit in for-loop Date: Tue, 3 Aug 2021 15:49:49 +0100 Message-Id: <20210803144949.79433-3-colin.king@canonical.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210803144949.79433-1-colin.king@canonical.com> References: <20210803144949.79433-1-colin.king@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Colin Ian King Currently the size of the entire array is being used in a for-loop for the element count. While this works since the elements are u8 sized, it is preferred to use ARRAY_SIZE to get the element count of the array. Kudos to Joe Perches for spotting this issue. Signed-off-by: Colin Ian King --- drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c index 8ae69d914312..e11728622a9e 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c @@ -1366,7 +1366,7 @@ u8 rtl92d_get_rightchnlplace_for_iqk(u8 chnl) u8 place = chnl; if (chnl > 14) { - for (place = 14; place < sizeof(channel_all); place++) { + for (place = 14; place < ARRAY_SIZE(channel_all); place++) { if (channel_all[place] == chnl) return place - 13; }