Skip to contentSkip to conversation

staging: r8188eu: some refactoring and cleanup

PATCH Superseded Vihas Makwana 2 participants 6 messages Apr 5, 2022 Staging

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover staging: r8188eu: some refactoring and cleanup

Drop some redundant checks and cleanup the unused functions.

Vihas Makwana (3):
staging: r8188eu: drop redundant if check in IS_MCAST
staging: r8188eu: drop redundant if check in check_fwstate
staging: r8188eu: simplify rtw_inc_and_chk_continual_urb_error

 drivers/staging/r8188eu/include/rtw_mlme.h | 43 +---------------------
 drivers/staging/r8188eu/include/usb_ops.h  |  7 +---
 drivers/staging/r8188eu/include/wifi.h     |  5 +--
 3 files changed, 3 insertions(+), 52 deletions(-)
Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/3 staging: r8188eu: drop redundant if check in IS_MCAST

The if check is redundant. Drop it and simplify the funciton.

---
 drivers/staging/r8188eu/include/wifi.h | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/staging/r8188eu/include/wifi.h +1 -4
index e10cf17d6..88ed6b4a0 100644
@@ -244,10 +244,7 @@ enum WIFI_REG_DOMAIN {
 
 static inline bool IS_MCAST(unsigned char *da)
 {
-	if ((*da) & 0x01)
-		return true;
-	else
-		return false;
+	return (*da) & 0x01;
 }
 
 static inline unsigned char *get_da(unsigned char *pframe)
Signature · 1 line
2.30.2
#2 lore raw

PATCH 2/3 staging: r8188eu: drop redundant if check in check_fwstate

In reply to Vihas Makwana

The if check is redundant. Drop it and simplify the funciton.

Also, drop clr_fwstate(), clr_fwstate_ex(), up_scanned_network() and down_scanned_network() as they are not used anywhere.

---
 drivers/staging/r8188eu/include/rtw_mlme.h | 43 +---------------------
 1 file changed, 1 insertion(+), 42 deletions(-)
drivers/staging/r8188eu/include/rtw_mlme.h +1 -42
index 37d217aaf..3b6f70ad8 100644
@@ -453,15 +453,7 @@ static inline u8 *get_bssid(struct mlme_priv *pmlmepriv)
 
 static inline bool check_fwstate(struct mlme_priv *pmlmepriv, int state)
 {
-	if (pmlmepriv->fw_state & state)
-		return true;
-
-	return false;
-}
-
-static inline int get_fwstate(struct mlme_priv *pmlmepriv)
-{
-	return pmlmepriv->fw_state;
+	return pmlmepriv->fw_state & state;
 }
 
 /*
@@ -487,39 +479,6 @@ static inline void _clr_fwstate_(struct mlme_priv *pmlmepriv, int state)
 		pmlmepriv->bScanInProcess = false;
 }
 
-/*
- * No Limit on the calling context,
- * therefore set it to be the critical section...
- */
-static inline void clr_fwstate(struct mlme_priv *pmlmepriv, int state)
-{
-	spin_lock_bh(&pmlmepriv->lock);
-	if (check_fwstate(pmlmepriv, state))
-		pmlmepriv->fw_state ^= state;
-	spin_unlock_bh(&pmlmepriv->lock);
-}
-
-static inline void clr_fwstate_ex(struct mlme_priv *pmlmepriv, int state)
-{
-	spin_lock_bh(&pmlmepriv->lock);
-	_clr_fwstate_(pmlmepriv, state);
-	spin_unlock_bh(&pmlmepriv->lock);
-}
-
-static inline void up_scanned_network(struct mlme_priv *pmlmepriv)
-{
-	spin_lock_bh(&pmlmepriv->lock);
-	pmlmepriv->num_of_scanned++;
-	spin_unlock_bh(&pmlmepriv->lock);
-}
-
-static inline void down_scanned_network(struct mlme_priv *pmlmepriv)
-{
-	spin_lock_bh(&pmlmepriv->lock);
-	pmlmepriv->num_of_scanned--;
-	spin_unlock_bh(&pmlmepriv->lock);
-}
-
 static inline void set_scanned_network_val(struct mlme_priv *pmlmepriv, int val)
 {
 	spin_lock_bh(&pmlmepriv->lock);
Signature · 1 line
2.30.2
#3 lore raw

Re: [PATCH 2/3] staging: r8188eu: drop redundant if check in check_fwstate

Quoted 4 lines · Vihas Makwana

The if check is redundant. Drop it and simplify the funciton.

Also, drop clr_fwstate(), clr_fwstate_ex(), up_scanned_network() and down_scanned_network() as they are not used anywhere.

When you write "also" in a changelog text, that's a huge hint that you should break this up into multiple patches.

Remember, do only one logical thing per change. This should be split up into 2 patches.

thanks,

greg k-h

#4 lore raw

PATCH 3/3 staging: r8188eu: simplify rtw_inc_and_chk_continual_urb_error

In reply to Vihas Makwana

The if check and variable "value" is redundant. Drop it and simplify the funciton.

---
 drivers/staging/r8188eu/include/usb_ops.h | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/staging/r8188eu/include/usb_ops.h +1 -6
index ddc46cb44..c5982704c 100644
@@ -27,12 +27,7 @@
  */
 static inline bool rtw_inc_and_chk_continual_urb_error(struct dvobj_priv *dvobj)
 {
-	int value = atomic_inc_return(&dvobj->continual_urb_error);
-
-	if (value > MAX_CONTINUAL_URB_ERR)
-		return true;
-
-	return false;
+	return atomic_inc_return(&dvobj->continual_urb_error) > MAX_CONTINUAL_URB_ERR;
 }
 
 /*
Signature · 1 line
2.30.2
#5 lore raw

Re: [PATCH 3/3] staging: r8188eu: simplify rtw_inc_and_chk_continual_urb_error

Quoted 14 lines · Vihas Makwana

The if check and variable "value" is redundant. Drop it and simplify the funciton.

---
 drivers/staging/r8188eu/include/usb_ops.h | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/staging/r8188eu/include/usb_ops.h +0 -0
index ddc46cb44..c5982704c 100644
@@ -27,12 +27,7 @@
  */

drivers/staging/r8188eu/include/usb_ops.h line 31

Quoted 10 lines
drivers/staging/r8188eu/include/usb_ops.h +1 -6
 static inline bool rtw_inc_and_chk_continual_urb_error(struct dvobj_priv *dvobj)
 {
-	int value = atomic_inc_return(&dvobj->continual_urb_error);
-
-	if (value > MAX_CONTINUAL_URB_ERR)
-		return true;
-
-	return false;
+	return atomic_inc_return(&dvobj->continual_urb_error) > MAX_CONTINUAL_URB_ERR;
 }

Let's leave this as-is because it's a mess and should be fixed up anyway. No need to count urb errors as atomic values, this is crazy.

thanks,

greg k-h