All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] [RFC] staging: rtl8723bs: refactor to reduce indents
@ 2021-05-22  9:17 Shreyansh Chouhan
  2021-05-22  9:17 ` [PATCH 1/2] " Shreyansh Chouhan
  2021-05-22  9:17 ` [PATCH 2/2] [RFC] staging: rtl8723bs: remove unnecessary braces from conditionals Shreyansh Chouhan
  0 siblings, 2 replies; 5+ messages in thread
From: Shreyansh Chouhan @ 2021-05-22  9:17 UTC (permalink / raw)
  To: gregkh, fabioaiuto83, ross.schm.dev, straube.linux
  Cc: Shreyansh Chouhan, linux-staging, linux-kernel

This patch series tries to fix the following warnings by checkpatch.pl
in core/rtw_wlan_util.c:

WARNING: Too many leading tabs - consider code refactoring
#887: FILE: rtw_wlan_util.c:887:
+                                               if ((edca[j] >> 16) > (edca[i] >> 16))

WARNING: Too many leading tabs - consider code refactoring
#1529: FILE: rtw_wlan_util.c:1529:
+                                               if (pIE->data[5] & RT_HT_CAP_USE_92SE)

WARNING: Too many leading tabs - consider code refactoring
#1537: FILE: rtw_wlan_util.c:1537:
+                                               if (pIE->data[6] & RT_HT_CAP_USE_JAGUAR_BCUT)

WARNING: Too many leading tabs - consider code refactoring
#1540: FILE: rtw_wlan_util.c:1540:
+                                               if (pIE->data[6] & RT_HT_CAP_USE_JAGUAR_CCUT)

I wanted to ask for comments on the names of these functions and if such
a patch series would be acceptable.

The first patch refactors the code by introducing two new functions
sort_wmm_ac_params and get_realtek_assoc_AP_vender.

The second patch removes unnecessary braces from the conditional
statements in check_assoc_AP function.

Shreyansh Chouhan (2):
  staging: rtl8723bs: refactor to reduce indents
  staging: rtl8723bs: remove unnecessary braces from conditionals

 .../staging/rtl8723bs/core/rtw_wlan_util.c    | 141 +++++++++---------
 1 file changed, 72 insertions(+), 69 deletions(-)

-- 
2.31.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] [RFC] staging: rtl8723bs: refactor to reduce indents
  2021-05-22  9:17 [PATCH 0/2] [RFC] staging: rtl8723bs: refactor to reduce indents Shreyansh Chouhan
