* [PATCH 2/5] staging: rtl8723bs: make cckrates{only}_included static
2020-09-12 8:45 [PATCH 1/5] staging: rtl8723bs: refactor cckrates{only}_included Michael Straube
@ 2020-09-12 8:45 ` Michael Straube
2020-09-12 8:45 ` [PATCH 3/5] staging: rtl8723bs: convert cckrates{only}_included to bool Michael Straube
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Michael Straube @ 2020-09-12 8:45 UTC (permalink / raw)
To: gregkh; +Cc: hdegoede, Larry.Finger, devel, linux-kernel, Michael Straube
Functions cckrates_included() and cckratesonly_included() are used only
in the file core/rtw_wlan_util.c. Make them static and remove extern
declarations from include/rtw_mlme_ext.c.
Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 4 ++--
drivers/staging/rtl8723bs/include/rtw_mlme_ext.h | 2 --
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
index 4e0d86b2e2e0..22e4305d70a2 100644
--- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
+++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
@@ -54,7 +54,7 @@ static u8 rtw_basic_rate_ofdm[3] = {
IEEE80211_OFDM_RATE_24MB | IEEE80211_BASIC_RATE_MASK
};
-int cckrates_included(unsigned char *rate, int ratelen)
+static int cckrates_included(unsigned char *rate, int ratelen)
{
int i;
@@ -68,7 +68,7 @@ int cckrates_included(unsigned char *rate, int ratelen)
return false;
}
-int cckratesonly_included(unsigned char *rate, int ratelen)
+static int cckratesonly_included(unsigned char *rate, int ratelen)
{
int i;
diff --git a/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h b/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h
index 14583799039f..1567831caf91 100644
--- a/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h
+++ b/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h
@@ -716,8 +716,6 @@ void sa_query_timer_hdl(struct timer_list *t);
DBG_871X("%s set_sa_query_timer(%p, %d)\n", __func__, (mlmeext), (ms)); \
_set_timer(&(mlmeext)->sa_query_timer, (ms)); \
} while (0)
-extern int cckrates_included(unsigned char *rate, int ratelen);
-extern int cckratesonly_included(unsigned char *rate, int ratelen);
extern void process_addba_req(struct adapter *padapter, u8 *paddba_req, u8 *addr);
--
2.28.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/5] staging: rtl8723bs: convert cckrates{only}_included to bool
2020-09-12 8:45 [PATCH 1/5] staging: rtl8723bs: refactor cckrates{only}_included Michael Straube
2020-09-12 8:45 ` [PATCH 2/5] staging: rtl8723bs: make cckrates{only}_included static Michael Straube
@ 2020-09-12 8:45 ` Michael Straube
2020-09-12 8:45 ` [PATCH 4/5] staging: rtl8723bs: remove comparsions to true Michael Straube
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Michael Straube @ 2020-09-12 8:45 UTC (permalink / raw)
To: gregkh; +Cc: hdegoede, Larry.Finger, devel, linux-kernel, Michael Straube
Functions cckrates_included() and cckratesonly_included() return
boolean values. Convert the return type from int to bool.
Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
index 22e4305d70a2..7733d076af85 100644
--- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
+++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
@@ -54,7 +54,7 @@ static u8 rtw_basic_rate_ofdm[3] = {
IEEE80211_OFDM_RATE_24MB | IEEE80211_BASIC_RATE_MASK
};
-static int cckrates_included(unsigned char *rate, int ratelen)
+static bool cckrates_included(unsigned char *rate, int ratelen)
{
int i;
@@ -68,7 +68,7 @@ static int cckrates_included(unsigned char *rate, int ratelen)
return false;
}
-static int cckratesonly_included(unsigned char *rate, int ratelen)
+static bool cckratesonly_included(unsigned char *rate, int ratelen)
{
int i;
--
2.28.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/5] staging: rtl8723bs: remove comparsions to true
2020-09-12 8:45 [PATCH 1/5] staging: rtl8723bs: refactor cckrates{only}_included Michael Straube
2020-09-12 8:45 ` [PATCH 2/5] staging: rtl8723bs: make cckrates{only}_included static Michael Straube
2020-09-12 8:45 ` [PATCH 3/5] staging: rtl8723bs: convert cckrates{only}_included to bool Michael Straube
@ 2020-09-12 8:45 ` Michael Straube
2020-09-12 8:45 ` [PATCH 5/5] staging: rtl8723bs: remove 5 GHz code Michael Straube
2020-09-12 18:22 ` [PATCH 1/5] staging: rtl8723bs: refactor cckrates{only}_included Joe Perches
4 siblings, 0 replies; 8+ messages in thread
From: Michael Straube @ 2020-09-12 8:45 UTC (permalink / raw)
To: gregkh; +Cc: hdegoede, Larry.Finger, devel, linux-kernel, Michael Straube
Remove unnecessary comparsions to boolean values.
Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
index 7733d076af85..cad35ce0c21a 100644
--- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
+++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
@@ -1767,9 +1767,9 @@ void update_wireless_mode(struct adapter *padapter)
else if (pmlmeinfo->HT_enable)
network_type = WIRELESS_11_24N;
- if ((cckratesonly_included(rate, ratelen)) == true)
+ if (cckratesonly_included(rate, ratelen))
network_type |= WIRELESS_11B;
- else if ((cckrates_included(rate, ratelen)) == true)
+ else if (cckrates_included(rate, ratelen))
network_type |= WIRELESS_11BG;
else
network_type |= WIRELESS_11G;
--
2.28.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 5/5] staging: rtl8723bs: remove 5 GHz code
2020-09-12 8:45 [PATCH 1/5] staging: rtl8723bs: refactor cckrates{only}_included Michael Straube
` (2 preceding siblings ...)
2020-09-12 8:45 ` [PATCH 4/5] staging: rtl8723bs: remove comparsions to true Michael Straube
@ 2020-09-12 8:45 ` Michael Straube
2020-09-12 18:22 ` [PATCH 1/5] staging: rtl8723bs: refactor cckrates{only}_included Joe Perches
4 siblings, 0 replies; 8+ messages in thread
From: Michael Straube @ 2020-09-12 8:45 UTC (permalink / raw)
To: gregkh; +Cc: hdegoede, Larry.Finger, devel, linux-kernel, Michael Straube
Acoording to the TODO code valid only for 5 GHz should be removed.
- find and remove remaining code valid only for 5 GHz. Most of the obvious
ones have been removed, but things like channel > 14 still exist.
Remove code path only valid for channels > 14.
Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
.../staging/rtl8723bs/core/rtw_wlan_util.c | 31 +++++++------------
1 file changed, 11 insertions(+), 20 deletions(-)
diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
index cad35ce0c21a..fdb5a6b51c03 100644
--- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
+++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
@@ -1754,26 +1754,17 @@ void update_wireless_mode(struct adapter *padapter)
if ((pmlmeinfo->HT_info_enable) && (pmlmeinfo->HT_caps_enable))
pmlmeinfo->HT_enable = 1;
- if (pmlmeext->cur_channel > 14) {
- if (pmlmeinfo->VHT_enable)
- network_type = WIRELESS_11AC;
- else if (pmlmeinfo->HT_enable)
- network_type = WIRELESS_11_5N;
-
- network_type |= WIRELESS_11A;
- } else {
- if (pmlmeinfo->VHT_enable)
- network_type = WIRELESS_11AC;
- else if (pmlmeinfo->HT_enable)
- network_type = WIRELESS_11_24N;
-
- if (cckratesonly_included(rate, ratelen))
- network_type |= WIRELESS_11B;
- else if (cckrates_included(rate, ratelen))
- network_type |= WIRELESS_11BG;
- else
- network_type |= WIRELESS_11G;
- }
+ if (pmlmeinfo->VHT_enable)
+ network_type = WIRELESS_11AC;
+ else if (pmlmeinfo->HT_enable)
+ network_type = WIRELESS_11_24N;
+
+ if (cckratesonly_included(rate, ratelen))
+ network_type |= WIRELESS_11B;
+ else if (cckrates_included(rate, ratelen))
+ network_type |= WIRELESS_11BG;
+ else
+ network_type |= WIRELESS_11G;
pmlmeext->cur_wireless_mode = network_type & padapter->registrypriv.wireless_mode;
--
2.28.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/5] staging: rtl8723bs: refactor cckrates{only}_included
2020-09-12 8:45 [PATCH 1/5] staging: rtl8723bs: refactor cckrates{only}_included Michael Straube
` (3 preceding siblings ...)
2020-09-12 8:45 ` [PATCH 5/5] staging: rtl8723bs: remove 5 GHz code Michael Straube
@ 2020-09-12 18:22 ` Joe Perches
2020-09-12 18:43 ` Joe Perches
2020-09-13 8:16 ` Michael Straube
4 siblings, 2 replies; 8+ messages in thread
From: Joe Perches @ 2020-09-12 18:22 UTC (permalink / raw)
To: Michael Straube, gregkh; +Cc: hdegoede, Larry.Finger, devel, linux-kernel
On Sat, 2020-09-12 at 10:45 +0200, Michael Straube wrote:
> Refactor cckrates_included() and cckratesonly_included() to simplify
> the code and improve readability.
>
> Signed-off-by: Michael Straube <straube.linux@gmail.com>
> ---
> drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
> index a5790a648a5b..4e0d86b2e2e0 100644
> --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
> +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
> @@ -56,11 +56,12 @@ static u8 rtw_basic_rate_ofdm[3] = {
>
> int cckrates_included(unsigned char *rate, int ratelen)
> {
> - int i;
> + int i;
>
> for (i = 0; i < ratelen; i++) {
> - if ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) ||
> - (((rate[i]) & 0x7f) == 11) || (((rate[i]) & 0x7f) == 22))
> + u8 r = rate[i] & 0x7f;
> +
> + if (r == 2 || r == 4 || r == 11 || r == 22)
> return true;
> }
>
> @@ -69,11 +70,12 @@ int cckrates_included(unsigned char *rate, int ratelen)
>
> int cckratesonly_included(unsigned char *rate, int ratelen)
> {
> - int i;
> + int i;
>
> for (i = 0; i < ratelen; i++) {
> - if ((((rate[i]) & 0x7f) != 2) && (((rate[i]) & 0x7f) != 4) &&
> - (((rate[i]) & 0x7f) != 11) && (((rate[i]) & 0x7f) != 22))
> + u8 r = rate[i] & 0x7f;
> +
> + if (r != 2 && r != 4 && r != 11 && r != 22)
> return false;
It would be simpler to add and use an inline like:
static bool is_cckrate(unsigned char rate)
{
rate &= 0x7f;
return rate == 2 || rate == 4 || rate == 11 || rate == 22;
}
so these could be
bool cckrates_included(unsigned char *rate, int ratelen)
{
int i;
for (i = 0; i < ratelen; i++) {
if (is_cckrate(rate[i])
return true;
}
return false;
}
bool cckratesonly_included(unsigned char *rate, int ratelen)
{
int i;
if (i <= 0)
return false;
for (i = 0; i < ratelen; i++) {
if (!is_cckrate(rate[i])
return false;
}
return true;
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/5] staging: rtl8723bs: refactor cckrates{only}_included
2020-09-12 18:22 ` [PATCH 1/5] staging: rtl8723bs: refactor cckrates{only}_included Joe Perches
@ 2020-09-12 18:43 ` Joe Perches
2020-09-13 8:16 ` Michael Straube
1 sibling, 0 replies; 8+ messages in thread
From: Joe Perches @ 2020-09-12 18:43 UTC (permalink / raw)
To: Michael Straube, gregkh; +Cc: hdegoede, Larry.Finger, devel, linux-kernel
On Sat, 2020-09-12 at 11:22 -0700, Joe Perches wrote:
> On Sat, 2020-09-12 at 10:45 +0200, Michael Straube wrote:
> > Refactor cckrates_included() and cckratesonly_included() to simplify
> > the code and improve readability.
[]
> diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
[]
> bool cckratesonly_included(unsigned char *rate, int ratelen)
> {
[]
> if (i <= 0)
if (ratelen <= 0) of course...
> return false;
>
> for (i = 0; i < ratelen; i++) {
> if (!is_cckrate(rate[i])
> return false;
> }
>
> return true;
> }
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/5] staging: rtl8723bs: refactor cckrates{only}_included
2020-09-12 18:22 ` [PATCH 1/5] staging: rtl8723bs: refactor cckrates{only}_included Joe Perches
2020-09-12 18:43 ` Joe Perches
@ 2020-09-13 8:16 ` Michael Straube
1 sibling, 0 replies; 8+ messages in thread
From: Michael Straube @ 2020-09-13 8:16 UTC (permalink / raw)
To: Joe Perches, gregkh; +Cc: hdegoede, Larry.Finger, devel, linux-kernel
On 2020-09-12 20:22, Joe Perches wrote:
> On Sat, 2020-09-12 at 10:45 +0200, Michael Straube wrote:
>> Refactor cckrates_included() and cckratesonly_included() to simplify
>> the code and improve readability.
>>
>> Signed-off-by: Michael Straube <straube.linux@gmail.com>
>> ---
>> drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 14 ++++++++------
>> 1 file changed, 8 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
>> index a5790a648a5b..4e0d86b2e2e0 100644
>> --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
>> +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
>> @@ -56,11 +56,12 @@ static u8 rtw_basic_rate_ofdm[3] = {
>>
>> int cckrates_included(unsigned char *rate, int ratelen)
>> {
>> - int i;
>> + int i;
>>
>> for (i = 0; i < ratelen; i++) {
>> - if ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) ||
>> - (((rate[i]) & 0x7f) == 11) || (((rate[i]) & 0x7f) == 22))
>> + u8 r = rate[i] & 0x7f;
>> +
>> + if (r == 2 || r == 4 || r == 11 || r == 22)
>> return true;
>> }
>>
>> @@ -69,11 +70,12 @@ int cckrates_included(unsigned char *rate, int ratelen)
>>
>> int cckratesonly_included(unsigned char *rate, int ratelen)
>> {
>> - int i;
>> + int i;
>>
>> for (i = 0; i < ratelen; i++) {
>> - if ((((rate[i]) & 0x7f) != 2) && (((rate[i]) & 0x7f) != 4) &&
>> - (((rate[i]) & 0x7f) != 11) && (((rate[i]) & 0x7f) != 22))
>> + u8 r = rate[i] & 0x7f;
>> +
>> + if (r != 2 && r != 4 && r != 11 && r != 22)
>> return false;
>
> It would be simpler to add and use an inline like:
>
> static bool is_cckrate(unsigned char rate)
> {
> rate &= 0x7f;
> return rate == 2 || rate == 4 || rate == 11 || rate == 22;
> }
>
> so these could be
>
> bool cckrates_included(unsigned char *rate, int ratelen)
> {
> int i;
>
> for (i = 0; i < ratelen; i++) {
> if (is_cckrate(rate[i])
> return true;
> }
>
> return false;
> }
>
> bool cckratesonly_included(unsigned char *rate, int ratelen)
> {
> int i;
>
> if (i <= 0)
> return false;
>
> for (i = 0; i < ratelen; i++) {
> if (!is_cckrate(rate[i])
> return false;
> }
>
> return true;
> }
>
>
I've just seen that there are already rtw_is_cckrates_included and rtw_is_cckratesonly_included
in rtw_ieee80211.c that can be used here.
I will send another series removing the functions from rtw_wlan_util.c and use the ones from
rtw_ieee80211.c.
So please don't merge this series, thanks.
Michael
^ permalink raw reply [flat|nested] 8+ messages in thread