linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] staging:r8188eu: refactor OnAction(): use switch instead table lookup
@ 2021-03-28 16:33 Ivan Safonov
  2021-03-28 16:33 ` [PATCH 2/2] staging:r8188eu: remove dummy handlers from OnAction() Ivan Safonov
  2021-04-02 13:04 ` [PATCH 1/2] staging:r8188eu: refactor OnAction(): use switch instead table lookup Greg Kroah-Hartman
  0 siblings, 2 replies; 6+ messages in thread
From: Ivan Safonov @ 2021-03-28 16:33 UTC (permalink / raw)
  To: Larry Finger
  Cc: Greg Kroah-Hartman, Michael Straube, Gustavo A. R. Silva,
	Peilin Ye, linux-staging, linux-kernel, Ivan Safonov

The switch is easier to read and refactor.

Signed-off-by: Ivan Safonov <insafonov@gmail.com>
---
 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 57 ++++++++++++-------
 .../staging/rtl8188eu/include/rtw_mlme_ext.h  |  6 --
 2 files changed, 37 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
index 50d3c3631be0..4d741737d671 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
@@ -3780,26 +3780,10 @@ static unsigned int DoReserved(struct adapter *padapter,
 	return _SUCCESS;
 }
 
-static struct action_handler OnAction_tbl[] = {
-	{RTW_WLAN_CATEGORY_SPECTRUM_MGMT,	 "ACTION_SPECTRUM_MGMT", on_action_spct},
-	{RTW_WLAN_CATEGORY_QOS, "ACTION_QOS", &OnAction_qos},
-	{RTW_WLAN_CATEGORY_DLS, "ACTION_DLS", &OnAction_dls},
-	{RTW_WLAN_CATEGORY_BACK, "ACTION_BACK", &OnAction_back},
-	{RTW_WLAN_CATEGORY_PUBLIC, "ACTION_PUBLIC", on_action_public},
-	{RTW_WLAN_CATEGORY_RADIO_MEASUREMENT, "ACTION_RADIO_MEASUREMENT", &DoReserved},
-	{RTW_WLAN_CATEGORY_FT, "ACTION_FT",	&DoReserved},
-	{RTW_WLAN_CATEGORY_HT,	"ACTION_HT",	&OnAction_ht},
-	{RTW_WLAN_CATEGORY_SA_QUERY, "ACTION_SA_QUERY", &DoReserved},
-	{RTW_WLAN_CATEGORY_WMM, "ACTION_WMM", &OnAction_wmm},
-	{RTW_WLAN_CATEGORY_P2P, "ACTION_P2P", &OnAction_p2p},
-};
-
 static unsigned int OnAction(struct adapter *padapter,
 			     struct recv_frame *precv_frame)
 {
-	int i;
 	unsigned char category;
-	struct action_handler *ptable;
 	unsigned char *frame_body;
 	u8 *pframe = precv_frame->pkt->data;
 
@@ -3807,11 +3791,44 @@ static unsigned int OnAction(struct adapter *padapter,
 
 	category = frame_body[0];
 
-	for (i = 0; i < ARRAY_SIZE(OnAction_tbl); i++) {
-		ptable = &OnAction_tbl[i];
-		if (category == ptable->num)
-			ptable->func(padapter, precv_frame);
+	switch (category) {
+	case RTW_WLAN_CATEGORY_SPECTRUM_MGMT:
+		on_action_spct(padapter, precv_frame);
+		break;
+	case RTW_WLAN_CATEGORY_QOS:
+		OnAction_qos(padapter, precv_frame);
+		break;
+	case RTW_WLAN_CATEGORY_DLS:
+		OnAction_dls(padapter, precv_frame);
+		break;
+	case RTW_WLAN_CATEGORY_BACK:
+		OnAction_back(padapter, precv_frame);
+		break;
+	case RTW_WLAN_CATEGORY_PUBLIC:
+		on_action_public(padapter, precv_frame);
+		break;
+	case RTW_WLAN_CATEGORY_RADIO_MEASUREMENT:
+		DoReserved(padapter, precv_frame);
+		break;
+	case RTW_WLAN_CATEGORY_FT:
+		DoReserved(padapter, precv_frame);
+		break;
+	case RTW_WLAN_CATEGORY_HT:
+		OnAction_ht(padapter, precv_frame);
+		break;
+	case RTW_WLAN_CATEGORY_SA_QUERY:
+		DoReserved(padapter, precv_frame);
+		break;
+	case RTW_WLAN_CATEGORY_WMM:
+		OnAction_wmm(padapter, precv_frame);
+		break;
+	case RTW_WLAN_CATEGORY_P2P:
+		OnAction_p2p(padapter, precv_frame);
+		break;
+	default:
+		break;
 	}
+
 	return _SUCCESS;
 }
 
diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h
index b11a6886a083..aa733abad10c 100644
--- a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h
+++ b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h
@@ -227,12 +227,6 @@ struct mlme_handler {
 	unsigned int (*func)(struct adapter *adapt, struct recv_frame *frame);
 };
 
-struct action_handler {
-	unsigned int num;
-	const char *str;
-	unsigned int (*func)(struct adapter *adapt, struct recv_frame *frame);
-};
-
 struct ss_res {
 	int state;
 	int bss_cnt;
-- 
2.26.2


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

* [PATCH 2/2] staging:r8188eu: remove dummy handlers from OnAction()
  2021-03-28 16:33 [PATCH 1/2] staging:r8188eu: refactor OnAction(): use switch instead table lookup Ivan Safonov
@ 2021-03-28 16:33 ` Ivan Safonov
  2021-04-02 13:04   ` Greg Kroah-Hartman
  2021-04-02 13:04 ` [PATCH 1/2] staging:r8188eu: refactor OnAction(): use switch instead table lookup Greg Kroah-Hartman
  1 sibling, 1 reply; 6+ messages in thread
From: Ivan Safonov @ 2021-03-28 16:33 UTC (permalink / raw)
  To: Larry Finger
  Cc: Greg Kroah-Hartman, Michael Straube, Gustavo A. R. Silva,
	Peilin Ye, linux-staging, linux-kernel, Ivan Safonov

on_action_spct() do nothing, because rtw_get_stainfo() has no side
effects. Other action handlers are trivial.

Signed-off-by: Ivan Safonov <insafonov@gmail.com>
---
 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 95 -------------------
 1 file changed, 95 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
index 4d741737d671..fca02f17ba98 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
@@ -3517,56 +3517,6 @@ static unsigned int OnAtim(struct adapter *padapter,
 	return _SUCCESS;
 }
 
-static unsigned int on_action_spct(struct adapter *padapter,
-				   struct recv_frame *precv_frame)
-{
-	struct sta_info *psta = NULL;
-	struct sta_priv *pstapriv = &padapter->stapriv;
-	u8 *pframe = precv_frame->pkt->data;
-	u8 *frame_body = pframe + sizeof(struct ieee80211_hdr_3addr);
-	u8 category;
-	u8 action;
-
-	DBG_88E(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(padapter->pnetdev));
-
-	psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe));
-
-	if (!psta)
-		goto exit;
-
-	category = frame_body[0];
-	if (category != RTW_WLAN_CATEGORY_SPECTRUM_MGMT)
-		goto exit;
-
-	action = frame_body[1];
-	switch (action) {
-	case WLAN_ACTION_SPCT_MSR_REQ:
-	case WLAN_ACTION_SPCT_MSR_RPRT:
-	case WLAN_ACTION_SPCT_TPC_REQ:
-	case WLAN_ACTION_SPCT_TPC_RPRT:
-		break;
-	case WLAN_ACTION_SPCT_CHL_SWITCH:
-		break;
-	default:
-		break;
-	}
-
-exit:
-	return _FAIL;
-}
-
-static unsigned int OnAction_qos(struct adapter *padapter,
-				 struct recv_frame *precv_frame)
-{
-	return _SUCCESS;
-}
-
-static unsigned int OnAction_dls(struct adapter *padapter,
-				 struct recv_frame *precv_frame)
-{
-	return _SUCCESS;
-}
-
 static unsigned int OnAction_back(struct adapter *padapter,
 				  struct recv_frame *precv_frame)
 {
@@ -3756,24 +3706,6 @@ static unsigned int on_action_public(struct adapter *padapter,
 	return ret;
 }
 
-static unsigned int OnAction_ht(struct adapter *padapter,
-				struct recv_frame *precv_frame)
-{
-	return _SUCCESS;
-}
-
-static unsigned int OnAction_wmm(struct adapter *padapter,
-				 struct recv_frame *precv_frame)
-{
-	return _SUCCESS;
-}
-
-static unsigned int OnAction_p2p(struct adapter *padapter,
-				 struct recv_frame *precv_frame)
-{
-	return _SUCCESS;
-}
-
 static unsigned int DoReserved(struct adapter *padapter,
 			       struct recv_frame *precv_frame)
 {
@@ -3792,39 +3724,12 @@ static unsigned int OnAction(struct adapter *padapter,
 	category = frame_body[0];
 
 	switch (category) {
-	case RTW_WLAN_CATEGORY_SPECTRUM_MGMT:
-		on_action_spct(padapter, precv_frame);
-		break;
-	case RTW_WLAN_CATEGORY_QOS:
-		OnAction_qos(padapter, precv_frame);
-		break;
-	case RTW_WLAN_CATEGORY_DLS:
-		OnAction_dls(padapter, precv_frame);
-		break;
 	case RTW_WLAN_CATEGORY_BACK:
 		OnAction_back(padapter, precv_frame);
 		break;
 	case RTW_WLAN_CATEGORY_PUBLIC:
 		on_action_public(padapter, precv_frame);
 		break;
-	case RTW_WLAN_CATEGORY_RADIO_MEASUREMENT:
-		DoReserved(padapter, precv_frame);
-		break;
-	case RTW_WLAN_CATEGORY_FT:
-		DoReserved(padapter, precv_frame);
-		break;
-	case RTW_WLAN_CATEGORY_HT:
-		OnAction_ht(padapter, precv_frame);
-		break;
-	case RTW_WLAN_CATEGORY_SA_QUERY:
-		DoReserved(padapter, precv_frame);
-		break;
-	case RTW_WLAN_CATEGORY_WMM:
-		OnAction_wmm(padapter, precv_frame);
-		break;
-	case RTW_WLAN_CATEGORY_P2P:
-		OnAction_p2p(padapter, precv_frame);
-		break;
 	default:
 		break;
 	}
-- 
2.26.2


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

* Re: [PATCH 1/2] staging:r8188eu: refactor OnAction(): use switch instead table lookup
  2021-03-28 16:33 [PATCH 1/2] staging:r8188eu: refactor OnAction(): use switch instead table lookup Ivan Safonov
  2021-03-28 16:33 ` [PATCH 2/2] staging:r8188eu: remove dummy handlers from OnAction() Ivan Safonov
@ 2021-04-02 13:04 ` Greg Kroah-Hartman
  1 sibling, 0 replies; 6+ messages in thread
From: Greg Kroah-Hartman @ 2021-04-02 13:04 UTC (permalink / raw)
  To: Ivan Safonov
  Cc: Larry Finger, Michael Straube, Gustavo A. R. Silva, Peilin Ye,
	linux-staging, linux-kernel

On Sun, Mar 28, 2021 at 07:33:23PM +0300, Ivan Safonov wrote:
> The switch is easier to read and refactor.

Your subject line is incorrect :(


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

* Re: [PATCH 2/2] staging:r8188eu: remove dummy handlers from OnAction()
  2021-03-28 16:33 ` [PATCH 2/2] staging:r8188eu: remove dummy handlers from OnAction() Ivan Safonov
@ 2021-04-02 13:04   ` Greg Kroah-Hartman
  2021-04-03 21:30     ` Ivan Safonov
  0 siblings, 1 reply; 6+ messages in thread
From: Greg Kroah-Hartman @ 2021-04-02 13:04 UTC (permalink / raw)
  To: Ivan Safonov
  Cc: Larry Finger, Michael Straube, Gustavo A. R. Silva, Peilin Ye,
	linux-staging, linux-kernel

On Sun, Mar 28, 2021 at 07:33:25PM +0300, Ivan Safonov wrote:
> on_action_spct() do nothing, because rtw_get_stainfo() has no side
> effects. Other action handlers are trivial.
> 
> Signed-off-by: Ivan Safonov <insafonov@gmail.com>

Same here, wrong driver name :(

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

* Re: [PATCH 2/2] staging:r8188eu: remove dummy handlers from OnAction()
  2021-04-02 13:04   ` Greg Kroah-Hartman
@ 2021-04-03 21:30     ` Ivan Safonov
  2021-04-04  9:56       ` Greg Kroah-Hartman
  0 siblings, 1 reply; 6+ messages in thread
From: Ivan Safonov @ 2021-04-03 21:30 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Larry Finger, Michael Straube, Gustavo A. R. Silva, Peilin Ye,
	linux-staging, linux-kernel

On 4/2/21 4:04 PM, Greg Kroah-Hartman wrote:
> On Sun, Mar 28, 2021 at 07:33:25PM +0300, Ivan Safonov wrote:
>> on_action_spct() do nothing, because rtw_get_stainfo() has no side
>> effects. Other action handlers are trivial.
>>
>> Signed-off-by: Ivan Safonov <insafonov@gmail.com>
> 
> Same here, wrong driver name :(
> 

Driver name is "r8188eu"...

$ grep 'r8188eu' drivers/staging/rtl8188eu/include/drv_types.h
#define DRV_NAME "r8188eu"

$ grep 'r8188eu' drivers/staging/rtl8188eu/os_dep/usb_intf.c -B1 -A7
static struct usb_driver rtl8188e_usb_drv = {
         .name = "r8188eu",
         .probe = rtw_drv_init,
         .disconnect = rtw_dev_remove,
         .id_table = rtw_usb_id_tbl,
         .suspend =  rtw_suspend,
         .resume = rtw_resume,
         .reset_resume = rtw_resume,
};

$ cat drivers/staging/rtl8188eu/Kconfig
# SPDX-License-Identifier: GPL-2.0
config R8188EU
         tristate "Realtek RTL8188EU Wireless LAN NIC driver"
         depends on WLAN && USB && CFG80211
         depends on m
         select WIRELESS_EXT
         select WEXT_PRIV
         select LIB80211
         select LIB80211_CRYPT_WEP
         select LIB80211_CRYPT_CCMP
         help
         This option adds the Realtek RTL8188EU USB device such as 
TP-Link TL-WN725N.
         If built as a module, it will be called r8188eu.

if R8188EU

config 88EU_AP_MODE
         bool "Realtek RTL8188EU AP mode"
         default y
         help
         This option enables Access Point mode. Unless you know that 
your system
         will never be used as an AP, or the target system has limited 
memory,
         "Y" should be selected.

endif

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

* Re: [PATCH 2/2] staging:r8188eu: remove dummy handlers from OnAction()
  2021-04-03 21:30     ` Ivan Safonov
@ 2021-04-04  9:56       ` Greg Kroah-Hartman
  0 siblings, 0 replies; 6+ messages in thread
From: Greg Kroah-Hartman @ 2021-04-04  9:56 UTC (permalink / raw)
  To: Ivan Safonov
  Cc: Larry Finger, Michael Straube, Gustavo A. R. Silva, Peilin Ye,
	linux-staging, linux-kernel

On Sun, Apr 04, 2021 at 12:30:41AM +0300, Ivan Safonov wrote:
> On 4/2/21 4:04 PM, Greg Kroah-Hartman wrote:
> > On Sun, Mar 28, 2021 at 07:33:25PM +0300, Ivan Safonov wrote:
> > > on_action_spct() do nothing, because rtw_get_stainfo() has no side
> > > effects. Other action handlers are trivial.
> > > 
> > > Signed-off-by: Ivan Safonov <insafonov@gmail.com>
> > 
> > Same here, wrong driver name :(
> > 
> 
> Driver name is "r8188eu"...
> 
> $ grep 'r8188eu' drivers/staging/rtl8188eu/include/drv_types.h

Directory name is "rtl8188eu", so something needs to be fixed up here to
remove confusion like this :)

thanks,

greg k-h

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

end of thread, other threads:[~2021-04-04  9:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-28 16:33 [PATCH 1/2] staging:r8188eu: refactor OnAction(): use switch instead table lookup Ivan Safonov
2021-03-28 16:33 ` [PATCH 2/2] staging:r8188eu: remove dummy handlers from OnAction() Ivan Safonov
2021-04-02 13:04   ` Greg Kroah-Hartman
2021-04-03 21:30     ` Ivan Safonov
2021-04-04  9:56       ` Greg Kroah-Hartman
2021-04-02 13:04 ` [PATCH 1/2] staging:r8188eu: refactor OnAction(): use switch instead table lookup Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).