@ 2021-05-22  9:17 ` Shreyansh Chouhan
  2021-05-24  9:05   ` Dan Carpenter
  2021-05-22  9:17 ` [PATCH 2/2] [RFC] staging: rtl8723bs: remove unnecessary braces from conditionals Shreyansh Chouhan
  1 sibling, 1 reply; 5+ messages in thread
From: Shreyansh Chouhan @ 2021-05-22  9:17 UTC (permalink / raw)
  To: gregkh, fabioaiuto83, ross.schm.dev, straube.linux
  Cc: Shreyansh Chouhan, linux-staging, linux-kernel

Reduce the number of indents in rtw_wlan_util.c file by refactoring the
code.

Moved the part of code that rearranged ac paramaters in the function
WMMOnAssocResp to a separate function named sort_wmm_ac_params. It takes
both the array of ac params and their indexes as arguments and sorts them.
Has return type void.

Moved the part of code that checked for the realtek vendor in the
function check_assoc_AP to a separate function named
get_realtek_assoc_AP_vender. It takes a pointer to struct
ndis_80211_var_ie as an argument and returns a u32 realtek vendor.

Signed-off-by: Shreyansh Chouhan <chouhan.shreyansh630@gmail.com>
---
 .../staging/rtl8723bs/core/rtw_wlan_util.c    | 108 +++++++++---------
 1 file changed, 56 insertions(+), 52 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
index ce47ef4edea0..36e515a7ab5c 100644
--- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
+++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
@@ -777,6 +777,32 @@ int WMM_param_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE)
 	return true;
 }
 
+static void sort_wmm_ac_params(u32 *inx, u32 *edca)
+{
+	u32 i, j, change_inx = false;
+
+	/* entry indx: 0->vo, 1->vi, 2->be, 3->bk. */
+	for (i = 0; i < 4; i++) {
+		for (j = i + 1; j < 4; j++) {
+			/* compare CW and AIFS */
+			if ((edca[j] & 0xFFFF) < (edca[i] & 0xFFFF)) {
+				change_inx = true;
+			} else if ((edca[j] & 0xFFFF) == (edca[i] & 0xFFFF)) {
+				/* compare TXOP */
+				if ((edca[j] >> 16) > (edca[i] >> 16))
+					change_inx = true;
+			}
+
+			if (change_inx) {
+				swap(edca[i], edca[j]);
+				swap(inx[i], inx[j]);
+
+				change_inx = false;
+			}
+		}
+	}
+}
+
 void WMMOnAssocRsp(struct adapter *padapter)
 {
 	u8 ACI, ACM, AIFS, ECWMin, ECWMax, aSifsTime;
@@ -873,35 +899,8 @@ void WMMOnAssocRsp(struct adapter *padapter)
 
 		inx[0] = 0; inx[1] = 1; inx[2] = 2; inx[3] = 3;
 
-		if (pregpriv->wifi_spec == 1) {
-			u32 j, tmp, change_inx = false;
-
-			/* entry indx: 0->vo, 1->vi, 2->be, 3->bk. */
-			for (i = 0; i < 4; i++) {
-				for (j = i+1; j < 4; j++) {
-					/* compare CW and AIFS */
-					if ((edca[j] & 0xFFFF) < (edca[i] & 0xFFFF)) {
-						change_inx = true;
-					} else if ((edca[j] & 0xFFFF) == (edca[i] & 0xFFFF)) {
-						/* compare TXOP */
-						if ((edca[j] >> 16) > (edca[i] >> 16))
-							change_inx = true;
-					}
-
-					if (change_inx) {
-						tmp = edca[i];
-						edca[i] = edca[j];
-						edca[j] = tmp;
-
-						tmp = inx[i];
-						inx[i] = inx[j];
-						inx[j] = tmp;
-
-						change_inx = false;
-					}
-				}
-			}
-		}
+		if (pregpriv->wifi_spec == 1)
+			sort_wmm_ac_params(inx, edca);
 
 		for (i = 0; i < 4; i++)
 			pxmitpriv->wmm_para_seq[i] = inx[i];
@@ -1496,6 +1495,33 @@ void set_sta_rate(struct adapter *padapter, struct sta_info *psta)
 	Update_RA_Entry(padapter, psta);
 }
 
+static u32 get_realtek_assoc_AP_vender(struct ndis_80211_var_ie *pIE)
+{
+	u32 Vender = HT_IOT_PEER_REALTEK;
+
+	if (pIE->Length >= 5) {
+		if (pIE->data[4] == 1)
+			/* if (pIE->data[5] & RT_HT_CAP_USE_LONG_PREAMBLE) */
+			/* bssDesc->BssHT.RT2RT_HT_Mode |= RT_HT_CAP_USE_LONG_PREAMBLE; */
+			if (pIE->data[5] & RT_HT_CAP_USE_92SE)
+				/* bssDesc->BssHT.RT2RT_HT_Mode |= RT_HT_CAP_USE_92SE; */
+				Vender = HT_IOT_PEER_REALTEK_92SE;
+
+		if (pIE->data[5] & RT_HT_CAP_USE_SOFTAP)
+			Vender = HT_IOT_PEER_REALTEK_SOFTAP;
+
+		if (pIE->data[4] == 2) {
+			if (pIE->data[6] & RT_HT_CAP_USE_JAGUAR_BCUT)
+				Vender = HT_IOT_PEER_REALTEK_JAGUAR_BCUTAP;
+
+			if (pIE->data[6] & RT_HT_CAP_USE_JAGUAR_CCUT)
+				Vender = HT_IOT_PEER_REALTEK_JAGUAR_CCUTAP;
+		}
+	}
+
+	return Vender;
+}
+
 unsigned char check_assoc_AP(u8 *pframe, uint len)
 {
 	unsigned int	i;
@@ -1519,29 +1545,7 @@ unsigned char check_assoc_AP(u8 *pframe, uint len)
 			} else if (!memcmp(pIE->data, CISCO_OUI, 3)) {
 				return HT_IOT_PEER_CISCO;
 			} else if (!memcmp(pIE->data, REALTEK_OUI, 3)) {
-				u32 Vender = HT_IOT_PEER_REALTEK;
-
-				if (pIE->Length >= 5) {
-					if (pIE->data[4] == 1)
-						/* if (pIE->data[5] & RT_HT_CAP_USE_LONG_PREAMBLE) */
-						/* bssDesc->BssHT.RT2RT_HT_Mode |= RT_HT_CAP_USE_LONG_PREAMBLE; */
-						if (pIE->data[5] & RT_HT_CAP_USE_92SE)
-							/* bssDesc->BssHT.RT2RT_HT_Mode |= RT_HT_CAP_USE_92SE; */
-							Vender = HT_IOT_PEER_REALTEK_92SE;
-
-					if (pIE->data[5] & RT_HT_CAP_USE_SOFTAP)
-						Vender = HT_IOT_PEER_REALTEK_SOFTAP;
-
-					if (pIE->data[4] == 2) {
-						if (pIE->data[6] & RT_HT_CAP_USE_JAGUAR_BCUT)
-							Vender = HT_IOT_PEER_REALTEK_JAGUAR_BCUTAP;
-
-						if (pIE->data[6] & RT_HT_CAP_USE_JAGUAR_CCUT)
-							Vender = HT_IOT_PEER_REALTEK_JAGUAR_CCUTAP;
-					}
-				}
-
-				return Vender;
+				return get_realtek_assoc_AP_vender(pIE);
 			} else if (!memcmp(pIE->data, AIRGOCAP_OUI, 3)) {
 				return HT_IOT_PEER_AIRGO;
 			} else {
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] [RFC] staging: rtl8723bs: remove unnecessary braces from conditionals
  2021-05-22  9:17 [PATCH 0/2] [RFC] staging: rtl8723bs: refactor to reduce indents Shreyansh Chouhan
  2021-05-22  9:17 ` [PATCH 1/2] " Shreyansh Chouhan
