2022-10-24 09:02:57

by Martin Kaiser

[permalink] [raw]
Subject: [PATCH 00/17] staging: r8188eu: clean up mlme handlers

This series cleans up the mlme handlers that process incoming management
frames.

We can reorder the handler functions and remove forward declarations. We
can also remove unused return values and simplify the error handling.

This series should be applied after the "some more small cleanups" series.

As usual, this series was tested with EdimaxV2 on an arm32 system.

Martin Kaiser (17):
staging: r8188eu: restructure mlme subfunction handling
staging: r8188eu: make OnAssocReq static
staging: r8188eu: make OnAssocRsp static
staging: r8188eu: make OnProbeReq static
staging: r8188eu: make OnProbeRsp static
staging: r8188eu: make OnBeacon static
staging: r8188eu: make OnDisassoc static
staging: r8188eu: make OnAuthClient static
staging: r8188eu: make OnDeAuth static
staging: r8188eu: make OnAction static
staging: r8188eu: make OnAuth static
staging: r8188eu: change mlme handlers to void
staging: r8188eu: remove unnecessary label
staging: r8188eu: remove unnecessary else branch
staging: r8188eu: remove unnecessary return
staging: r8188eu: remove an else branch
staging: r8188eu: go2asoc is not needed

drivers/staging/r8188eu/core/rtw_mlme_ext.c | 226 ++++++++----------
.../staging/r8188eu/include/rtw_mlme_ext.h | 23 +-
2 files changed, 100 insertions(+), 149 deletions(-)

--
2.30.2


2022-10-24 09:12:58

by Martin Kaiser

[permalink] [raw]
Subject: [PATCH 11/17] staging: r8188eu: make OnAuth static

OnAuth is used only in rtw_mlme_ext.c. Make this function static.

Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/core/rtw_mlme_ext.c | 2 +-
drivers/staging/r8188eu/include/rtw_mlme_ext.h | 3 ---
2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index 08f193781776..34b41931fb66 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -651,7 +651,7 @@ static unsigned int OnBeacon(struct adapter *padapter, struct recv_frame *precv_
return _SUCCESS;
}

