staging: rtl8723bs: cleanup rtw_enqueue_cmd flow
cover staging: rtl8723bs: cleanup rtw_enqueue_cmd flow
This series cleans up the command enqueue path in rtw_cmd.c.
Patch 1 simplifies the control flow of _rtw_enqueue_cmd() by removing the goto exit pattern and using direct returns.
Patch 2 limits the scope of _rtw_enqueue_cmd() by making it static and removing its declaration from the header.
Patch 3 simplifies the control flow of rtw_enqueue_cmd() by removing the goto exit pattern.
Patch 4 converts the private helper _rtw_enqueue_cmd() to return 0 on success, while keeping rtw_enqueue_cmd() translating the result to the existing legacy return convention.
No functional changes intended.
Hungyu Lin (4):
staging: rtl8723bs: simplify _rtw_enqueue_cmd control flow
staging: rtl8723bs: make _rtw_enqueue_cmd static
staging: rtl8723bs: simplify rtw_enqueue_cmd control flow
staging: rtl8723bs: make _rtw_enqueue_cmd return 0 on success
drivers/staging/rtl8723bs/core/rtw_cmd.c | 20 +++++++++---------- drivers/staging/rtl8723bs/include/cmd_osdep.h | 1 - 2 files changed, 10 insertions(+), 11 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/4 staging: rtl8723bs: simplify _rtw_enqueue_cmd control flow
Replace the goto exit pattern with a direct return to simplify the control flow and improve readability.
No functional change intended.
--- drivers/staging/rtl8723bs/core/rtw_cmd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/rtl8723bs/core/rtw_cmd.c +1 -2
@@ -252,7 +252,7 @@ int _rtw_enqueue_cmd(struct __queue *queue, struct cmd_obj *obj)unsigned long irqL;if (!obj) - goto exit; +return _SUCCESS;/* spin_lock_bh(&queue->lock); */ spin_lock_irqsave (&queue->lock, irqL);
@@ -262,7 +262,6 @@ int _rtw_enqueue_cmd(struct __queue *queue, struct cmd_obj *obj)/* spin_unlock_bh(&queue->lock); */ spin_unlock_irqrestore (&queue->lock, irqL); -exit:return _SUCCESS; }
Signature · 1 line
2.34.1
PATCH 2/4 staging: rtl8723bs: make _rtw_enqueue_cmd static
The function _rtw_enqueue_cmd() is only used within rtw_cmd.c, so make it static and remove the unnecessary declaration from the header file.
--- drivers/staging/rtl8723bs/core/rtw_cmd.c | 2 +- drivers/staging/rtl8723bs/include/cmd_osdep.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)
drivers/staging/rtl8723bs/core/rtw_cmd.c +1 -1
@@ -247,7 +247,7 @@ void _rtw_free_cmd_priv(struct cmd_priv *pcmdpriv)* */ -int _rtw_enqueue_cmd (struct __queue *queue,struct cmd_obj *obj) +static int _rtw_enqueue_cmd (struct __queue *queue,struct cmd_obj *obj) {unsigned long irqL;
drivers/staging/rtl8723bs/include/cmd_osdep.h +0 -1
@@ -11,7 +11,6 @@ int rtw_init_cmd_priv(struct cmd_priv *pcmdpriv);int rtw_init_evt_priv (struct evt_priv *pevtpriv);extern void _rtw_free_evt_priv (struct evt_priv *pevtpriv);extern void _rtw_free_cmd_priv (struct cmd_priv *pcmdpriv); -int _rtw_enqueue_cmd (struct __queue *queue,struct cmd_obj *obj);extern struct cmd_obj *_rtw_dequeue_cmd (struct __queue *queue);#endif
Signature · 1 line
2.34.1
PATCH 3/4 staging: rtl8723bs: simplify rtw_enqueue_cmd control flow
Replace the goto exit pattern with direct returns to simplify the control flow and improve readability.
No functional change intended.
--- drivers/staging/rtl8723bs/core/rtw_cmd.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/staging/rtl8723bs/core/rtw_cmd.c +3 -4
@@ -312,18 +312,18 @@ int rtw_cmd_filter(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj)int rtw_enqueue_cmd (struct cmd_priv *pcmdpriv,struct cmd_obj *cmd_obj) { -int res = _FAIL; +int res;struct adapter *padapter = pcmdpriv->padapter;if (!cmd_obj) - goto exit; +return _FAIL; cmd_obj->padapter = padapter; res =rtw_cmd_filter (pcmdpriv, cmd_obj);if (res == _FAIL) {rtw_free_cmd_obj (cmd_obj); - goto exit; +return _FAIL; } res =_rtw_enqueue_cmd (&pcmdpriv->cmd_queue, cmd_obj);
@@ -331,7 +331,6 @@ int rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj)if (res == _SUCCESS)complete (&pcmdpriv->cmd_queue_comp); -exit:return res; }
Signature · 1 line
2.34.1
PATCH 4/4 staging: rtl8723bs: make _rtw_enqueue_cmd return 0 on success
Convert the private helper _rtw_enqueue_cmd() to return 0 on success instead of the legacy _SUCCESS value.
Keep rtw_enqueue_cmd() translating the result back to the existing return convention for now.
No functional change intended.
--- drivers/staging/rtl8723bs/core/rtw_cmd.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/staging/rtl8723bs/core/rtw_cmd.c +6 -4
@@ -252,7 +252,7 @@ static int _rtw_enqueue_cmd(struct __queue *queue, struct cmd_obj *obj)unsigned long irqL;if (!obj) -return _SUCCESS; +return 0 ;/* spin_lock_bh(&queue->lock); */ spin_lock_irqsave (&queue->lock, irqL);
@@ -262,7 +262,7 @@ static int _rtw_enqueue_cmd(struct __queue *queue, struct cmd_obj *obj)/* spin_unlock_bh(&queue->lock); */ spin_unlock_irqrestore (&queue->lock, irqL); -return _SUCCESS; +return 0 ; }struct cmd_obj *_rtw_dequeue_cmd (struct __queue *queue)
@@ -328,10 +328,12 @@ int rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) res =_rtw_enqueue_cmd (&pcmdpriv->cmd_queue, cmd_obj); -if (res == _SUCCESS) +if (res ==0 ) {complete (&pcmdpriv->cmd_queue_comp); +return _SUCCESS; + } -return res; +return _FAIL; }struct cmd_obj *rtw_dequeue_cmd (struct cmd_priv *pcmdpriv)
Signature · 1 line
2.34.1