@ 2021-05-22  9:17 ` Shreyansh Chouhan
  1 sibling, 0 replies; 5+ messages in thread
From: Shreyansh Chouhan @ 2021-05-22  9:17 UTC (permalink / raw)
  To: gregkh, fabioaiuto83, ross.schm.dev, straube.linux
  Cc: Shreyansh Chouhan, linux-staging, linux-kernel

Removed the braces from if else statements in core/rtw_wlan_util.c since
the previous commit 6a257dd6de516573 caused all conditional blocks to
have a single statement in the function check_assoc_AP.

Signed-off-by: Shreyansh Chouhan <chouhan.shreyansh630@gmail.com>
---
 .../staging/rtl8723bs/core/rtw_wlan_util.c    | 35 +++++++++----------
 1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
index 36e515a7ab5c..dd965c810967 100644
--- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
+++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
@@ -1532,25 +1532,24 @@ unsigned char check_assoc_AP(u8 *pframe, uint len)
 
 		switch (pIE->ElementID) {
 		case WLAN_EID_VENDOR_SPECIFIC:
-			if ((!memcmp(pIE->data, ARTHEROS_OUI1, 3)) || (!memcmp(pIE->data, ARTHEROS_OUI2, 3))) {
+			if ((!memcmp(pIE->data, ARTHEROS_OUI1, 3)) || (!memcmp(pIE->data, ARTHEROS_OUI2, 3)))
 				return HT_IOT_PEER_ATHEROS;
-			} else if ((!memcmp(pIE->data, BROADCOM_OUI1, 3)) ||
-				   (!memcmp(pIE->data, BROADCOM_OUI2, 3)) ||
-				   (!memcmp(pIE->data, BROADCOM_OUI3, 3))) {
-				return HT_IOT_PEER_BROADCOM;
-			} else if (!memcmp(pIE->data, MARVELL_OUI, 3)) {
-				return HT_IOT_PEER_MARVELL;
-			} else if (!memcmp(pIE->data, RALINK_OUI, 3)) {
-				return HT_IOT_PEER_RALINK;
-			} else if (!memcmp(pIE->data, CISCO_OUI, 3)) {
-				return HT_IOT_PEER_CISCO;
-			} else if (!memcmp(pIE->data, REALTEK_OUI, 3)) {
-				return get_realtek_assoc_AP_vender(pIE);
-			} else if (!memcmp(pIE->data, AIRGOCAP_OUI, 3)) {
-				return HT_IOT_PEER_AIRGO;
-			} else {
-				break;
-			}
+			else if ((!memcmp(pIE->data, BROADCOM_OUI1, 3)) ||
+			         (!memcmp(pIE->data, BROADCOM_OUI2, 3)) ||
+			         (!memcmp(pIE->data, BROADCOM_OUI3, 3)))
+			      return HT_IOT_PEER_BROADCOM;
+			else if (!memcmp(pIE->data, MARVELL_OUI, 3))
+			      return HT_IOT_PEER_MARVELL;
+			else if (!memcmp(pIE->data, RALINK_OUI, 3))
+			      return HT_IOT_PEER_RALINK;
+			else if (!memcmp(pIE->data, CISCO_OUI, 3))
+			      return HT_IOT_PEER_CISCO;
+			else if (!memcmp(pIE->data, REALTEK_OUI, 3))
+			      return get_realtek_assoc_AP_vender(pIE);
+			else if (!memcmp(pIE->data, AIRGOCAP_OUI, 3))
+			      return HT_IOT_PEER_AIRGO;
+			else
+			      break;
 
 		default:
 			break;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] [RFC] staging: rtl8723bs: refactor to reduce indents
  2021-05-22  9:17 ` [PATCH 1/2] " Shreyansh Chouhan
