2022-04-06 04:14:34

by Vihas Makwana

[permalink] [raw]
Subject: [PATCH 0/3] 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(-)

--
2.30.2


2022-04-06 07:26:10

by Vihas Makwana

[permalink] [raw]
Subject: [PATCH 3/3] staging: r8188eu: simplify rtw_inc_and_chk_continual_urb_error

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

Signed-off-by: Vihas Makwana <[email protected]>
---
drivers/staging/r8188eu/include/usb_ops.h | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/staging/r8188eu/include/usb_ops.h b/drivers/staging/r8188eu/include/usb_ops.h
index ddc46cb44..c5982704c 100644
--- a/drivers/staging/r8188eu/include/usb_ops.h
+++ b/drivers/staging/r8188eu/include/usb_ops.h
@@ -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;
}

/*
--
2.30.2

2022-04-06 12:06:04

by Vihas Makwana

[permalink] [raw]
Subject: [PATCH 2/3] staging: r8188eu: drop redundant if check in check_fwstate

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.

Signed-off-by: Vihas Makwana <[email protected]>
---
drivers/staging/r8188eu/include/rtw_mlme.h | 43 +---------------------
1 file changed, 1 insertion(+), 42 deletions(-)

diff --git a/drivers/staging/r8188eu/include/rtw_mlme.h b/drivers/staging/r8188eu/include/rtw_mlme.h
index 37d217aaf..3b6f70ad8 100644
--- a/drivers/staging/r8188eu/include/rtw_mlme.h
+++ b/drivers/staging/r8188eu/include/rtw_mlme.h
@@ -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);
--
2.30.2

2022-04-06 12:19:05

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH 3/3] staging: r8188eu: simplify rtw_inc_and_chk_continual_urb_error

On Tue, Apr 05, 2022 at 06:12:40PM +0530, Vihas Makwana wrote:
> The if check and variable "value" is redundant. Drop it and simplify
> the funciton.
>
> Signed-off-by: Vihas Makwana <[email protected]>
> ---
> drivers/staging/r8188eu/include/usb_ops.h | 7 +------
> 1 file changed, 1 insertion(+), 6 deletions(-)
>
> diff --git a/drivers/staging/r8188eu/include/usb_ops.h b/drivers/staging/r8188eu/include/usb_ops.h
> index ddc46cb44..c5982704c 100644
> --- a/drivers/staging/r8188eu/include/usb_ops.h
> +++ b/drivers/staging/r8188eu/include/usb_ops.h
> @@ -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;
> }

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

2022-04-06 12:29:36

by Vihas Makwana

[permalink] [raw]
Subject: [PATCH 1/3] staging: r8188eu: drop redundant if check in IS_MCAST

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

Signed-off-by: Vihas Makwana <[email protected]>
---
drivers/staging/r8188eu/include/wifi.h | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/staging/r8188eu/include/wifi.h b/drivers/staging/r8188eu/include/wifi.h
index e10cf17d6..88ed6b4a0 100644
--- a/drivers/staging/r8188eu/include/wifi.h
+++ b/drivers/staging/r8188eu/include/wifi.h
@@ -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)
--
2.30.2