Skip to contentSkip to conversation

rtlwifi: Simplify bool comparison

PATCH In review Jiapeng Zhong 2 participants 2 messages Jan 26, 2021 – Jan 27, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 rtlwifi: Simplify bool comparison

Fix the following coccicheck warning:
./drivers/net/wireless/realtek/rtlwifi/ps.c:798:7-21: WARNING:
Comparison to bool ./drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c:3848:7-17:
WARNING: Comparison of 0/1 to bool variable

---

Changes in v3:
-modify email address to a unique one
-modify subject prefix to "rtlwifi"
-merge this patch with another patch

 drivers/net/wireless/realtek/rtlwifi/ps.c            | 4 ++--
 drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/realtek/rtlwifi/ps.c +2 -2
index f9988225..629c032 100644
@@ -798,9 +798,9 @@ static void rtl_p2p_noa_ie(struct ieee80211_hw *hw, void *data,
 		ie += 3 + noa_len;
 	}
 
-	if (find_p2p_ie == true) {
+	if (find_p2p_ie) {
 		if ((p2pinfo->p2p_ps_mode > P2P_PS_NONE) &&
-		    (find_p2p_ps_ie == false))
+		    (!find_p2p_ps_ie))
 			rtl_p2p_ps_cmd(hw, P2P_PS_DISABLE);
 	}
 }
drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c +1 -1
index 372d6f8..1fb857c 100644
@@ -3848,7 +3848,7 @@ static void _rtl8821ae_iqk_tx(struct ieee80211_hw *hw, enum radio_path path)
 			else
 				rtl_write_dword(rtlpriv, 0xc8c, 0x00163e96);
 
-			if (vdf_enable == 1) {
+			if (vdf_enable) {
 				rtl_dbg(rtlpriv, COMP_IQK, DBG_LOUD, "VDF_enable\n");
 				for (k = 0; k <= 2; k++) {
 					switch (k) {
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 5 lines · Jiapeng Zhong

Fix the following coccicheck warning:
./drivers/net/wireless/realtek/rtlwifi/ps.c:798:7-21: WARNING:
Comparison to bool ./drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c:3848:7-17:
WARNING: Comparison of 0/1 to bool variable

[]

drivers/net/wireless/realtek/rtlwifi/ps.c

Quoted 1 line
drivers/net/wireless/realtek/rtlwifi/ps.c +0 -0

[]

Quoted 10 lines
drivers/net/wireless/realtek/rtlwifi/ps.c +0 -0
@@ -798,9 +798,9 @@ static void rtl_p2p_noa_ie(struct ieee80211_hw *hw, void *data,
  		ie += 3 + noa_len;
  	}

drivers/net/wireless/realtek/rtlwifi/ps.c +1 -1
-	if (find_p2p_ie == true) {
+	if (find_p2p_ie) {

  if ((p2pinfo->p2p_ps_mode > P2P_PS_NONE) &&

drivers/net/wireless/realtek/rtlwifi/ps.c +1 -1
-		    (find_p2p_ps_ie == false))
+		    (!find_p2p_ps_ie))
Quoted 2 lines

  rtl_p2p_ps_cmd(hw, P2P_PS_DISABLE); }

Always review suggested coccinelle patches before submission and see if there are ways to improve the code beyond what the spatch tool suggests.

Perhaps integrate these tests and removed an indent level too:

	if (find_p2p_ie && !find_p2p_ps_ie &&
	    p2pinfo->p2p_ps_mode > P2P_PS_NONE)
		rtl_p2p_ps_cmd(hw, P2P_PS_DISABLE);