@ 2021-05-24  9:05   ` Dan Carpenter
  2021-05-24 16:06     ` Shreyansh Chouhan
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2021-05-24  9:05 UTC (permalink / raw)
  To: Shreyansh Chouhan
  Cc: gregkh, fabioaiuto83, ross.schm.dev, straube.linux,
	linux-staging, linux-kernel

On Sat, May 22, 2021 at 02:47:18PM +0530, Shreyansh Chouhan wrote:
> Reduce the number of indents in rtw_wlan_util.c file by refactoring the
> code.
> 
> Moved the part of code that rearranged ac paramaters in the function
> WMMOnAssocResp to a separate function named sort_wmm_ac_params. It takes
> both the array of ac params and their indexes as arguments and sorts them.
> Has return type void.
> 
> Moved the part of code that checked for the realtek vendor in the
> function check_assoc_AP to a separate function named
> get_realtek_assoc_AP_vender. It takes a pointer to struct
> ndis_80211_var_ie as an argument and returns a u32 realtek vendor.
> 
> Signed-off-by: Shreyansh Chouhan <chouhan.shreyansh630@gmail.com>
> ---
>  .../staging/rtl8723bs/core/rtw_wlan_util.c    | 108 +++++++++---------
>  1 file changed, 56 insertions(+), 52 deletions(-)
> 
> diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
> index ce47ef4edea0..36e515a7ab5c 100644
> --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
> +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
> @@ -777,6 +777,32 @@ int WMM_param_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE)
>  	return true;
>  }
>  
> +static void sort_wmm_ac_params(u32 *inx, u32 *edca)
> +{
> +	u32 i, j, change_inx = false;
> +
> +	/* entry indx: 0->vo, 1->vi, 2->be, 3->bk. */
> +	for (i = 0; i < 4; i++) {
> +		for (j = i + 1; j < 4; j++) {
> +			/* compare CW and AIFS */
> +			if ((edca[j] & 0xFFFF) < (edca[i] & 0xFFFF)) {
> +				change_inx = true;
> +			} else if ((edca[j] & 0xFFFF) == (edca[i] & 0xFFFF)) {
> +				/* compare TXOP */
> +				if ((edca[j] >> 16) > (edca[i] >> 16))
> +					change_inx = true;
> +			}
> +
> +			if (change_inx) {
> +				swap(edca[i], edca[j]);
> +				swap(inx[i], inx[j]);

Using swap() is the correct thing to do, but send that change as a
separate patch.

Don't send RFC patches, just send normal patches.  No need for comments.

> +
> +				change_inx = false;
> +			}
> +		}
> +	}
> +}

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] [RFC] staging: rtl8723bs: refactor to reduce indents
  2021-05-24  9:05   ` Dan Carpenter
@ 2021-05-24 16:06     ` Shreyansh Chouhan
  0 siblings, 0 replies; 5+ messages in thread
From: Shreyansh Chouhan @ 2021-05-24 16:06 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: gregkh, fabioaiuto83, ross.schm.dev, straube.linux,
	linux-staging, linux-kernel

On Mon, May 24, 2021 at 12:05:58PM +0300, Dan Carpenter wrote:
> 
> Using swap() is the correct thing to do, but send that change as a
> separate patch.
> 
> Don't send RFC patches, just send normal patches.  No need for comments.
> 

I have resent the patches. I will keep it in mind for the future.

Thanks,
--Shreyansh Chouhan

> 
> regards,
> dan carpenter
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-05-24 16:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-22  9:17 [PATCH 0/2] [RFC] staging: rtl8723bs: refactor to reduce indents Shreyansh Chouhan
2021-05-22  9:17 ` [PATCH 1/2] " Shreyansh Chouhan
2021-05-24  9:05   ` Dan Carpenter
2021-05-24 16:06     ` Shreyansh Chouhan
2021-05-22  9:17 ` [PATCH 2/2] [RFC] staging: rtl8723bs: remove unnecessary braces from conditionals Shreyansh Chouhan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.