Skip to content

Commit da8b094

Browse files
martin-kaisergregkh
authored andcommitted
staging: r8188eu: merge _rtw_enqueue_cmd into its caller
The _rtw_enqueue_cmd function is called only by rtw_enqueue_cmd. When _rtw_enqueue_cmd is called, the caller has already checked that the obj parameter is not NULL. _rtw_enqueue_cmd returns _SUCCESS in any case. We can merge the two functions and simplify the error handling. Signed-off-by: Martin Kaiser <[email protected]> Tested-by: Philipp Hortmann <[email protected]> # Edimax N150 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent eec8cca commit da8b094

File tree

1 file changed

+9
-38
lines changed

1 file changed

+9
-38
lines changed

drivers/staging/r8188eu/core/rtw_cmd.c

Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -28,32 +28,6 @@ void rtw_free_evt_priv(struct evt_priv *pevtpriv)
2828
}
2929
}
3030

31-
/* Calling Context:
32-
*
33-
* rtw_enqueue_cmd can only be called between kernel thread,
34-
* since only spin_lock is used.
35-
*
36-
* ISR/Call-Back functions can't call this sub-function.
37-
*/
38-
39-
static int _rtw_enqueue_cmd(struct __queue *queue, struct cmd_obj *obj)
40-
{
41-
unsigned long flags;
42-
43-
if (!obj)
44-
goto exit;
45-
46-
spin_lock_irqsave(&queue->lock, flags);
47-
48-
list_add_tail(&obj->list, &queue->queue);
49-
50-
spin_unlock_irqrestore(&queue->lock, flags);
51-
52-
exit:
53-
54-
return _SUCCESS;
55-
}
56-
5731
int rtw_init_cmd_priv(struct cmd_priv *pcmdpriv)
5832
{
5933
init_completion(&pcmdpriv->enqueue_cmd);
@@ -125,28 +99,25 @@ static int rtw_cmd_filter(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj)
12599

126100
u32 rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj)
127101
{
128-
int res = _FAIL;
102+
unsigned long flags;
129103
struct adapter *padapter = pcmdpriv->padapter;
130104

131105
if (!cmd_obj)
132-
goto exit;
106+
return _FAIL;
133107

134108
cmd_obj->padapter = padapter;
135109

136-
res = rtw_cmd_filter(pcmdpriv, cmd_obj);
137-
if (res == _FAIL) {
110+
if (rtw_cmd_filter(pcmdpriv, cmd_obj) == _FAIL) {
138111
rtw_free_cmd_obj(cmd_obj);
139-
goto exit;
112+
return _FAIL;
140113
}
141114

142-
res = _rtw_enqueue_cmd(&pcmdpriv->cmd_queue, cmd_obj);
143-
144-
if (res == _SUCCESS)
145-
complete(&pcmdpriv->enqueue_cmd);
115+
spin_lock_irqsave(&pcmdpriv->cmd_queue.lock, flags);
116+
list_add_tail(&cmd_obj->list, &pcmdpriv->cmd_queue.queue);
117+
spin_unlock_irqrestore(&pcmdpriv->cmd_queue.lock, flags);
146118

147-
exit:
148-
149-
return res;
119+
complete(&pcmdpriv->enqueue_cmd);
120+
return _SUCCESS;
150121
}
151122

152123
struct cmd_obj *rtw_dequeue_cmd(struct cmd_priv *pcmdpriv)

0 commit comments

Comments
 (0)