staging: rtl8188eu: remove the last urb callback macros
Subsystems (2)
PATCH 1/12 staging: rtl8188eu: remove the last urb callback macros
Both usb_read_port_complete and usb_write_port_complete have a regs parameter that is not used.
When this parameter is removed, the functions can be used as urb completion callbacks directly. There's no need for the macros that strip the second parameter.
--- drivers/staging/rtl8188eu/include/usb_ops_linux.h | 5 ----- drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c | 4 ++-- 2 files changed, 2 insertions(+), 7 deletions(-)
drivers/staging/rtl8188eu/include/usb_ops_linux.h +0 -5
@@ -10,11 +10,6 @@#define USB_HIGH_SPEED_BULK_SIZE 512#define USB_FULL_SPEED_BULK_SIZE 64 -#define usb_write_port_complete (purb, regs) \ - usb_write_port_complete(purb) -#define usb_read_port_complete (purb, regs) \ - usb_read_port_complete(purb) -unsigned int ffaddr2pipehdl (struct dvobj_priv *pdvobj,u32 addr);u8 usb_read8 (struct adapter *adapter,u32 addr);
drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c +2 -2
@@ -334,7 +334,7 @@ u32 usb_read32(struct adapter *adapter, u32 addr)return le32_to_cpu (data); } -static void usb_read_port_complete (struct urb *purb,struct pt_regs *regs) +static void usb_read_port_complete (struct urb *purb) {struct recv_buf *precvbuf = (struct recv_buf *)purb->context;struct adapter *adapt = (struct adapter *)precvbuf->adapter;
@@ -519,7 +519,7 @@ int usb_write32(struct adapter *adapter, u32 addr, u32 val)return usbctrl_vendorreq (adapter, wvalue, &data,4 ,REALTEK_USB_VENQT_WRITE ); } -static void usb_write_port_complete (struct urb *purb,struct pt_regs *regs) +static void usb_write_port_complete (struct urb *purb) {struct xmit_buf *pxmitbuf = (struct xmit_buf *)purb->context;struct adapter *padapter = pxmitbuf->padapter;
Signature · 1 line
2.20.1
PATCH 2/12 staging: rtl8188eu: remove prototype for non-existing function
There's no usb_read_port_cancel function in this driver. Remove its prototype.
--- drivers/staging/rtl8188eu/include/usb_ops_linux.h | 1 - 1 file changed, 1 deletion(-)
drivers/staging/rtl8188eu/include/usb_ops_linux.h +0 -1
@@ -17,7 +17,6 @@ u16 usb_read16(struct adapter *adapter, u32 addr);u32 usb_read32 (struct adapter *adapter,u32 addr);u32 usb_read_port (struct adapter *adapter,u32 addr,struct recv_buf *precvbuf); -void usb_read_port_cancel (struct adapter *adapter);int usb_write8 (struct adapter *adapter,u32 addr,u8 val);int usb_write16 (struct adapter *adapter,u32 addr,u16 val);
Signature · 1 line
2.20.1
PATCH 3/12 staging: rtl8188eu: make ffaddr2pipehdl static
In reply to Martin KaiserThis function is used only inside usb_ops_linux.c.
--- drivers/staging/rtl8188eu/include/usb_ops_linux.h | 2 -- drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/staging/rtl8188eu/include/usb_ops_linux.h +0 -2
@@ -10,8 +10,6 @@#define USB_HIGH_SPEED_BULK_SIZE 512#define USB_FULL_SPEED_BULK_SIZE 64 -unsigned int ffaddr2pipehdl (struct dvobj_priv *pdvobj,u32 addr); -u8 usb_read8 (struct adapter *adapter,u32 addr);u16 usb_read16 (struct adapter *adapter,u32 addr);u32 usb_read32 (struct adapter *adapter,u32 addr);
drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c +1 -1
@@ -195,7 +195,7 @@ static int recvbuf2recvframe(struct adapter *adapt, struct sk_buff *pskb)return _SUCCESS; } -unsigned int ffaddr2pipehdl (struct dvobj_priv *pdvobj,u32 addr) +static unsigned int ffaddr2pipehdl (struct dvobj_priv *pdvobj,u32 addr) {unsigned int pipe =0 , ep_num =0 ;struct usb_device *pusbd = pdvobj->pusbdev;
Signature · 1 line
2.20.1
PATCH 4/12 staging: rtl8188eu: replace switch-case with if
In reply to Martin KaiserThis switch has only one case. Replace it with an if statement.
--- drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c +2 -6
@@ -675,13 +675,9 @@ u32 usb_write_port(struct adapter *padapter, u32 addr, u32 cnt, struct xmit_buf ("%s(): usb_submit_urb, status =%x\n" , __func__, status)); -switch (status) { -case -ENODEV : +if (status == -ENODEV ) padapter->bDriverStopped = true; -break ; -default : -break ; - } + goto exit; }
Signature · 1 line
2.20.1
PATCH 5/12 staging: rtl8188eu: remove unused function parameter
In reply to Martin KaiserThe struct adapter parameter of rtw_os_recvbuf_resource_alloc is not used. Remove it.
While at it, use the same parameter name in the prototype and the function definition.
--- drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c | 2 +- drivers/staging/rtl8188eu/include/recv_osdep.h | 2 +- drivers/staging/rtl8188eu/os_dep/recv_linux.c | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-)
drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c +1 -1
@@ -38,7 +38,7 @@ int rtw_hal_init_recv_priv(struct adapter *padapter) precvbuf = precvpriv->precv_buf;for (i =0 ; i <NR_RECVBUFF ; i++) { - res =rtw_os_recvbuf_resource_alloc (padapter, precvbuf); + res =rtw_os_recvbuf_resource_alloc (precvbuf);if (res == _FAIL)break ; precvbuf->adapter = padapter;
drivers/staging/rtl8188eu/include/recv_osdep.h +1 -1
@@ -19,7 +19,7 @@ int rtw_recv_indicatepkt(struct adapter *adapter,void rtw_handle_tkip_mic_err (struct adapter *padapter,u8 bgroup); -int rtw_os_recvbuf_resource_alloc (struct adapter *adapt,struct recv_buf *buf); +int rtw_os_recvbuf_resource_alloc (struct recv_buf *precvbuf);void rtw_init_recv_timer (struct recv_reorder_ctrl *preorder_ctrl);
drivers/staging/rtl8188eu/os_dep/recv_linux.c +1 -2
@@ -14,8 +14,7 @@#include <usb_ops_linux.h> /* alloc os related resource in struct recv_buf */ -int rtw_os_recvbuf_resource_alloc (struct adapter *padapter, -struct recv_buf *precvbuf) +int rtw_os_recvbuf_resource_alloc (struct recv_buf *precvbuf) { precvbuf->pskb =NULL ; precvbuf->reuse = false;
Signature · 1 line
2.20.1
PATCH 6/12 staging: rtl8188eu: remove a constant variable
In reply to Martin Kaiserenqueue is always 0.
--- drivers/staging/rtl8188eu/core/rtw_pwrctrl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/rtl8188eu/core/rtw_pwrctrl.c +1 -2
@@ -480,10 +480,9 @@ void LPS_Leave(struct adapter *padapter)void LeaveAllPowerSaveMode (struct adapter *Adapter) {struct mlme_priv *pmlmepriv = &Adapter->mlmepriv; -u8 enqueue =0 ;if (check_fwstate (pmlmepriv, _FW_LINKED)) -rtw_lps_ctrl_wk_cmd (Adapter,LPS_CTRL_LEAVE , enqueue); +rtw_lps_ctrl_wk_cmd (Adapter,LPS_CTRL_LEAVE ,0 ); }void rtw_init_pwrctrl_priv (struct adapter *padapter)
Signature · 1 line
2.20.1
PATCH 7/12 staging: rtl8188eu: move static array from .h to .c
In reply to Martin KaiserDeclaring a static array in a header file is likely to cause name conflicts if the declaration is pulled in multiple times.
The rtl8188 driver protects the declaration of the wlancmds array in rtw_mlme_ext.h with ifdef _RTW_CMD_C_, which is defined only in rtw_cmd.c. It makes more sense to declare the array in the .c file.
--- drivers/staging/rtl8188eu/core/rtw_cmd.c | 18 +++++++++++++++ .../staging/rtl8188eu/include/rtw_mlme_ext.h | 22 ------------------- 2 files changed, 18 insertions(+), 22 deletions(-)
drivers/staging/rtl8188eu/core/rtw_cmd.c +18 -0
@@ -12,6 +12,24 @@#include <mlme_osdep.h> #include <rtw_mlme_ext.h> +static struct cmd_hdl wlancmds[] = { + {sizeof (struct wlan_bssid_ex ), join_cmd_hdl}, + {sizeof (struct disconnect_parm ), disconnect_hdl}, + {sizeof (struct wlan_bssid_ex ), createbss_hdl}, + {sizeof (struct setopmode_parm ), setopmode_hdl}, + {sizeof (struct sitesurvey_parm ), sitesurvey_cmd_hdl}, + {sizeof (struct setauth_parm ), setauth_hdl}, + {sizeof (struct setkey_parm ), setkey_hdl}, + {sizeof (struct set_stakey_parm ), set_stakey_hdl}, + {sizeof (struct set_assocsta_parm ),NULL }, + {sizeof (struct addBaReq_parm ), add_ba_hdl}, + {sizeof (struct set_ch_parm ), set_ch_hdl}, + {sizeof (struct wlan_bssid_ex ), tx_beacon_hdl}, + {0 , mlme_evt_hdl}, + {0 , rtw_drvextra_cmd_hdl}, + {sizeof (struct SetChannelPlan_param ), set_chplan_hdl} +}; +/* * Caller and the rtw_cmd_thread can protect cmd_q by spin_lock. * No irqsave is necessary.
drivers/staging/rtl8188eu/include/rtw_mlme_ext.h +0 -22
@@ -606,28 +606,6 @@ u8 led_blink_hdl(struct adapter *padapter, unsigned char *pbuf);u8 set_csa_hdl (struct adapter *padapter,unsigned char *pbuf);u8 tdls_hdl (struct adapter *padapter,unsigned char *pbuf); -#ifdef _RTW_CMD_C_ - -static struct cmd_hdl wlancmds[] = { - {sizeof (struct wlan_bssid_ex ), join_cmd_hdl}, - {sizeof (struct disconnect_parm ), disconnect_hdl}, - {sizeof (struct wlan_bssid_ex ), createbss_hdl}, - {sizeof (struct setopmode_parm ), setopmode_hdl}, - {sizeof (struct sitesurvey_parm ), sitesurvey_cmd_hdl}, - {sizeof (struct setauth_parm ), setauth_hdl}, - {sizeof (struct setkey_parm ), setkey_hdl}, - {sizeof (struct set_stakey_parm ), set_stakey_hdl}, - {sizeof (struct set_assocsta_parm ),NULL }, - {sizeof (struct addBaReq_parm ), add_ba_hdl}, - {sizeof (struct set_ch_parm ), set_ch_hdl}, - {sizeof (struct wlan_bssid_ex ), tx_beacon_hdl}, - {0 , mlme_evt_hdl}, - {0 , rtw_drvextra_cmd_hdl}, - {sizeof (struct SetChannelPlan_param ), set_chplan_hdl} -}; - -#endif -struct C2HEvent_Header {#ifdef __LITTLE_ENDIANunsigned int len:16 ;
Signature · 1 line
2.20.1
PATCH 8/12 staging: rtl8188eu: move another static array from .h to .c
In reply to Martin KaiserMove the declaration of the rtw_cmd_callback array from rtw_cmd.h to rtw_cmd.c.
The _RTW_CMD_C_ symbol is now obsolete and can be removed.
--- drivers/staging/rtl8188eu/core/rtw_cmd.c | 19 ++++++++++++++++++- drivers/staging/rtl8188eu/include/rtw_cmd.h | 20 -------------------- 2 files changed, 18 insertions(+), 21 deletions(-)
drivers/staging/rtl8188eu/core/rtw_cmd.c +18 -1
@@ -4,7 +4,6 @@* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * ******************************************************************************/ -#define _RTW_CMD_C_#include <osdep_service.h> #include <drv_types.h>
@@ -30,6 +29,24 @@ static struct cmd_hdl wlancmds[] = { {sizeof(struct SetChannelPlan_param), set_chplan_hdl} }; +static struct _cmd_callback rtw_cmd_callback[] = { + {_JoinBss_CMD_, &rtw_joinbss_cmd_callback}, + {_DisConnect_CMD_, &rtw_disassoc_cmd_callback}, + {_CreateBss_CMD_, &rtw_createbss_cmd_callback}, + {_SetOpMode_CMD_,NULL }, + {_SiteSurvey_CMD_, &rtw_survey_cmd_callback}, + {_SetAuth_CMD_,NULL }, + {_SetKey_CMD_,NULL }, + {_SetStaKey_CMD_, &rtw_setstaKey_cmdrsp_callback}, + {_SetAssocSta_CMD_, &rtw_setassocsta_cmdrsp_callback}, + {_AddBAReq_CMD_,NULL }, + {_SetChannel_CMD_,NULL }, + {_TX_Beacon_CMD_,NULL }, + {_Set_MLME_EVT_CMD_,NULL }, + {_Set_Drv_Extra_CMD_,NULL }, + {_SetChannelPlan_CMD_,NULL }, +}; +/* * Caller and the rtw_cmd_thread can protect cmd_q by spin_lock. * No irqsave is necessary.
drivers/staging/rtl8188eu/include/rtw_cmd.h +0 -20
@@ -361,24 +361,4 @@ enum rtw_h2c_cmd {MAX_H2CCMD }; -#ifdef _RTW_CMD_C_ -static struct _cmd_callback rtw_cmd_callback[] = { - {_JoinBss_CMD_, &rtw_joinbss_cmd_callback}, - {_DisConnect_CMD_, &rtw_disassoc_cmd_callback}, - {_CreateBss_CMD_, &rtw_createbss_cmd_callback}, - {_SetOpMode_CMD_,NULL }, - {_SiteSurvey_CMD_, &rtw_survey_cmd_callback}, - {_SetAuth_CMD_,NULL }, - {_SetKey_CMD_,NULL }, - {_SetStaKey_CMD_, &rtw_setstaKey_cmdrsp_callback}, - {_SetAssocSta_CMD_, &rtw_setassocsta_cmdrsp_callback}, - {_AddBAReq_CMD_,NULL }, - {_SetChannel_CMD_,NULL }, - {_TX_Beacon_CMD_,NULL }, - {_Set_MLME_EVT_CMD_,NULL }, - {_Set_Drv_Extra_CMD_,NULL }, - {_SetChannelPlan_CMD_,NULL }, -}; -#endif -#endif /* _CMD_H_ */
Signature · 1 line
2.20.1
PATCH 9/12 staging: rtl8188eu: always free cmd_obj in the cmd thread
In reply to Martin KaiserThe rtl8188 driver starts a command thread that reads commands from a queue and processes them. Each command consists of a struct cmd_obj. The command thread may call a function to process the current command and optionally a post-processing function. Eventually, the command's cmd_obj must be freed.
At the moment, if there's a post-processing function for the current command, this function has to free the cmd_obj. If there's no post-processing function, the command thread frees cmd_obj.
It's much simpler if we always leave it to the command thread to free cmd_obj.
--- drivers/staging/rtl8188eu/core/rtw_cmd.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-)
drivers/staging/rtl8188eu/core/rtw_cmd.c +3 -21
@@ -235,17 +235,16 @@ int rtw_cmd_thread(void *context)RT_TRACE (_module_rtl871x_cmd_c_, _drv_info_, ("mlme_cmd_hdl(): pcmd_callback = 0x%p, cmdcode = 0x%x\n" , pcmd_callback, pcmd->cmdcode)); -rtw_free_cmd_obj (pcmd); }else {/* todo: !!! fill rsp_buf to pcmd->rsp if (pcmd->rsp!= NULL) */ -pcmd_callback (pcmd->padapter, pcmd);/* need consider that free cmd_obj in rtw_cmd_callback */ +pcmd_callback (pcmd->padapter, pcmd); } }else {RT_TRACE (_module_rtl871x_cmd_c_, _drv_err_, ("%s: cmdcode = 0x%x callback not defined!\n" , __func__, pcmd->cmdcode)); -rtw_free_cmd_obj (pcmd); } +rtw_free_cmd_obj (pcmd);if (signal_pending (current))flush_signals (current);
@@ -1186,9 +1185,6 @@ void rtw_survey_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd)RT_TRACE (_module_rtl871x_cmd_c_, _drv_err_, ("\n ********Error: MgntActrtw_set_802_11_bssid_LIST_SCAN Fail ************\n\n." )); } - -/* free cmd */ -rtw_free_cmd_obj (pcmd); }void rtw_disassoc_cmd_callback (struct adapter *padapter,struct cmd_obj *pcmd)
@@ -1202,11 +1198,7 @@ void rtw_disassoc_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd)RT_TRACE (_module_rtl871x_cmd_c_, _drv_err_, ("\n ***Error: disconnect_cmd_callback Fail ***\n." )); -return ; } - -/* free cmd */ -rtw_free_cmd_obj (pcmd); }void rtw_joinbss_cmd_callback (struct adapter *padapter,struct cmd_obj *pcmd)
@@ -1224,8 +1216,6 @@ void rtw_joinbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd)mod_timer (&pmlmepriv->assoc_timer, jiffies +msecs_to_jiffies (1 )); } - -rtw_free_cmd_obj (pcmd); }void rtw_createbss_cmd_callback (struct adapter *padapter,struct cmd_obj *pcmd)
@@ -1292,8 +1282,6 @@ void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) createbss_cmd_fail:spin_unlock_bh (&pmlmepriv->lock); - -rtw_free_cmd_obj (pcmd); }void rtw_setstaKey_cmdrsp_callback (struct adapter *padapter,struct cmd_obj *pcmd)
@@ -1305,10 +1293,7 @@ void rtw_setstaKey_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcif (!psta) {RT_TRACE (_module_rtl871x_cmd_c_, _drv_err_, ("\nERROR: %s => can't get sta_info\n\n" , __func__)); - goto exit; } -exit: -rtw_free_cmd_obj (pcmd); }void rtw_setassocsta_cmdrsp_callback (struct adapter *padapter,struct cmd_obj *pcmd)
@@ -1322,7 +1307,7 @@ void rtw_setassocsta_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *if (!psta) {RT_TRACE (_module_rtl871x_cmd_c_, _drv_err_, ("\nERROR: %s => can't get sta_info\n\n" , __func__)); - goto exit; +return ; } psta->aid = passocsta_rsp->cam_id;
@@ -1332,7 +1317,4 @@ void rtw_setassocsta_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *set_fwstate (pmlmepriv, _FW_LINKED);spin_unlock_bh (&pmlmepriv->lock); - -exit: -rtw_free_cmd_obj (pcmd); }
Signature · 1 line
2.20.1
PATCH 10/12 staging: rtl8188eu: remove duplicate if statement
In reply to Martin KaiserThere's two identical checks if the device was stopped or unplugged. Remove one of them.
--- drivers/staging/rtl8188eu/core/rtw_cmd.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/staging/rtl8188eu/core/rtw_cmd.c +0 -7
@@ -191,13 +191,6 @@ int rtw_cmd_thread(void *context)if (wait_for_completion_interruptible (&pcmdpriv->cmd_queue_comp))break ; -if (padapter->bDriverStopped || - padapter->bSurpriseRemoved) { -DBG_88E ("%s: DriverStopped(%d) SurpriseRemoved(%d) break at line %d\n" , - __func__, padapter->bDriverStopped, - padapter->bSurpriseRemoved, __LINE__); -break ; - } _next:if (padapter->bDriverStopped || padapter->bSurpriseRemoved) {
Signature · 1 line
2.20.1
PATCH 11/12 staging: rtl8188eu: remove a dead assignment
In reply to Martin KaiserThere's no need to set cmd_hdl to NULL after it's used. It will be set again before the next command is processed.
--- drivers/staging/rtl8188eu/core/rtw_cmd.c | 2 -- 1 file changed, 2 deletions(-)
drivers/staging/rtl8188eu/core/rtw_cmd.c +0 -2
@@ -217,8 +217,6 @@ int rtw_cmd_thread(void *context) }else { pcmd->res =H2C_PARAMETERS_ERROR ; } - - cmd_hdl =NULL ; }/* call callback function for post-processed */
Signature · 1 line
2.20.1
PATCH 12/12 staging: rtl8188eu: simplify rtw_cmd_thread's main loop
In reply to Martin KaiserIn rtw_cmd_thread's main loop, we wait until there's a command in the queue. To skip this wait statement in subsequent iterations, the driver uses a label and goto instead of the actual loop. We only get back to the initial wait if the queue is empty when we read it.
Basically, all we want to do is check if there's a command in the queue. If yes, we process it. If not, we wait until someone enqueues a command.
--- drivers/staging/rtl8188eu/core/rtw_cmd.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/staging/rtl8188eu/core/rtw_cmd.c +6 -7
@@ -188,10 +188,6 @@ int rtw_cmd_thread(void *context) ("start r871x %s !!!!\n", __func__));while (1 ) { -if (wait_for_completion_interruptible (&pcmdpriv->cmd_queue_comp)) -break ; - -_next:if (padapter->bDriverStopped || padapter->bSurpriseRemoved) { DBG_88E("%s: DriverStopped(%d) SurpriseRemoved(%d) break at line %d\n",
@@ -201,8 +197,13 @@ int rtw_cmd_thread(void *context) } pcmd =rtw_dequeue_cmd (&pcmdpriv->cmd_queue); -if (!pcmd) +if (!pcmd) { +/* The queue is empty. Wait until someone enqueues a command. */ +if (wait_for_completion_interruptible (&pcmdpriv->cmd_queue_comp)) +break ; +continue ; + }if (rtw_cmd_filter (pcmdpriv, pcmd) == _FAIL) { pcmd->res =H2C_DROPPED ;
@@ -239,8 +240,6 @@ int rtw_cmd_thread(void *context)if (signal_pending (current))flush_signals (current); - - goto _next; } pcmdpriv->cmdthd_running = false;
Signature · 1 line
2.20.1