-unsigned int OnAuth(struct adapter *padapter, struct recv_frame *precv_frame)
+static unsigned int OnAuth(struct adapter *padapter, struct recv_frame *precv_frame)
{
unsigned int auth_mode, ie_len;
u16 seq;
diff --git a/drivers/staging/r8188eu/include/rtw_mlme_ext.h b/drivers/staging/r8188eu/include/rtw_mlme_ext.h
index f192733a5c53..f77e6dc81831 100644
--- a/drivers/staging/r8188eu/include/rtw_mlme_ext.h
+++ b/drivers/staging/r8188eu/include/rtw_mlme_ext.h
@@ -536,9 +536,6 @@ void start_clnt_auth(struct adapter *padapter);
void start_clnt_join(struct adapter *padapter);
void start_create_ibss(struct adapter *padapter);

-unsigned int OnAuth(struct adapter *padapter,
- struct recv_frame *precv_frame);
-
unsigned int OnAction_back(struct adapter *padapter,
struct recv_frame *precv_frame);
unsigned int on_action_public(struct adapter *padapter,
--
2.30.2

2022-10-24 09:13:16

by Martin Kaiser

[permalink] [raw]
Subject: [PATCH 06/17] staging: r8188eu: make OnBeacon static

OnBeacon is used only in rtw_mlme_ext.c. Make this function static.

Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/core/rtw_mlme_ext.c | 2 +-
drivers/staging/r8188eu/include/rtw_mlme_ext.h | 2 --
2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index 797c843de616..07ed3d704c2d 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -561,7 +561,7 @@ static unsigned int OnProbeRsp(struct adapter *padapter, struct recv_frame *prec
return _SUCCESS;
}

-unsigned int OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame)
+static unsigned int OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame)
{
int cam_idx;
struct sta_info *psta;
diff --git a/drivers/staging/r8188eu/include/rtw_mlme_ext.h b/drivers/staging/r8188eu/include/rtw_mlme_ext.h
index 52991ec7b3e8..b4868598eba8 100644
--- a/drivers/staging/r8188eu/include/rtw_mlme_ext.h
+++ b/drivers/staging/r8188eu/include/rtw_mlme_ext.h
@@ -536,8 +536,6 @@ void start_clnt_auth(struct adapter *padapter);
void start_clnt_join(struct adapter *padapter);
void start_create_ibss(struct adapter *padapter);

-unsigned int OnBeacon(struct adapter *padapter,
- struct recv_frame *precv_frame);
unsigned int OnDisassoc(struct adapter *padapter,
struct recv_frame *precv_frame);
unsigned int OnAuth(struct adapter *padapter,
--
2.30.2

2022-10-24 09:13:28

by Martin Kaiser

[permalink] [raw]
Subject: [PATCH 14/17] staging: r8188eu: remove unnecessary else branch

Remove an else branch in OnAuthClient that is not needed.

If we go into the else branch, go2asoc is 0. We can simply continue and
the last if condition will be false.

Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/core/rtw_mlme_ext.c | 3 ---
1 file changed, 3 deletions(-)

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index 01fe5019b333..3c6ea9912d7f 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -850,9 +850,6 @@ static void OnAuthClient(struct adapter *padapter, struct recv_frame *precv_fram
go2asoc = 1;
else
return;
- } else {
- /* this is also illegal */
- return;
}

if (go2asoc) {
--
2.30.2

2022-10-24 09:13:39

by Martin Kaiser

[permalink] [raw]
Subject: [PATCH 02/17] staging: r8188eu: make OnAssocReq static

OnAssocReq is used only in rtw_mlme_ext.c. Make this function static.

Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/core/rtw_mlme_ext.c | 2 +-
drivers/staging/r8188eu/include/rtw_mlme_ext.h | 2 --
2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index 15b7148fa898..4e7d9a273fe4 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -911,7 +911,7 @@ static void UpdateBrateTblForSoftAP(u8 *bssrateset, u32 bssratelen)
}
}

-unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame)
+static unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame)
{
u16 capab_info;
struct rtw_ieee802_11_elems elems;
diff --git a/drivers/staging/r8188eu/include/rtw_mlme_ext.h b/drivers/staging/r8188eu/include/rtw_mlme_ext.h
index 66aa8b497aa1..41e31cec9abe 100644
--- a/drivers/staging/r8188eu/include/rtw_mlme_ext.h
+++ b/drivers/staging/r8188eu/include/rtw_mlme_ext.h
@@ -536,8 +536,6 @@ void start_clnt_auth(struct adapter *padapter);
void start_clnt_join(struct adapter *padapter);
void start_create_ibss(struct adapter *padapter);

-unsigned int OnAssocReq(struct adapter *padapter,
- struct recv_frame *precv_frame);
unsigned int OnAssocRsp(struct adapter *padapter,
struct recv_frame *precv_frame);
unsigned int OnProbeReq(struct adapter *padapter,
--
2.30.2

2022-10-24 09:13:49

by Martin Kaiser

[permalink] [raw]
Subject: [PATCH 13/17] staging: r8188eu: remove unnecessary label

Remove a label on OnAuthClient that just calls return. We can return
directly instead of jumping to this label.

Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/core/rtw_mlme_ext.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index 074c95f76e27..01fe5019b333 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -823,7 +823,7 @@ static void OnAuthClient(struct adapter *padapter, struct recv_frame *precv_fram
}

set_link_timer(pmlmeext, 1);
- goto authclnt_fail;
+ return;
}

if (seq == 2) {
@@ -833,7 +833,7 @@ static void OnAuthClient(struct adapter *padapter, struct recv_frame *precv_fram
pkt_len - WLAN_HDR_A3_LEN - _AUTH_IE_OFFSET_);

if (!p)
- goto authclnt_fail;
+ return;

memcpy((void *)(pmlmeinfo->chg_txt), (void *)(p + 2), len);
pmlmeinfo->auth_seq = 3;
@@ -849,18 +849,16 @@ static void OnAuthClient(struct adapter *padapter, struct recv_frame *precv_fram
if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared)
go2asoc = 1;
else
- goto authclnt_fail;
+ return;
} else {
/* this is also illegal */
- goto authclnt_fail;
+ return;
}

if (go2asoc) {
start_clnt_assoc(padapter);
return;
}
-authclnt_fail:
- return;
}

