mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mohammed Anees <pvmohammedanees2003@gmail.com>
To: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Ping-Ke Shih <pkshih@realtek.com>, Kalle Valo <kvalo@kernel.org>,
	Mohammed Anees <pvmohammedanees2003@gmail.com>
Subject: [PATCH] wifi: rtw88: Refactor looping in rtw_phy_store_tx_power_by_rate
Date: Wed, 16 Oct 2024 11:36:05 +0530	[thread overview]
Message-ID: <20241016060605.11359-1-pvmohammedanees2003@gmail.com> (raw)

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,
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@gmail.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];
+
 	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


             reply	other threads:[~2024-10-16  6:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-16  6:06 Mohammed Anees [this message]
2024-10-17  1:21 ` Ping-Ke Shih
2024-10-17  6:56   ` Mohammed Anees
2024-10-17  7:06     ` Ping-Ke Shih
2024-10-17  7:12       ` Mohammed Anees
2024-10-17  3:19 ` kernel test robot

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=20241016060605.11359-1-pvmohammedanees2003@gmail.com \
    --to=pvmohammedanees2003@gmail.com \
    --cc=kvalo@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=pkshih@realtek.com \
    /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

all inboxes | Powered by JetHome®