lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c0f6c6c3b87c4d048ad9f42dc1dfaed9@realtek.com>
Date: Thu, 17 Oct 2024 01:21:54 +0000
From: Ping-Ke Shih <pkshih@...ltek.com>
To: Mohammed Anees <pvmohammedanees2003@...il.com>,
        "linux-wireless@...r.kernel.org" <linux-wireless@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
CC: Kalle Valo <kvalo@...nel.org>
Subject: RE: [PATCH] wifi: rtw88: Refactor looping in rtw_phy_store_tx_power_by_rate

Mohammed Anees <pvmohammedanees2003@...il.com> wrote:
> 
> The previous implementation performs check for the band
> in each iteration, which is unnecessary and further more
> there is a else condition which will never get triggered,

I feel compilers can optimize the check for the band, and we can just remove
the else condition. Or 
   if (2ghz)
      foo_2g();
   else
      foo_5g();


> since a check is done to see if the band is either 2G or
> 5G earlier and the band either be any of those 2. We can
> refactor this by assigning a pointer to the appropriate
> power offset array based on the band before the loop and
> updating this.
> 
> Signed-off-by: Mohammed Anees <pvmohammedanees2003@...il.com>
> ---
>  drivers/net/wireless/realtek/rtw88/phy.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/wireless/realtek/rtw88/phy.c b/drivers/net/wireless/realtek/rtw88/phy.c
> index 37ef80c9091d..17d61f1d9257 100644
> --- a/drivers/net/wireless/realtek/rtw88/phy.c
> +++ b/drivers/net/wireless/realtek/rtw88/phy.c
> @@ -1465,15 +1465,14 @@ static void rtw_phy_store_tx_power_by_rate(struct rtw_dev *rtwdev,
>                     rate_num > RTW_RF_PATH_MAX))
>                 return;
> 
> +       s8 (*tx_pwr_by_rate_offset) = (band == PHY_BANK_2G)
> +                                               ? hal->tx_pwr_by_rate_offset_2g[rfpath]
> +                                               : hal->tx_pwr_by_rate_offset_5g[rfpath];
> +

Though -Wdeclaration-after-statement was dropped, still recommend to place
declarations at the beginning of function.

The operands ? and : should place at the end of statement. 

x = y ?
    z0 :
    z1;


>         for (i = 0; i < rate_num; i++) {
>                 offset = pwr_by_rate[i];
>                 rate = rates[i];
> -               if (band == PHY_BAND_2G)
> -                       hal->tx_pwr_by_rate_offset_2g[rfpath][rate] = offset;
> -               else if (band == PHY_BAND_5G)
> -                       hal->tx_pwr_by_rate_offset_5g[rfpath][rate] = offset;
> -               else
> -                       continue;
> +               tx_pwr_by_rate_offset[rate] = offset;
>         }
>  }
> 
> --
> 2.47.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