From patchwork Thu Nov 10 13:58:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bitterblue Smith X-Patchwork-Id: 624785 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40D52C433FE for ; Thu, 10 Nov 2022 13:58:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230020AbiKJN6V (ORCPT ); Thu, 10 Nov 2022 08:58:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231283AbiKJN6V (ORCPT ); Thu, 10 Nov 2022 08:58:21 -0500 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31F077019D for ; Thu, 10 Nov 2022 05:58:20 -0800 (PST) Received: by mail-ej1-x62b.google.com with SMTP id y14so5136736ejd.9 for ; Thu, 10 Nov 2022 05:58:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:subject:from:cc:to:content-language :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=OPA4/BHM5mWGZAGUL4tFe00eB1HaHi/U7muTCPGJQII=; b=Cupq99lMU20urfJUjgi3jjD0mKOmTezWmDUPmyARurKqnRyK/d8+KDSiIe0yDjz4MQ YJ2f47cm1STtAhYYx/ZS6WfLs7/YtA0kWeDCbNRnAZPOSNPSsmkvQ7LSX93Lc+TCqNUF Zi++pjW5PfGegqtOMOCmRqbp/yi4Mkop4hhUPt4DMs3l0VFsfK5jKffB1t+LhziC8pb+ KynhCoB8IpT5gfjJkGsKbRzu81LJcj06091Sk3TqBMou0NoIGxeqqhubaB41c9ksCZRE Kx1wzw+wm2AHvT2PSdSHmXQhfh934k4HYROHp0bOCLbsaNraZDpfUVC6aBs0sPoRcHdk uMHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:subject:from:cc:to:content-language :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=OPA4/BHM5mWGZAGUL4tFe00eB1HaHi/U7muTCPGJQII=; b=i6GNGJKt3kZvWbn5KPiIjCdkX3/uCGtjJE+Vnecl8wxXyIq8WOOCZqAdbxyYT6ITu9 zUCrhZR6O+VwsnxLavPyoMPdcnQlAWQWxj9c0fvxuzVunhWtPYcdFJDG4lBIO1RZfgwK b205lFL7ZSjfCcG4xOS6VtZ3Qh7/l19LTFQftZrG7FeJSgesxvpkDkcLCgTnIAun+r0K QuR7XrUOi1Hx3lX0NYZfIoSNucJzkfiq/Z+1EL0C4A36pi+zZT+5FKcmllGj7EUGeCrW 5Rt1gMRbk/c18IrcAoBUjzOePHEQRioUDUOyYUQoakZCtub3hBLxFbC/Ap4htuXrd4ku ywbg== X-Gm-Message-State: ACrzQf3sYORpSuL6JKTf7TpnWb9rlRiOBm8y72cYVXcp78EUFO/s8m1j GBt8FZoMKWdFSJEjS6mBgAgMejw0Opo= X-Google-Smtp-Source: AMsMyM5z8nL8gxeT2DDJ26P7E/dQ2O4D3IS8VKwOtMFynSO6bNYFDbnMXaRzopp2wuCglG89/ueWEQ== X-Received: by 2002:a17:906:11d3:b0:782:2d3e:6340 with SMTP id o19-20020a17090611d300b007822d3e6340mr2871840eja.234.1668088698626; Thu, 10 Nov 2022 05:58:18 -0800 (PST) Received: from [192.168.1.50] ([81.196.40.23]) by smtp.gmail.com with ESMTPSA id es11-20020a056402380b00b0045bd257b307sm8436131edb.22.2022.11.10.05.58.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 10 Nov 2022 05:58:18 -0800 (PST) Message-ID: Date: Thu, 10 Nov 2022 15:58:16 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.3 Content-Language: en-US To: "linux-wireless@vger.kernel.org" Cc: Jes Sorensen , Ping-Ke Shih From: Bitterblue Smith Subject: [PATCH v2 1/3] wifi: rtl8xxxu: Name some bits used in burst init Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Use descriptive names instead of magic numbers. Suggested-by: Ping-Ke Shih Signed-off-by: Bitterblue Smith --- v2: - Change the commit message. --- drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 10 +++++----- drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h | 6 ++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c index 839e0546f5ec..e4eb17d03cd7 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c @@ -3786,16 +3786,16 @@ void rtl8xxxu_init_burst(struct rtl8xxxu_priv *priv) * For USB high speed set 512B packets */ val8 = rtl8xxxu_read8(priv, REG_RXDMA_PRO_8723B); - val8 &= ~(BIT(4) | BIT(5)); - val8 |= BIT(4); - val8 |= BIT(1) | BIT(2) | BIT(3); + u8p_replace_bits(&val8, 1, RXDMA_PRO_DMA_BURST_SIZE); + u8p_replace_bits(&val8, 3, RXDMA_PRO_DMA_BURST_CNT); + val8 |= RXDMA_PRO_DMA_MODE; rtl8xxxu_write8(priv, REG_RXDMA_PRO_8723B, val8); /* * Enable single packet AMPDU */ val8 = rtl8xxxu_read8(priv, REG_HT_SINGLE_AMPDU_8723B); - val8 |= BIT(7); + val8 |= HT_SINGLE_AMPDU_ENABLE; rtl8xxxu_write8(priv, REG_HT_SINGLE_AMPDU_8723B, val8); rtl8xxxu_write16(priv, REG_MAX_AGGR_NUM, 0x0c14); @@ -3820,7 +3820,7 @@ void rtl8xxxu_init_burst(struct rtl8xxxu_priv *priv) /* to prevent mac is reseted by bus. */ val8 = rtl8xxxu_read8(priv, REG_RSV_CTRL); - val8 |= BIT(5) | BIT(6); + val8 |= RSV_CTRL_WLOCK_1C | RSV_CTRL_DIS_PRST; rtl8xxxu_write8(priv, REG_RSV_CTRL, val8); } diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h index 04bf77959fba..5d4cac4f4c06 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h @@ -68,6 +68,8 @@ #define REG_SPS_OCP_CFG 0x0018 #define REG_8192E_LDOV12_CTRL 0x0014 #define REG_RSV_CTRL 0x001c +#define RSV_CTRL_WLOCK_1C BIT(5) +#define RSV_CTRL_DIS_PRST BIT(6) #define REG_RF_CTRL 0x001f #define RF_ENABLE BIT(0) @@ -472,6 +474,9 @@ /* Presumably only found on newer chips such as 8723bu */ #define REG_RX_DMA_CTRL_8723B 0x0286 #define REG_RXDMA_PRO_8723B 0x0290 +#define RXDMA_PRO_DMA_MODE BIT(1) /* Set to 0x1. */ +#define RXDMA_PRO_DMA_BURST_CNT GENMASK(3, 2) /* Set to 0x3. */ +#define RXDMA_PRO_DMA_BURST_SIZE GENMASK(5, 4) /* Set to 0x1. */ #define REG_RF_BB_CMD_ADDR 0x02c0 #define REG_RF_BB_CMD_DATA 0x02c4 @@ -577,6 +582,7 @@ #define REG_STBC_SETTING 0x04c4 #define REG_QUEUE_CTRL 0x04c6 #define REG_HT_SINGLE_AMPDU_8723B 0x04c7 +#define HT_SINGLE_AMPDU_ENABLE BIT(7) #define REG_PROT_MODE_CTRL 0x04c8 #define REG_MAX_AGGR_NUM 0x04ca #define REG_RTS_MAX_AGGR_NUM 0x04cb From patchwork Thu Nov 10 13:59:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bitterblue Smith X-Patchwork-Id: 623662 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C612C433FE for ; Thu, 10 Nov 2022 13:59:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230102AbiKJN7e (ORCPT ); Thu, 10 Nov 2022 08:59:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229763AbiKJN7d (ORCPT ); Thu, 10 Nov 2022 08:59:33 -0500 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3821C19C19 for ; Thu, 10 Nov 2022 05:59:32 -0800 (PST) Received: by mail-ed1-x52f.google.com with SMTP id u24so3163906edd.13 for ; Thu, 10 Nov 2022 05:59:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=r5qrvMRjYp2MjZ83UWi9SzdbxwdoJBFIb7DywDX9xjk=; b=eBFtLrjrnKJZZ+CDUDYOIIQ7Tmg5QJTgOigUxEWxh6f+kstic4ACCfZMblFFph00T4 E9qFzz+6V0vDzM5mf67lAutRQHlWcM+pLJQ2+lfiZtLnO96KM+HPsGGN6kn6U/l8nswx SYCETknz+FthPx7v4yQY9zkoUs/1tZWVAxM1wYlbDo0dfLURKClEgYrKZJ6as3GRu2xx yqiNdNPPsi4EM27YWTpurXiL4E0RjsC4bhJ5SqXvyEUNProDVbJcG690lKzzy8ELXvqf dGHJ3OuBCXPqoiDG3wohMhR8v38bh4koHprPwuWVL6jmo1Fu+BwztMT53zwTP7/cp72j o9Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=r5qrvMRjYp2MjZ83UWi9SzdbxwdoJBFIb7DywDX9xjk=; b=nWuMgyEUcHpw97EaJW6V6GMbbFBSYkBf3Fadvu697/TtlDtLso4mxRtQnbl3cm/9WU WVSuIX0z/7UDJOwmgK1OtNeRIDlctCrkcJ24odnzdM5Yg7w3Fr3mMtna+riAd5qTQnfH vWFlMylHxsPRjpygMJdP1QhdPjlyVr+y+ZKdAGpOcDW1GpSuRaj/AaG2AeGO9SejN7Yz ypIVRxjjJqm9llNkuQYmTosZyui1kZlSPtWG47PmDpnwAYhYQltVZxhOSkyzqTODu26B a8hjmo8bdp8jPn8Z4UTwV4jhoS1CwPvDVBTdcLLVMN+AXpoW7B56mlSja+atK+Wr21+s lT4w== X-Gm-Message-State: ACrzQf2hCfuE5n2uHPlPYcdgyCaDbhhJWaqYXZFKYDs6v16vbvvX4nB3 b7bCvrF777Dg3KRbH0c4Wqj4JOTuaUQ= X-Google-Smtp-Source: AMsMyM5ggRy4g1IqCuWJ5TyvBCqFARmMSdlu1IltKlrclubUT4Pc3w8zzlffsu6KFG3xTGESsIs8nw== X-Received: by 2002:a05:6402:22a5:b0:462:b393:f281 with SMTP id cx5-20020a05640222a500b00462b393f281mr63684721edb.379.1668088770615; Thu, 10 Nov 2022 05:59:30 -0800 (PST) Received: from [192.168.1.50] ([81.196.40.23]) by smtp.gmail.com with ESMTPSA id a10-20020a1709066d4a00b00730bfe6adc4sm7269873ejt.37.2022.11.10.05.59.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 10 Nov 2022 05:59:30 -0800 (PST) Message-ID: <5fc9cc0e-eecb-8428-aeb1-f745791c0f16@gmail.com> Date: Thu, 10 Nov 2022 15:59:29 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.3 Subject: [PATCH v2 2/3] wifi: rtl8xxxu: Use strscpy instead of sprintf Content-Language: en-US From: Bitterblue Smith To: "linux-wireless@vger.kernel.org" Cc: Jes Sorensen , Ping-Ke Shih References: In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Fill priv->chip_name and priv->chip_vendor with strscpy instead of sprintf. This is just to prevent future bugs in case the name of a chip/vendor becomes longer than the size of chip_name/chip_vendor. Suggested-by: Ping-Ke Shih Signed-off-by: Bitterblue Smith Reviewed-by: Ping-Ke Shih --- v2: - No change. --- .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c | 2 +- .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c | 8 ++++---- .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c | 4 ++-- .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c | 2 +- .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c | 2 +- .../net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 12 ++++++------ 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c index 0f77312dd0ca..ef38891ddbd1 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c @@ -327,7 +327,7 @@ static int rtl8188fu_identify_chip(struct rtl8xxxu_priv *priv) u32 sys_cfg, vendor; int ret = 0; - sprintf(priv->chip_name, "8188FU"); + strscpy(priv->chip_name, "8188FU", sizeof(priv->chip_name)); priv->rtl_chip = RTL8188F; priv->rf_paths = 1; priv->rx_paths = 1; diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c index 815c1e278e4e..6c443e4822d8 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c @@ -345,12 +345,12 @@ int rtl8192cu_identify_chip(struct rtl8xxxu_priv *priv) bonding = rtl8xxxu_read32(priv, REG_HPON_FSM); bonding &= HPON_FSM_BONDING_MASK; if (bonding == HPON_FSM_BONDING_1T2R) { - sprintf(priv->chip_name, "8191CU"); + strscpy(priv->chip_name, "8191CU", sizeof(priv->chip_name)); priv->tx_paths = 1; priv->usb_interrupts = 1; priv->rtl_chip = RTL8191C; } else { - sprintf(priv->chip_name, "8192CU"); + strscpy(priv->chip_name, "8192CU", sizeof(priv->chip_name)); priv->tx_paths = 2; priv->usb_interrupts = 0; priv->rtl_chip = RTL8192C; @@ -358,7 +358,7 @@ int rtl8192cu_identify_chip(struct rtl8xxxu_priv *priv) priv->rf_paths = 2; priv->rx_paths = 2; } else { - sprintf(priv->chip_name, "8188CU"); + strscpy(priv->chip_name, "8188CU", sizeof(priv->chip_name)); priv->rf_paths = 1; priv->rx_paths = 1; priv->tx_paths = 1; @@ -451,7 +451,7 @@ static int rtl8192cu_parse_efuse(struct rtl8xxxu_priv *priv) priv->power_base = &rtl8192c_power_base; if (efuse->rf_regulatory & 0x20) { - sprintf(priv->chip_name, "8188RU"); + strscpy(priv->chip_name, "8188RU", sizeof(priv->chip_name)); priv->rtl_chip = RTL8188R; priv->hi_pa = 1; priv->no_pape = 1; diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c index 7a182073832b..fc3336f18892 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c @@ -496,11 +496,11 @@ int rtl8192eu_identify_chip(struct rtl8xxxu_priv *priv) bonding = rtl8xxxu_read32(priv, REG_HPON_FSM); bonding &= HPON_FSM_BONDING_MASK; if (bonding == HPON_FSM_BONDING_1T2R) { - sprintf(priv->chip_name, "8191EU"); + strscpy(priv->chip_name, "8191EU", sizeof(priv->chip_name)); priv->tx_paths = 1; priv->rtl_chip = RTL8191E; } else { - sprintf(priv->chip_name, "8192EU"); + strscpy(priv->chip_name, "8192EU", sizeof(priv->chip_name)); priv->tx_paths = 2; priv->rtl_chip = RTL8192E; } diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c index 33a1114a5853..c8ab71ed4ff4 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c @@ -144,7 +144,7 @@ static int rtl8723au_identify_chip(struct rtl8xxxu_priv *priv) goto out; } - sprintf(priv->chip_name, "8723AU"); + strscpy(priv->chip_name, "8723AU", sizeof(priv->chip_name)); priv->usb_interrupts = 1; priv->rtl_chip = RTL8723A; diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c index 558572bdd2c8..ece82e613bf0 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c @@ -319,7 +319,7 @@ static int rtl8723bu_identify_chip(struct rtl8xxxu_priv *priv) goto out; } - sprintf(priv->chip_name, "8723BU"); + strscpy(priv->chip_name, "8723BU", sizeof(priv->chip_name)); priv->rtl_chip = RTL8723B; priv->rf_paths = 1; priv->rx_paths = 1; diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c index e4eb17d03cd7..e8fcd531c437 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c @@ -1592,10 +1592,10 @@ static void rtl8xxxu_print_chipinfo(struct rtl8xxxu_priv *priv) void rtl8xxxu_identify_vendor_1bit(struct rtl8xxxu_priv *priv, u32 vendor) { if (vendor) { - sprintf(priv->chip_vendor, "UMC"); + strscpy(priv->chip_vendor, "UMC", sizeof(priv->chip_vendor)); priv->vendor_umc = 1; } else { - sprintf(priv->chip_vendor, "TSMC"); + strscpy(priv->chip_vendor, "TSMC", sizeof(priv->chip_vendor)); } } @@ -1603,18 +1603,18 @@ void rtl8xxxu_identify_vendor_2bits(struct rtl8xxxu_priv *priv, u32 vendor) { switch (vendor) { case SYS_CFG_VENDOR_ID_TSMC: - sprintf(priv->chip_vendor, "TSMC"); + strscpy(priv->chip_vendor, "TSMC", sizeof(priv->chip_vendor)); break; case SYS_CFG_VENDOR_ID_SMIC: - sprintf(priv->chip_vendor, "SMIC"); + strscpy(priv->chip_vendor, "SMIC", sizeof(priv->chip_vendor)); priv->vendor_smic = 1; break; case SYS_CFG_VENDOR_ID_UMC: - sprintf(priv->chip_vendor, "UMC"); + strscpy(priv->chip_vendor, "UMC", sizeof(priv->chip_vendor)); priv->vendor_umc = 1; break; default: - sprintf(priv->chip_vendor, "unknown"); + strscpy(priv->chip_vendor, "unknown", sizeof(priv->chip_vendor)); } } From patchwork Thu Nov 10 14:01:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bitterblue Smith X-Patchwork-Id: 624784 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88F9FC433FE for ; Thu, 10 Nov 2022 14:01:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229673AbiKJOBX (ORCPT ); Thu, 10 Nov 2022 09:01:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229547AbiKJOBW (ORCPT ); Thu, 10 Nov 2022 09:01:22 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BA521DD for ; Thu, 10 Nov 2022 06:01:21 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id 5so1200988wmo.1 for ; Thu, 10 Nov 2022 06:01:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=+4Owka3zXw7FCcRApOZHVfZ/AlQV5eZ52vqP+e4YGZg=; b=Y7f13J7jAPfk3kJFcXiBWnn+1T2ugoLoD5/gxpEGpkmjBZoiZaaId9HpO16/9DUThO FPjFUnm4qJgk4gm5+ORJZYlcSoa/K9guYcnM2vGbXEHW6WIggHogIUpPT0ERmmBxfwK7 Vvq1wWmOMwjVFiNdHVq6OS36ciknssQlpk6FsnVzyvyaOha3H1wyEOoNH5YNT7WWa6ZP qke/fgNe36XrkCDxbHvyVpqQmGh0WDcpKF/3pfGjrPyQxUPmfHvKwsEywtxk+F89KMO4 1/uDXKq4twUi47RKTbPSHvzexrSrNb/5MQFbnIGpPK9mrtLYTAOoko2dqM5XWDC3u/bE IrxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+4Owka3zXw7FCcRApOZHVfZ/AlQV5eZ52vqP+e4YGZg=; b=kJodYxsSXy9EkZYeM6WSjtVDQFiV5li/nd0ftqqvmSBNaAYlyQFFOuP/SIwNj4jE/i 2tUtXT09/URLyEIyShPRry/JhR6qXORc/sGGyC/GA/YuHmXVeJoctBVU0UCQ3g8g95E4 MuYsGFI1+ZjUBEV6wEgIQOI3YWRaPMR3iH8L3IsWAlq3wuZ1WFugZ40/0wC/0BItOPvo /NV5yCwdhlSE0IEn7aeLT3dQko1fUS644Mv1KXC/17ZNAHwPDN7Ip8lKS7C7/mhTBp4o GPVnfbtWGFty7tiw/Xi6YbiW8e00GJVDssCyoc5ju5rFKA8zNcoKS7oc7lVHy6vQtVHp J80Q== X-Gm-Message-State: ACrzQf1HtwgIxxDX71AVe72giSDpeskwEW5DqhvKBoM0rHfkOK7Tdf5a WoNmJ8pDqgdNdmnqAKNilWSeDKVnYjM= X-Google-Smtp-Source: AMsMyM7QGjRVPyR680y/VmlrvcNdeurRkvJ9GJf31IcUr6AtlHM/7TI9iqx0qaqY2lUjL+JRzAkdtg== X-Received: by 2002:a05:600c:491c:b0:3cf:7336:8704 with SMTP id f28-20020a05600c491c00b003cf73368704mr36279127wmp.101.1668088879713; Thu, 10 Nov 2022 06:01:19 -0800 (PST) Received: from [192.168.1.50] ([81.196.40.23]) by smtp.gmail.com with ESMTPSA id u24-20020a7bc058000000b003b476cabf1csm5134689wmc.26.2022.11.10.06.01.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 10 Nov 2022 06:01:19 -0800 (PST) Message-ID: <68f94284-3728-7b75-2b7b-64fae8af6bc5@gmail.com> Date: Thu, 10 Nov 2022 16:01:18 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.3 Subject: [PATCH v2 3/3] wifi: rtl8xxxu: Use u32_get_bits in *_identify_chip Content-Language: en-US From: Bitterblue Smith To: "linux-wireless@vger.kernel.org" Cc: Jes Sorensen , Ping-Ke Shih References: In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org It simplifies the code a bit. Suggested-by: Ping-Ke Shih Signed-off-by: Bitterblue Smith --- v2: - No change. --- drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c | 3 +-- drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c | 5 ++--- drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c | 5 ++--- drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c | 5 ++--- drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c | 5 ++--- drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h | 1 - 6 files changed, 9 insertions(+), 15 deletions(-) diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c index ef38891ddbd1..2c4f403ba68f 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8188f.c @@ -335,8 +335,7 @@ static int rtl8188fu_identify_chip(struct rtl8xxxu_priv *priv) priv->has_wifi = 1; sys_cfg = rtl8xxxu_read32(priv, REG_SYS_CFG); - priv->chip_cut = (sys_cfg & SYS_CFG_CHIP_VERSION_MASK) >> - SYS_CFG_CHIP_VERSION_SHIFT; + priv->chip_cut = u32_get_bits(sys_cfg, SYS_CFG_CHIP_VERSION_MASK); if (sys_cfg & SYS_CFG_TRP_VAUX_EN) { dev_info(dev, "Unsupported test chip\n"); ret = -ENOTSUPP; diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c index 6c443e4822d8..e7190cb2e5a3 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192c.c @@ -333,8 +333,7 @@ int rtl8192cu_identify_chip(struct rtl8xxxu_priv *priv) int ret = 0; sys_cfg = rtl8xxxu_read32(priv, REG_SYS_CFG); - priv->chip_cut = (sys_cfg & SYS_CFG_CHIP_VERSION_MASK) >> - SYS_CFG_CHIP_VERSION_SHIFT; + priv->chip_cut = u32_get_bits(sys_cfg, SYS_CFG_CHIP_VERSION_MASK); if (sys_cfg & SYS_CFG_TRP_VAUX_EN) { dev_info(dev, "Unsupported test chip\n"); ret = -ENOTSUPP; @@ -371,7 +370,7 @@ int rtl8192cu_identify_chip(struct rtl8xxxu_priv *priv) rtl8xxxu_identify_vendor_1bit(priv, vendor); val32 = rtl8xxxu_read32(priv, REG_GPIO_OUTSTS); - priv->rom_rev = (val32 & GPIO_RF_RL_ID) >> 28; + priv->rom_rev = u32_get_bits(val32, GPIO_RF_RL_ID); rtl8xxxu_config_endpoints_sie(priv); diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c index fc3336f18892..bdb79dc18f06 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8192e.c @@ -485,8 +485,7 @@ int rtl8192eu_identify_chip(struct rtl8xxxu_priv *priv) int ret = 0; sys_cfg = rtl8xxxu_read32(priv, REG_SYS_CFG); - priv->chip_cut = (sys_cfg & SYS_CFG_CHIP_VERSION_MASK) >> - SYS_CFG_CHIP_VERSION_SHIFT; + priv->chip_cut = u32_get_bits(sys_cfg, SYS_CFG_CHIP_VERSION_MASK); if (sys_cfg & SYS_CFG_TRP_VAUX_EN) { dev_info(dev, "Unsupported test chip\n"); ret = -ENOTSUPP; @@ -512,7 +511,7 @@ int rtl8192eu_identify_chip(struct rtl8xxxu_priv *priv) rtl8xxxu_identify_vendor_2bits(priv, vendor); val32 = rtl8xxxu_read32(priv, REG_GPIO_OUTSTS); - priv->rom_rev = (val32 & GPIO_RF_RL_ID) >> 28; + priv->rom_rev = u32_get_bits(val32, GPIO_RF_RL_ID); rtl8xxxu_config_endpoints_sie(priv); diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c index c8ab71ed4ff4..707ac48ecc83 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723a.c @@ -136,8 +136,7 @@ static int rtl8723au_identify_chip(struct rtl8xxxu_priv *priv) int ret = 0; sys_cfg = rtl8xxxu_read32(priv, REG_SYS_CFG); - priv->chip_cut = (sys_cfg & SYS_CFG_CHIP_VERSION_MASK) >> - SYS_CFG_CHIP_VERSION_SHIFT; + priv->chip_cut = u32_get_bits(sys_cfg, SYS_CFG_CHIP_VERSION_MASK); if (sys_cfg & SYS_CFG_TRP_VAUX_EN) { dev_info(dev, "Unsupported test chip\n"); ret = -ENOTSUPP; @@ -165,7 +164,7 @@ static int rtl8723au_identify_chip(struct rtl8xxxu_priv *priv) rtl8xxxu_identify_vendor_1bit(priv, vendor); val32 = rtl8xxxu_read32(priv, REG_GPIO_OUTSTS); - priv->rom_rev = (val32 & GPIO_RF_RL_ID) >> 28; + priv->rom_rev = u32_get_bits(val32, GPIO_RF_RL_ID); rtl8xxxu_config_endpoints_sie(priv); diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c index ece82e613bf0..a0ec895b61a4 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_8723b.c @@ -311,8 +311,7 @@ static int rtl8723bu_identify_chip(struct rtl8xxxu_priv *priv) int ret = 0; sys_cfg = rtl8xxxu_read32(priv, REG_SYS_CFG); - priv->chip_cut = (sys_cfg & SYS_CFG_CHIP_VERSION_MASK) >> - SYS_CFG_CHIP_VERSION_SHIFT; + priv->chip_cut = u32_get_bits(sys_cfg, SYS_CFG_CHIP_VERSION_MASK); if (sys_cfg & SYS_CFG_TRP_VAUX_EN) { dev_info(dev, "Unsupported test chip\n"); ret = -ENOTSUPP; @@ -338,7 +337,7 @@ static int rtl8723bu_identify_chip(struct rtl8xxxu_priv *priv) rtl8xxxu_identify_vendor_2bits(priv, vendor); val32 = rtl8xxxu_read32(priv, REG_GPIO_OUTSTS); - priv->rom_rev = (val32 & GPIO_RF_RL_ID) >> 28; + priv->rom_rev = u32_get_bits(val32, GPIO_RF_RL_ID); rtl8xxxu_config_endpoints_sie(priv); diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h index 5d4cac4f4c06..3e79efdfb4c2 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_regs.h @@ -315,7 +315,6 @@ #define SYS_CFG_SPS_SEL BIT(24) /* 1:LDO regulator mode; 0:Switching regulator mode*/ #define SYS_CFG_CHIP_VERSION_MASK 0xf000 /* Bit 12 - 15 */ -#define SYS_CFG_CHIP_VERSION_SHIFT 12 #define REG_GPIO_OUTSTS 0x00f4 /* For RTL8723 only. */ #define GPIO_EFS_HCI_SEL (BIT(0) | BIT(1))