Commit 94cd0ba1 authored by Qianfeng Rong's avatar Qianfeng Rong Committed by Ping-Ke Shih
Browse files

wifi: rtlwifi: Use min()/max() to improve code



Use min()/max() to reduce the code and improve its readability.

Acked-by: default avatarPing-Ke Shih <pkshih@realtek.com>
Signed-off-by: default avatarQianfeng Rong <rongqianfeng@vivo.com>
Signed-off-by: default avatarPing-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250715121721.266713-8-rongqianfeng@vivo.com
parent 37c23874
Loading
Loading
Loading
Loading
+3 −16
Original line number Diff line number Diff line
@@ -1487,22 +1487,9 @@ _rtl92ce_read_txpower_info_from_hwpg(struct ieee80211_hw *hw,
			rtlefuse->txpwrlevel_ht40_1s[rf_path][i] =
			    rtlefuse->
			    eeprom_chnlarea_txpwr_ht40_1s[rf_path][index];

			if ((rtlefuse->
			     eeprom_chnlarea_txpwr_ht40_1s[rf_path][index] -
			     rtlefuse->
			     eprom_chnl_txpwr_ht40_2sdf[rf_path][index])
			    > 0) {
			rtlefuse->txpwrlevel_ht40_2s[rf_path][i] =
				    rtlefuse->
				    eeprom_chnlarea_txpwr_ht40_1s[rf_path]
				    [index] -
				    rtlefuse->
				    eprom_chnl_txpwr_ht40_2sdf[rf_path]
				    [index];
			} else {
				rtlefuse->txpwrlevel_ht40_2s[rf_path][i] = 0;
			}
				max(rtlefuse->eeprom_chnlarea_txpwr_ht40_1s[rf_path][index] -
				    rtlefuse->eprom_chnl_txpwr_ht40_2sdf[rf_path][index], 0);
		}

		for (i = 0; i < 14; i++) {
+3 −14
Original line number Diff line number Diff line
@@ -163,20 +163,9 @@ _rtl92cu_read_txpower_info_from_hwpg(struct ieee80211_hw *hw,
			rtlefuse->txpwrlevel_ht40_1s[rf_path][i] =
			    rtlefuse->
			    eeprom_chnlarea_txpwr_ht40_1s[rf_path][index];
			if ((rtlefuse->
			     eeprom_chnlarea_txpwr_ht40_1s[rf_path][index] -
			     rtlefuse->
			     eprom_chnl_txpwr_ht40_2sdf[rf_path][index])
			    > 0) {
			rtlefuse->txpwrlevel_ht40_2s[rf_path][i] =
				    rtlefuse->
				    eeprom_chnlarea_txpwr_ht40_1s[rf_path]
				    [index] - rtlefuse->
				    eprom_chnl_txpwr_ht40_2sdf[rf_path]
				    [index];
			} else {
				rtlefuse->txpwrlevel_ht40_2s[rf_path][i] = 0;
			}
				max(rtlefuse->eeprom_chnlarea_txpwr_ht40_1s[rf_path][index] -
				    rtlefuse->eprom_chnl_txpwr_ht40_2sdf[rf_path][index], 0);
		}
		for (i = 0; i < 14; i++) {
			RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
+1 −4
Original line number Diff line number Diff line
@@ -223,10 +223,7 @@ static void rtl92ee_dm_dig(struct ieee80211_hw *hw)

	if (mac->link_state >= MAC80211_LINKED) {
		if (bfirstconnect) {
			if (dm_dig->rssi_val_min <= dig_maxofmin)
				current_igi = dm_dig->rssi_val_min;
			else
				current_igi = dig_maxofmin;
			current_igi = min(dm_dig->rssi_val_min, dig_maxofmin);

			dm_dig->large_fa_hit = 0;
		} else {
+3 −12
Original line number Diff line number Diff line
@@ -1449,18 +1449,9 @@ _rtl8723e_read_txpower_info_from_hwpg(struct ieee80211_hw *hw,
				rtlefuse->eeprom_chnlarea_txpwr_ht40_1s
					[rf_path][index];

			if ((rtlefuse->eeprom_chnlarea_txpwr_ht40_1s
					[rf_path][index] -
			     rtlefuse->eprom_chnl_txpwr_ht40_2sdf
					[rf_path][index]) > 0) {
			rtlefuse->txpwrlevel_ht40_2s[rf_path][i] =
				  rtlefuse->eeprom_chnlarea_txpwr_ht40_1s
				  [rf_path][index] -
				  rtlefuse->eprom_chnl_txpwr_ht40_2sdf
				  [rf_path][index];
			} else {
				rtlefuse->txpwrlevel_ht40_2s[rf_path][i] = 0;
			}
				max(rtlefuse->eeprom_chnlarea_txpwr_ht40_1s[rf_path][index] -
				    rtlefuse->eprom_chnl_txpwr_ht40_2sdf[rf_path][index], 0);
		}

		for (i = 0; i < 14; i++) {
+1 −4
Original line number Diff line number Diff line
@@ -468,10 +468,7 @@ static void rtl8723be_dm_dig(struct ieee80211_hw *hw)

	if (mac->link_state >= MAC80211_LINKED) {
		if (bfirstconnect) {
			if (dm_digtable->rssi_val_min <= dig_maxofmin)
				current_igi = dm_digtable->rssi_val_min;
			else
				current_igi = dig_maxofmin;
			current_igi = min(dm_digtable->rssi_val_min, dig_maxofmin);

			dm_digtable->large_fa_hit = 0;
		} else {
Loading