static void UpdateBrateTbl(u8 *mbrate)
--
2.30.2

2022-10-24 09:13:51

by Martin Kaiser

[permalink] [raw]
Subject: [PATCH 04/17] staging: r8188eu: make OnProbeReq static

OnProbeReq is used only in rtw_mlme_ext.c. Make this function static.

Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/core/rtw_mlme_ext.c | 2 +-
drivers/staging/r8188eu/include/rtw_mlme_ext.h | 2 --
2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index 0b46da9de47c..4a0bea5f5052 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -447,7 +447,7 @@ Following are the callback functions for each subtype of the management frames

*****************************************************************************/

-unsigned int OnProbeReq(struct adapter *padapter, struct recv_frame *precv_frame)
+static unsigned int OnProbeReq(struct adapter *padapter, struct recv_frame *precv_frame)
{
unsigned int ielen;
unsigned char *p;
diff --git a/drivers/staging/r8188eu/include/rtw_mlme_ext.h b/drivers/staging/r8188eu/include/rtw_mlme_ext.h
index c2b1aa2f378b..b24aae8108b6 100644
--- a/drivers/staging/r8188eu/include/rtw_mlme_ext.h
+++ b/drivers/staging/r8188eu/include/rtw_mlme_ext.h
@@ -536,8 +536,6 @@ void start_clnt_auth(struct adapter *padapter);
void start_clnt_join(struct adapter *padapter);
void start_create_ibss(struct adapter *padapter);

-unsigned int OnProbeReq(struct adapter *padapter,
- struct recv_frame *precv_frame);
unsigned int OnProbeRsp(struct adapter *padapter,
struct recv_frame *precv_frame);
unsigned int OnBeacon(struct adapter *padapter,
--
2.30.2

2022-10-24 09:13:54

by Martin Kaiser

[permalink] [raw]
Subject: [PATCH 03/17] staging: r8188eu: make OnAssocRsp static

OnAssocRsp is used only in rtw_mlme_ext.c. Make this function static.

Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/core/rtw_mlme_ext.c | 2 +-
drivers/staging/r8188eu/include/rtw_mlme_ext.h | 2 --
2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index 4e7d9a273fe4..0b46da9de47c 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -1319,7 +1319,7 @@ static unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *prec
return _FAIL;
}

-unsigned int OnAssocRsp(struct adapter *padapter, struct recv_frame *precv_frame)
+static unsigned int OnAssocRsp(struct adapter *padapter, struct recv_frame *precv_frame)
{
struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)precv_frame->rx_data;
uint i;
diff --git a/drivers/staging/r8188eu/include/rtw_mlme_ext.h b/drivers/staging/r8188eu/include/rtw_mlme_ext.h
index 41e31cec9abe..c2b1aa2f378b 100644
--- a/drivers/staging/r8188eu/include/rtw_mlme_ext.h
+++ b/drivers/staging/r8188eu/include/rtw_mlme_ext.h
@@ -536,8 +536,6 @@ void start_clnt_auth(struct adapter *padapter);
void start_clnt_join(struct adapter *padapter);
void start_create_ibss(struct adapter *padapter);

-unsigned int OnAssocRsp(struct adapter *padapter,
- struct recv_frame *precv_frame);
unsigned int OnProbeReq(struct adapter *padapter,
struct recv_frame *precv_frame);
unsigned int OnProbeRsp(struct adapter *padapter,
--
2.30.2

2022-10-24 09:16:54

by Martin Kaiser

[permalink] [raw]
Subject: [PATCH 05/17] staging: r8188eu: make OnProbeRsp static

OnProbeRsp is used only in rtw_mlme_ext.c. Make this function static.

Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/core/rtw_mlme_ext.c | 2 +-
drivers/staging/r8188eu/include/rtw_mlme_ext.h | 2 --
2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index 4a0bea5f5052..797c843de616 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -515,7 +515,7 @@ static unsigned int OnProbeReq(struct adapter *padapter, struct recv_frame *prec
return _SUCCESS;
}

-unsigned int OnProbeRsp(struct adapter *padapter, struct recv_frame *precv_frame)
+static unsigned int OnProbeRsp(struct adapter *padapter, struct recv_frame *precv_frame)
{
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
struct wifidirect_info *pwdinfo = &padapter->wdinfo;
diff --git a/drivers/staging/r8188eu/include/rtw_mlme_ext.h b/drivers/staging/r8188eu/include/rtw_mlme_ext.h
index b24aae8108b6..52991ec7b3e8 100644
--- a/drivers/staging/r8188eu/include/rtw_mlme_ext.h
+++ b/drivers/staging/r8188eu/include/rtw_mlme_ext.h
@@ -536,8 +536,6 @@ void start_clnt_auth(struct adapter *padapter);
void start_clnt_join(struct adapter *padapter);
void start_create_ibss(struct adapter *padapter);

-unsigned int OnProbeRsp(struct adapter *padapter,
- struct recv_frame *precv_frame);
unsigned int OnBeacon(struct adapter *padapter,
struct recv_frame *precv_frame);
unsigned int OnDisassoc(struct adapter *padapter,
--
2.30.2

2022-10-24 09:17:36

by Martin Kaiser

[permalink] [raw]
Subject: [PATCH 15/17] staging: r8188eu: remove unnecessary return

Remove a return statement at the end of a function.

Signed-off-by: Martin Kaiser <[email protected]>
---
drivers/staging/r8188eu/core/rtw_mlme_ext.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
index 3c6ea9912d7f..7120e015d1bd 100644
--- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c
@@ -852,10 +852,8 @@ static void OnAuthClient(struct adapter *padapter, struct recv_frame *precv_fram
return;
}

- if (go2asoc) {
+ if (go2asoc)
start_clnt_assoc(padapter);
- return;
- }
}

static void UpdateBrateTbl(u8 *mbrate)
--
2.30.2

2022-10-24 21:47:44

by Philipp Hortmann

[permalink] [raw]
Subject: Re: [PATCH 00/17] staging: r8188eu: clean up mlme handlers

On 10/24/22 10:14, Martin Kaiser wrote:
> This series cleans up the mlme handlers that process incoming management
> frames.
>
> We can reorder the handler functions and remove forward declarations. We
> can also remove unused return values and simplify the error handling.
>
> This series should be applied after the "some more small cleanups" series.
>
> As usual, this series was tested with EdimaxV2 on an arm32 system.
>
> Martin Kaiser (17):
> staging: r8188eu: restructure mlme subfunction handling
> staging: r8188eu: make OnAssocReq static
> staging: r8188eu: make OnAssocRsp static
> staging: r8188eu: make OnProbeReq static
> staging: r8188eu: make OnProbeRsp static
> staging: r8188eu: make OnBeacon static
> staging: r8188eu: make OnDisassoc static
> staging: r8188eu: make OnAuthClient static
> staging: r8188eu: make OnDeAuth static
> staging: r8188eu: make OnAction static
> staging: r8188eu: make OnAuth static
> staging: r8188eu: change mlme handlers to void
> staging: r8188eu: remove unnecessary label
> staging: r8188eu: remove unnecessary else branch
> staging: r8188eu: remove unnecessary return
> staging: r8188eu: remove an else branch
> staging: r8188eu: go2asoc is not needed
>
> drivers/staging/r8188eu/core/rtw_mlme_ext.c | 226 ++++++++----------
> .../staging/r8188eu/include/rtw_mlme_ext.h | 23 +-
> 2 files changed, 100 insertions(+), 149 deletions(-)
>
Tested-by: Philipp Hortmann <[email protected]> # Edimax N150