linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ping-Ke Shih <pkshih@realtek.com>
To: Dmitry Antipov <dmantipov@yandex.ru>
Cc: Kalle Valo <kvalo@kernel.org>,
	"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
	"lvc-project@linuxtesting.org" <lvc-project@linuxtesting.org>
Subject: RE: [PATCH 1/2] wifi: rtlwifi: remove dead code in phy_get_tx_swing_8812A()
Date: Mon, 6 Nov 2023 03:37:21 +0000	[thread overview]
Message-ID: <e6ae1e6e46d74b3092b28bd17acbefd3@realtek.com> (raw)
In-Reply-To: <20231101113510.51290-1-dmantipov@yandex.ru>



> -----Original Message-----
> From: Dmitry Antipov <dmantipov@yandex.ru>
> Sent: Wednesday, November 1, 2023 7:35 PM
> To: Ping-Ke Shih <pkshih@realtek.com>
> Cc: Kalle Valo <kvalo@kernel.org>; linux-wireless@vger.kernel.org; lvc-project@linuxtesting.org; Dmitry
> Antipov <dmantipov@yandex.ru>
> Subject: [PATCH 1/2] wifi: rtlwifi: remove dead code in phy_get_tx_swing_8812A()
> 
> Since 'reg_swing_2g', 'swing_2g', 'reg_swing_5g', and 'swing_5g'
> are compile-time constants, mark all of them as such and remove
> never executed blocks in 'phy_get_tx_swing_8812A()'. Minor style
> adjustments, compile tested only.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
> ---
>  .../wireless/realtek/rtlwifi/rtl8821ae/phy.c  | 77 ++++---------------
>  1 file changed, 16 insertions(+), 61 deletions(-)
> 
> diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c
> b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c
> index 5323ead30db0..c262770fea29 100644
> --- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c
> +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c
> @@ -437,12 +437,11 @@ u32 phy_get_tx_swing_8812A(struct ieee80211_hw *hw, u8    band,
>         struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
>         struct rtl_dm *rtldm = rtl_dm(rtlpriv);
>         struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
> -       s8 reg_swing_2g = -1;/* 0xff; */
> -       s8 reg_swing_5g = -1;/* 0xff; */
> -       s8 swing_2g = -1 * reg_swing_2g;
> -       s8 swing_5g = -1 * reg_swing_5g;
> -       u32  out = 0x200;
> -       const s8 auto_temp = -1;
> +       const s8 reg_swing_2g = -1; /* 0xff; */
> +       const s8 reg_swing_5g = -1; /* 0xff; */

Looks like these two can be removed, but I don't really understand what it
wants originally.

> +       const s8 swing_2g = -1 * reg_swing_2g;
> +       const s8 swing_5g = -1 * reg_swing_5g;
> +       u32 out = 0x200;
> 
>         rtl_dbg(rtlpriv, COMP_SCAN, DBG_LOUD,
>                 "===> PHY_GetTXBBSwing_8812A, bbSwing_2G: %d, bbSwing_5G: %d,autoload_failflag=%d.\n",
> @@ -452,36 +451,16 @@ u32 phy_get_tx_swing_8812A(struct ieee80211_hw *hw, u8    band,
>         if (rtlefuse->autoload_failflag) {
>                 if (band == BAND_ON_2_4G) {
>                         rtldm->swing_diff_2g = swing_2g;
> -                       if (swing_2g == 0) {
> -                               out = 0x200; /* 0 dB */
> -                       } else if (swing_2g == -3) {
> -                               out = 0x16A; /* -3 dB */
> -                       } else if (swing_2g == -6) {
> -                               out = 0x101; /* -6 dB */
> -                       } else if (swing_2g == -9) {
> -                               out = 0x0B6; /* -9 dB */
> -                       } else {
> -                               rtldm->swing_diff_2g = 0;
> -                               out = 0x200;
> -                       }
> +                       rtldm->swing_diff_2g = 0;
> +                       out = 0x200;

This branch becomes duplicate assignments of swing_diff_2g. 
    rtldm->swing_diff_2g = swing_2g;
    rtldm->swing_diff_2g = 0;
    out = 0x200;

The original branch chunk might be debug purpose, so maybe add a debugfs entry as
the input of 'swing_2g'. Or, that is used by some boards that don't programmed efuse
but read 'swing_2g' from external file.


It is hard to me to decide if we should take this cleanup.

Ping-Ke



      parent reply	other threads:[~2023-11-06  3:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-01 11:35 [PATCH 1/2] wifi: rtlwifi: remove dead code in phy_get_tx_swing_8812A() Dmitry Antipov
2023-11-01 11:35 ` [PATCH 2/2] wifi: rtlwifi: simplify _rtl8812ae_phy_get_txpower_limit() Dmitry Antipov
2023-11-06  3:44   ` Ping-Ke Shih
2023-11-06  3:37 ` Ping-Ke Shih [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e6ae1e6e46d74b3092b28bd17acbefd3@realtek.com \
    --to=pkshih@realtek.com \
    --cc=dmantipov@yandex.ru \
    --cc=kvalo@kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).