* [PATCH 00/12] net: Use min()/max() to improve code
@ 2025-07-09 2:21 Qianfeng Rong
2025-07-09 2:21 ` [PATCH 07/12] wifi: ath5k: Use max() " Qianfeng Rong
` (6 more replies)
0 siblings, 7 replies; 14+ messages in thread
From: Qianfeng Rong @ 2025-07-09 2:21 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Potnuri Bharat Teja, Veerasenareddy Burru,
Sathesh Edara, Louis Peens, Shahed Shaikh, Manish Chopra,
maintainer:QLOGIC QLCNIC (1/10)Gb ETHERNET DRIVER, Jiri Slaby,
Nick Kossifidis, Luis Chamberlain,
Toke Høiland-Jørgensen, Arend van Spriel, Brian Norris,
Francesco Dolcini, Ajay Singh, Claudiu Beznea, Ping-Ke Shih,
Qianfeng Rong, Kees Cook, Gustavo A. R. Silva, Kory Maincent,
Aleksander Jan Bajkowski, Lucas Sanchez Sagrado, Philipp Hahn,
Eric Biggers, Hayes Wang, Wentao Liang, Johannes Berg,
Sai Krishna, Jacobe Zang, Dmitry Antipov, Kalle Valo,
Sascha Hauer, David Lin, Aditya Kumar Singh, Roopni Devanathan,
Dan Carpenter, Marek Vasut, Alexis Lothoré, Arnd Bergmann,
open list:CAVIUM LIQUIDIO NETWORK DRIVER, open list,
open list:NETRONOME ETHERNET DRIVERS,
open list:USB NETWORKING DRIVERS,
open list:ATHEROS ATH5K WIRELESS DRIVER,
open list:BROADCOM BRCM80211 IEEE802.11 WIRELESS DRIVERS,
open list:BROADCOM BRCM80211 IEEE802.11 WIRELESS DRIVERS
Use min() to reduce the code and improve its readability.
No functional changes.
Qianfeng Rong (12):
ethernet: liquidio: Use min() to improve code
ethernet: cxgb4: Use min() to improve code
ethernet: octeon_ep: Use min() to improve code
ethernet: nfp: Use min()/max() to improve code
ethernet: qlcnic: Use min() to improve code
net: usb: Use min() to improve code
wifi: ath5k: Use max() to improve code
wifi: ath9k: Use max() to improve code
wifi: brcm80211: Use min() to improve code
wifi: mwifiex: Use max() to improve code
wifi: wilc1000: Use min() to improve code
wifi: rtlwifi: Use min()/max() to improve code
.../ethernet/cavium/liquidio/octeon_console.c | 5 +----
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 5 +----
.../marvell/octeon_ep/octep_pfvf_mbox.c | 5 +----
.../ethernet/netronome/nfp/nfp_netvf_main.c | 13 ++++---------
.../ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c | 5 +----
drivers/net/usb/r8152.c | 5 +----
drivers/net/wireless/ath/ath5k/phy.c | 12 +++---------
drivers/net/wireless/ath/ath9k/dfs.c | 5 +----
.../broadcom/brcm80211/brcmfmac/usb.c | 5 +----
.../broadcom/brcm80211/brcmsmac/phy/phy_n.c | 6 ++----
.../net/wireless/marvell/mwifiex/cfg80211.c | 6 ++----
.../net/wireless/microchip/wilc1000/wlan.c | 5 +----
.../wireless/realtek/rtlwifi/rtl8192ce/hw.c | 19 +++----------------
.../wireless/realtek/rtlwifi/rtl8192cu/hw.c | 17 +++--------------
.../wireless/realtek/rtlwifi/rtl8192ee/dm.c | 5 +----
.../wireless/realtek/rtlwifi/rtl8723ae/hw.c | 15 +++------------
.../wireless/realtek/rtlwifi/rtl8723be/dm.c | 5 +----
.../wireless/realtek/rtlwifi/rtl8821ae/dm.c | 5 +----
18 files changed, 31 insertions(+), 112 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 07/12] wifi: ath5k: Use max() to improve code
2025-07-09 2:21 [PATCH 00/12] net: Use min()/max() to improve code Qianfeng Rong
@ 2025-07-09 2:21 ` Qianfeng Rong
2025-07-09 4:55 ` Jiri Slaby
2025-07-09 2:21 ` [PATCH 08/12] wifi: ath9k: " Qianfeng Rong
` (5 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Qianfeng Rong @ 2025-07-09 2:21 UTC (permalink / raw)
To: Jiri Slaby, Nick Kossifidis, Luis Chamberlain,
open list:ATHEROS ATH5K WIRELESS DRIVER, open list
Cc: Qianfeng Rong
Use max() to reduce the code and improve its readability.
Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
---
drivers/net/wireless/ath/ath5k/phy.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/drivers/net/wireless/ath/ath5k/phy.c b/drivers/net/wireless/ath/ath5k/phy.c
index 4825f9cb9cb8..b76772396590 100644
--- a/drivers/net/wireless/ath/ath5k/phy.c
+++ b/drivers/net/wireless/ath/ath5k/phy.c
@@ -3116,10 +3116,7 @@ ath5k_combine_pwr_to_pdadc_curves(struct ath5k_hw *ah,
pd_gain_overlap;
/* Force each power step to be at least 0.5 dB */
- if ((pdadc_tmp[1] - pdadc_tmp[0]) > 1)
- pwr_step = pdadc_tmp[1] - pdadc_tmp[0];
- else
- pwr_step = 1;
+ pwr_step = max(pdadc_tmp[1] - pdadc_tmp[0], 1);
/* If pdadc_0 is negative, we need to extrapolate
* below this pdgain by a number of pwr_steps */
@@ -3144,11 +3141,8 @@ ath5k_combine_pwr_to_pdadc_curves(struct ath5k_hw *ah,
continue;
/* Force each power step to be at least 0.5 dB */
- if ((pdadc_tmp[table_size - 1] - pdadc_tmp[table_size - 2]) > 1)
- pwr_step = pdadc_tmp[table_size - 1] -
- pdadc_tmp[table_size - 2];
- else
- pwr_step = 1;
+ pwr_step = max(pdadc_tmp[table_size - 1] -
+ pdadc_tmp[table_size - 2], 1);
/* Extrapolate above */
while ((pdadc_0 < (s16) pdadc_n) &&
--
2.34.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 08/12] wifi: ath9k: Use max() to improve code
2025-07-09 2:21 [PATCH 00/12] net: Use min()/max() to improve code Qianfeng Rong
2025-07-09 2:21 ` [PATCH 07/12] wifi: ath5k: Use max() " Qianfeng Rong
@ 2025-07-09 2:21 ` Qianfeng Rong
2025-07-09 2:21 ` [PATCH 09/12] wifi: brcm80211: Use min() " Qianfeng Rong
` (4 subsequent siblings)
6 siblings, 0 replies; 14+ messages in thread
From: Qianfeng Rong @ 2025-07-09 2:21 UTC (permalink / raw)
To: Toke Høiland-Jørgensen,
open list:QUALCOMM ATHEROS ATH9K WIRELESS DRIVER, open list
Cc: Qianfeng Rong
Use max() to reduce the code and improve its readability.
Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
---
drivers/net/wireless/ath/ath9k/dfs.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/net/wireless/ath/ath9k/dfs.c b/drivers/net/wireless/ath/ath9k/dfs.c
index 2fb73a5e1d51..370346450675 100644
--- a/drivers/net/wireless/ath/ath9k/dfs.c
+++ b/drivers/net/wireless/ath/ath9k/dfs.c
@@ -239,10 +239,7 @@ ath9k_postprocess_radar_event(struct ath_softc *sc,
* Radiated testing, when pulse is on DC, different pri and
* ext durations are reported, so take the larger of the two
*/
- if (ard->pulse_length_ext >= ard->pulse_length_pri)
- dur = ard->pulse_length_ext;
- else
- dur = ard->pulse_length_pri;
+ dur = max(ard->pulse_length_ext, ard->pulse_length_pri);
DFS_STAT_INC(sc, dc_phy_errors);
/* when both are present use stronger one */
--
2.34.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 09/12] wifi: brcm80211: Use min() to improve code
2025-07-09 2:21 [PATCH 00/12] net: Use min()/max() to improve code Qianfeng Rong
2025-07-09 2:21 ` [PATCH 07/12] wifi: ath5k: Use max() " Qianfeng Rong
2025-07-09 2:21 ` [PATCH 08/12] wifi: ath9k: " Qianfeng Rong
@ 2025-07-09 2:21 ` Qianfeng Rong
2025-07-09 2:21 ` [PATCH 10/12] wifi: mwifiex: Use max() " Qianfeng Rong
` (3 subsequent siblings)
6 siblings, 0 replies; 14+ messages in thread
From: Qianfeng Rong @ 2025-07-09 2:21 UTC (permalink / raw)
To: Arend van Spriel, Wentao Liang, Johannes Berg, Kalle Valo,
Sai Krishna, Qianfeng Rong, Jacobe Zang, Dmitry Antipov,
open list:BROADCOM BRCM80211 IEEE802.11 WIRELESS DRIVERS,
open list:BROADCOM BRCM80211 IEEE802.11 WIRELESS DRIVERS,
open list:BROADCOM BRCM80211 IEEE802.11 WIRELESS DRIVERS,
open list
Use min() to reduce the code and improve its readability.
Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
---
drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 5 +----
.../net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c | 6 ++----
2 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
index b056336d5da6..f0129d10d2b9 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
@@ -927,10 +927,7 @@ brcmf_usb_dl_writeimage(struct brcmf_usbdev_info *devinfo, u8 *fw, int fwlen)
/* Wait until the usb device reports it received all
* the bytes we sent */
if ((rdlbytes == sent) && (rdlbytes != dllen)) {
- if ((dllen-sent) < TRX_RDL_CHUNK)
- sendlen = dllen-sent;
- else
- sendlen = TRX_RDL_CHUNK;
+ sendlen = min(dllen - sent, TRX_RDL_CHUNK);
/* simply avoid having to send a ZLP by ensuring we
* never have an even
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c
index d362c4337616..cc406699e389 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c
@@ -25825,10 +25825,8 @@ wlc_phy_cal_txiqlo_nphy(struct brcms_phy *pi, struct nphy_txgains target_gain,
if (mphase) {
cal_cnt = pi->mphase_txcal_cmdidx;
- if ((cal_cnt + pi->mphase_txcal_numcmds) < max_cal_cmds)
- num_cals = cal_cnt + pi->mphase_txcal_numcmds;
- else
- num_cals = max_cal_cmds;
+ num_cals = min(cal_cnt + pi->mphase_txcal_numcmds,
+ max_cal_cmds);
} else {
cal_cnt = 0;
num_cals = max_cal_cmds;
--
2.34.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 10/12] wifi: mwifiex: Use max() to improve code
2025-07-09 2:21 [PATCH 00/12] net: Use min()/max() to improve code Qianfeng Rong
` (2 preceding siblings ...)
2025-07-09 2:21 ` [PATCH 09/12] wifi: brcm80211: Use min() " Qianfeng Rong
@ 2025-07-09 2:21 ` Qianfeng Rong
2025-07-09 5:42 ` Jeff Chen
2025-07-09 2:21 ` [PATCH 11/12] wifi: wilc1000: Use min() " Qianfeng Rong
` (2 subsequent siblings)
6 siblings, 1 reply; 14+ messages in thread
From: Qianfeng Rong @ 2025-07-09 2:21 UTC (permalink / raw)
To: Brian Norris, Francesco Dolcini, Johannes Berg, Sascha Hauer,
Kalle Valo, David Lin, Aditya Kumar Singh, Dan Carpenter,
Qianfeng Rong, open list:MARVELL MWIFIEX WIRELESS DRIVER,
open list
Use max() to reduce the code and improve its readability.
Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
---
drivers/net/wireless/marvell/mwifiex/cfg80211.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
index 286378770e9e..d81db73ac77f 100644
--- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
@@ -4783,10 +4783,8 @@ int mwifiex_register_cfg80211(struct mwifiex_adapter *adapter)
wiphy->iface_combinations = &mwifiex_iface_comb_ap_sta;
wiphy->n_iface_combinations = 1;
- if (adapter->max_sta_conn > adapter->max_p2p_conn)
- wiphy->max_ap_assoc_sta = adapter->max_sta_conn;
- else
- wiphy->max_ap_assoc_sta = adapter->max_p2p_conn;
+ wiphy->max_ap_assoc_sta = max(adapter->max_sta_conn,
+ adapter->max_p2p_conn);
/* Initialize cipher suits */
wiphy->cipher_suites = mwifiex_cipher_suites;
--
2.34.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 11/12] wifi: wilc1000: Use min() to improve code
2025-07-09 2:21 [PATCH 00/12] net: Use min()/max() to improve code Qianfeng Rong
` (3 preceding siblings ...)
2025-07-09 2:21 ` [PATCH 10/12] wifi: mwifiex: Use max() " Qianfeng Rong
@ 2025-07-09 2:21 ` Qianfeng Rong
2025-07-09 13:58 ` Alexis Lothoré
2025-07-09 2:21 ` [PATCH 12/12] wifi: rtlwifi: Use min()/max() " Qianfeng Rong
2025-07-11 0:59 ` [PATCH 00/12] net: " Jakub Kicinski
6 siblings, 1 reply; 14+ messages in thread
From: Qianfeng Rong @ 2025-07-09 2:21 UTC (permalink / raw)
To: Ajay Singh, Claudiu Beznea, Kalle Valo, Alexis Lothoré,
Marek Vasut, Qianfeng Rong,
open list:MICROCHIP WILC1000 WIFI DRIVER, open list
Use min() to reduce the code and improve its readability.
Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
---
drivers/net/wireless/microchip/wilc1000/wlan.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c
index 9d80adc45d6b..fedc7d59216a 100644
--- a/drivers/net/wireless/microchip/wilc1000/wlan.c
+++ b/drivers/net/wireless/microchip/wilc1000/wlan.c
@@ -1287,10 +1287,7 @@ int wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer,
offset += 8;
while (((int)size) && (offset < buffer_size)) {
- if (size <= blksz)
- size2 = size;
- else
- size2 = blksz;
+ size2 = min(size, blksz);
memcpy(dma_buffer, &buffer[offset], size2);
ret = wilc->hif_func->hif_block_tx(wilc, addr,
--
2.34.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 12/12] wifi: rtlwifi: Use min()/max() to improve code
2025-07-09 2:21 [PATCH 00/12] net: Use min()/max() to improve code Qianfeng Rong
` (4 preceding siblings ...)
2025-07-09 2:21 ` [PATCH 11/12] wifi: wilc1000: Use min() " Qianfeng Rong
@ 2025-07-09 2:21 ` Qianfeng Rong
2025-07-09 6:57 ` Ping-Ke Shih
2025-07-11 0:59 ` [PATCH 00/12] net: " Jakub Kicinski
6 siblings, 1 reply; 14+ messages in thread
From: Qianfeng Rong @ 2025-07-09 2:21 UTC (permalink / raw)
To: Ping-Ke Shih, Qianfeng Rong, Arnd Bergmann,
open list:REALTEK WIRELESS DRIVER (rtlwifi family), open list
Use min()/max() to reduce the code and improve its readability.
Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
---
.../wireless/realtek/rtlwifi/rtl8192ce/hw.c | 19 +++----------------
.../wireless/realtek/rtlwifi/rtl8192cu/hw.c | 17 +++--------------
.../wireless/realtek/rtlwifi/rtl8192ee/dm.c | 5 +----
.../wireless/realtek/rtlwifi/rtl8723ae/hw.c | 15 +++------------
.../wireless/realtek/rtlwifi/rtl8723be/dm.c | 5 +----
.../wireless/realtek/rtlwifi/rtl8821ae/dm.c | 5 +----
6 files changed, 12 insertions(+), 54 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.c
index 5ca6b49e73c7..dac6e271410d 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/hw.c
@@ -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;
- }
+ rtlefuse->txpwrlevel_ht40_2s[rf_path][i] =
+ 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++) {
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c
index ec5d558609fe..95b1098426d5 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192cu/hw.c
@@ -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;
- }
+ rtlefuse->txpwrlevel_ht40_2s[rf_path][i] =
+ 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,
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/dm.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/dm.c
index 17486e3f322c..0108850bb9e5 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/dm.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/dm.c
@@ -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 {
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c
index 21b827f519b6..26ff551f054d 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/hw.c
@@ -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;
- }
+ rtlefuse->txpwrlevel_ht40_2s[rf_path][i] =
+ 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++) {
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/dm.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/dm.c
index c53f95144812..c65d14fb914f 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/dm.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/dm.c
@@ -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 {
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/dm.c b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/dm.c
index 76b5395539d0..f8b159c74658 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/dm.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/dm.c
@@ -756,10 +756,7 @@ static void rtl8821ae_dm_dig(struct ieee80211_hw *hw)
rtl_dbg(rtlpriv, COMP_DIG, DBG_LOUD,
"DIG AfterLink\n");
if (first_connect) {
- if (dm_digtable->rssi_val_min <= dig_max_of_min)
- current_igi = dm_digtable->rssi_val_min;
- else
- current_igi = dig_max_of_min;
+ current_igi = min(dm_digtable->rssi_val_min, dig_max_of_min);
rtl_dbg(rtlpriv, COMP_DIG, DBG_LOUD,
"First Connect\n");
} else {
--
2.34.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 07/12] wifi: ath5k: Use max() to improve code
2025-07-09 2:21 ` [PATCH 07/12] wifi: ath5k: Use max() " Qianfeng Rong
@ 2025-07-09 4:55 ` Jiri Slaby
0 siblings, 0 replies; 14+ messages in thread
From: Jiri Slaby @ 2025-07-09 4:55 UTC (permalink / raw)
To: Qianfeng Rong, Nick Kossifidis, Luis Chamberlain,
open list:ATHEROS ATH5K WIRELESS DRIVER, open list
On 09. 07. 25, 4:21, Qianfeng Rong wrote:
> Use max() to reduce the code and improve its readability.
>
> Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
--
js
suse labs
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 10/12] wifi: mwifiex: Use max() to improve code
2025-07-09 2:21 ` [PATCH 10/12] wifi: mwifiex: Use max() " Qianfeng Rong
@ 2025-07-09 5:42 ` Jeff Chen
2025-07-09 6:42 ` Qianfeng Rong
0 siblings, 1 reply; 14+ messages in thread
From: Jeff Chen @ 2025-07-09 5:42 UTC (permalink / raw)
To: Qianfeng Rong
Cc: Brian Norris, Francesco Dolcini, Johannes Berg, Sascha Hauer,
Kalle Valo, David Lin, Aditya Kumar Singh, Dan Carpenter,
open list:MARVELL MWIFIEX WIRELESS DRIVER, open list
Hi Qianfeng,
Thanks for the cleanup.
On Wed, Jul 09, 2025 at 10:21:38 AM +0800, Qianfeng Rong wrote:
> Use max() to reduce the code and improve its readability.
>
> Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
> ---
> drivers/net/wireless/marvell/mwifiex/cfg80211.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
> index 286378770e9e..d81db73ac77f 100644
> --- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c
> +++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
> @@ -4783,10 +4783,8 @@ int mwifiex_register_cfg80211(struct mwifiex_adapter *adapter)
> wiphy->iface_combinations = &mwifiex_iface_comb_ap_sta;
> wiphy->n_iface_combinations = 1;
>
> - if (adapter->max_sta_conn > adapter->max_p2p_conn)
> - wiphy->max_ap_assoc_sta = adapter->max_sta_conn;
> - else
> - wiphy->max_ap_assoc_sta = adapter->max_p2p_conn;
> + wiphy->max_ap_assoc_sta = max(adapter->max_sta_conn,
> + adapter->max_p2p_conn);
adapter->max_sta_conn and adapter->max_p2p_conn are u8, and wiphy->max_ap_assoc_sta is u16.
To ensure type safety and maintainability, I recommend using max_t() with typeof():
wiphy->max_ap_assoc_sta = max_t(typeof(wiphy->max_ap_assoc_sta),
adapter->max_sta_conn,
adapter->max_p2p_conn);
>
> /* Initialize cipher suits */
> wiphy->cipher_suites = mwifiex_cipher_suites;
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 10/12] wifi: mwifiex: Use max() to improve code
2025-07-09 5:42 ` Jeff Chen
@ 2025-07-09 6:42 ` Qianfeng Rong
0 siblings, 0 replies; 14+ messages in thread
From: Qianfeng Rong @ 2025-07-09 6:42 UTC (permalink / raw)
To: Jeff Chen
Cc: Brian Norris, Francesco Dolcini, Johannes Berg, Sascha Hauer,
Kalle Valo, David Lin, Aditya Kumar Singh, Dan Carpenter,
open list:MARVELL MWIFIEX WIRELESS DRIVER, open list
在 2025/7/9 13:42, Jeff Chen 写道:
> - if (adapter->max_sta_conn > adapter->max_p2p_conn)
> - wiphy->max_ap_assoc_sta = adapter->max_sta_conn;
> - else
> - wiphy->max_ap_assoc_sta = adapter->max_p2p_conn;
> + wiphy->max_ap_assoc_sta = max(adapter->max_sta_conn,
> + adapter->max_p2p_conn);
> adapter->max_sta_conn and adapter->max_p2p_conn are u8, and wiphy->max_ap_assoc_sta is u16.
> To ensure type safety and maintainability, I recommend using max_t() with typeof():
> wiphy->max_ap_assoc_sta = max_t(typeof(wiphy->max_ap_assoc_sta),
> adapter->max_sta_conn,
> adapter->max_p2p_conn);
>
Thanks for taking the time to reply.
I will try to do this in the next version.
Best regards,
Qianfeng
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* RE: [PATCH 12/12] wifi: rtlwifi: Use min()/max() to improve code
2025-07-09 2:21 ` [PATCH 12/12] wifi: rtlwifi: Use min()/max() " Qianfeng Rong
@ 2025-07-09 6:57 ` Ping-Ke Shih
0 siblings, 0 replies; 14+ messages in thread
From: Ping-Ke Shih @ 2025-07-09 6:57 UTC (permalink / raw)
To: Qianfeng Rong, Arnd Bergmann,
open list:REALTEK WIRELESS DRIVER (rtlwifi family), open list
Qianfeng Rong <rongqianfeng@vivo.com> wrote:
> Use min()/max() to reduce the code and improve its readability.
>
> Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 11/12] wifi: wilc1000: Use min() to improve code
2025-07-09 2:21 ` [PATCH 11/12] wifi: wilc1000: Use min() " Qianfeng Rong
@ 2025-07-09 13:58 ` Alexis Lothoré
0 siblings, 0 replies; 14+ messages in thread
From: Alexis Lothoré @ 2025-07-09 13:58 UTC (permalink / raw)
To: Qianfeng Rong, Ajay Singh, Claudiu Beznea, Kalle Valo,
Marek Vasut, open list:MICROCHIP WILC1000 WIFI DRIVER, open list
On Wed Jul 9, 2025 at 4:21 AM CEST, Qianfeng Rong wrote:
> Use min() to reduce the code and improve its readability.
>
> Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
Reviewed-by: Alexis Lothoré <alexis.lothore@bootlin.com>
Thanks,
Alexis
--
Alexis Lothoré, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 00/12] net: Use min()/max() to improve code
2025-07-09 2:21 [PATCH 00/12] net: Use min()/max() to improve code Qianfeng Rong
` (5 preceding siblings ...)
2025-07-09 2:21 ` [PATCH 12/12] wifi: rtlwifi: Use min()/max() " Qianfeng Rong
@ 2025-07-11 0:59 ` Jakub Kicinski
2025-07-14 2:08 ` Qianfeng Rong
6 siblings, 1 reply; 14+ messages in thread
From: Jakub Kicinski @ 2025-07-11 0:59 UTC (permalink / raw)
To: Qianfeng Rong
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni,
Potnuri Bharat Teja, Veerasenareddy Burru, Sathesh Edara,
Louis Peens, Shahed Shaikh, Manish Chopra,
maintainer:QLOGIC QLCNIC (1/10)Gb ETHERNET DRIVER, Jiri Slaby,
Nick Kossifidis, Luis Chamberlain,
Toke Høiland-Jørgensen, Arend van Spriel, Brian Norris,
Francesco Dolcini, Ajay Singh, Claudiu Beznea, Ping-Ke Shih,
Kees Cook, Gustavo A. R. Silva, Kory Maincent,
Aleksander Jan Bajkowski, Lucas Sanchez Sagrado, Philipp Hahn,
Eric Biggers, Hayes Wang, Wentao Liang, Johannes Berg,
Sai Krishna, Jacobe Zang, Dmitry Antipov, Kalle Valo,
Sascha Hauer, David Lin, Aditya Kumar Singh, Roopni Devanathan,
Dan Carpenter, Marek Vasut, Alexis Lothoré, Arnd Bergmann,
open list:CAVIUM LIQUIDIO NETWORK DRIVER, open list,
open list:NETRONOME ETHERNET DRIVERS,
open list:USB NETWORKING DRIVERS,
open list:ATHEROS ATH5K WIRELESS DRIVER,
open list:BROADCOM BRCM80211 IEEE802.11 WIRELESS DRIVERS,
open list:BROADCOM BRCM80211 IEEE802.11 WIRELESS DRIVERS
On Wed, 9 Jul 2025 10:21:28 +0800 Qianfeng Rong wrote:
> Use min() to reduce the code and improve its readability.
>
> No functional changes.
For net/ethernet/ this is not worth the churn, sorry.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 00/12] net: Use min()/max() to improve code
2025-07-11 0:59 ` [PATCH 00/12] net: " Jakub Kicinski
@ 2025-07-14 2:08 ` Qianfeng Rong
0 siblings, 0 replies; 14+ messages in thread
From: Qianfeng Rong @ 2025-07-14 2:08 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni,
Potnuri Bharat Teja, Veerasenareddy Burru, Sathesh Edara,
Louis Peens, Shahed Shaikh, Manish Chopra,
maintainer:QLOGIC QLCNIC (1/10)Gb ETHERNET DRIVER, Jiri Slaby,
Nick Kossifidis, Luis Chamberlain,
Toke Høiland-Jørgensen, Arend van Spriel, Brian Norris,
Francesco Dolcini, Ajay Singh, Claudiu Beznea, Ping-Ke Shih,
Kees Cook, Gustavo A. R. Silva, Kory Maincent,
Aleksander Jan Bajkowski, Lucas Sanchez Sagrado, Philipp Hahn,
Eric Biggers, Hayes Wang, Wentao Liang, Johannes Berg,
Sai Krishna, Jacobe Zang, Dmitry Antipov, Kalle Valo,
Sascha Hauer, David Lin, Aditya Kumar Singh, Roopni Devanathan,
Dan Carpenter, Marek Vasut, Alexis Lothoré, Arnd Bergmann,
open list:CAVIUM LIQUIDIO NETWORK DRIVER, open list,
open list:NETRONOME ETHERNET DRIVERS,
open list:USB NETWORKING DRIVERS,
open list:ATHEROS ATH5K WIRELESS DRIVER,
open list:BROADCOM BRCM80211 IEEE802.11 WIRELESS DRIVERS,
open list:BROADCOM BRCM80211 IEEE802.11 WIRELESS DRIVERS
在 2025/7/11 8:59, Jakub Kicinski 写道:
> On Wed, 9 Jul 2025 10:21:28 +0800 Qianfeng Rong wrote:
>> Use min() to reduce the code and improve its readability.
>>
>> No functional changes.
> For net/ethernet/ this is not worth the churn, sorry.
Never mind, thanks for your reply.
Best regards,
Qianfeng
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2025-07-14 2:08 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-09 2:21 [PATCH 00/12] net: Use min()/max() to improve code Qianfeng Rong
2025-07-09 2:21 ` [PATCH 07/12] wifi: ath5k: Use max() " Qianfeng Rong
2025-07-09 4:55 ` Jiri Slaby
2025-07-09 2:21 ` [PATCH 08/12] wifi: ath9k: " Qianfeng Rong
2025-07-09 2:21 ` [PATCH 09/12] wifi: brcm80211: Use min() " Qianfeng Rong
2025-07-09 2:21 ` [PATCH 10/12] wifi: mwifiex: Use max() " Qianfeng Rong
2025-07-09 5:42 ` Jeff Chen
2025-07-09 6:42 ` Qianfeng Rong
2025-07-09 2:21 ` [PATCH 11/12] wifi: wilc1000: Use min() " Qianfeng Rong
2025-07-09 13:58 ` Alexis Lothoré
2025-07-09 2:21 ` [PATCH 12/12] wifi: rtlwifi: Use min()/max() " Qianfeng Rong
2025-07-09 6:57 ` Ping-Ke Shih
2025-07-11 0:59 ` [PATCH 00/12] net: " Jakub Kicinski
2025-07-14 2:08 ` Qianfeng Rong
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).