Commit 183aeac1 authored by David Woodhouse's avatar David Woodhouse Committed by David S. Miller

libertas: introduce and use lbs_complete_command() for command completion

Signed-off-by: default avatarDavid Woodhouse <dwmw2@infradead.org>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent c4ab4127
...@@ -1230,9 +1230,7 @@ static int lbs_submit_command(struct lbs_private *priv, ...@@ -1230,9 +1230,7 @@ static int lbs_submit_command(struct lbs_private *priv,
if (ret) { if (ret) {
lbs_pr_info("DNLD_CMD: hw_host_to_card failed: %d\n", ret); lbs_pr_info("DNLD_CMD: hw_host_to_card failed: %d\n", ret);
spin_lock_irqsave(&priv->driver_lock, flags); spin_lock_irqsave(&priv->driver_lock, flags);
priv->cur_cmd_retcode = ret; lbs_complete_command(priv, priv->cur_cmd, ret);
__lbs_cleanup_and_insert_cmd(priv, priv->cur_cmd);
priv->cur_cmd = NULL;
spin_unlock_irqrestore(&priv->driver_lock, flags); spin_unlock_irqrestore(&priv->driver_lock, flags);
goto done; goto done;
} }
...@@ -1275,8 +1273,8 @@ static int lbs_cmd_mac_control(struct lbs_private *priv, ...@@ -1275,8 +1273,8 @@ static int lbs_cmd_mac_control(struct lbs_private *priv,
* This function inserts command node to cmdfreeq * This function inserts command node to cmdfreeq
* after cleans it. Requires priv->driver_lock held. * after cleans it. Requires priv->driver_lock held.
*/ */
void __lbs_cleanup_and_insert_cmd(struct lbs_private *priv, static void __lbs_cleanup_and_insert_cmd(struct lbs_private *priv,
struct cmd_ctrl_node *ptempcmd) struct cmd_ctrl_node *ptempcmd)
{ {
if (!ptempcmd) if (!ptempcmd)
...@@ -1296,6 +1294,15 @@ static void lbs_cleanup_and_insert_cmd(struct lbs_private *priv, ...@@ -1296,6 +1294,15 @@ static void lbs_cleanup_and_insert_cmd(struct lbs_private *priv,
spin_unlock_irqrestore(&priv->driver_lock, flags); spin_unlock_irqrestore(&priv->driver_lock, flags);
} }
void lbs_complete_command(struct lbs_private *priv, struct cmd_ctrl_node *cmd,
int result)
{
if (cmd == priv->cur_cmd)
priv->cur_cmd_retcode = result;
__lbs_cleanup_and_insert_cmd(priv, cmd);
priv->cur_cmd = NULL;
}
int lbs_set_radio_control(struct lbs_private *priv) int lbs_set_radio_control(struct lbs_private *priv)
{ {
int ret = 0; int ret = 0;
...@@ -1901,7 +1908,9 @@ int lbs_execute_next_command(struct lbs_private *priv) ...@@ -1901,7 +1908,9 @@ int lbs_execute_next_command(struct lbs_private *priv)
lbs_deb_host( lbs_deb_host(
"EXEC_NEXT_CMD: ignore ENTER_PS cmd\n"); "EXEC_NEXT_CMD: ignore ENTER_PS cmd\n");
list_del(&cmdnode->list); list_del(&cmdnode->list);
lbs_cleanup_and_insert_cmd(priv, cmdnode); spin_lock_irqsave(&priv->driver_lock, flags);
lbs_complete_command(priv, cmdnode, 0);
spin_unlock_irqrestore(&priv->driver_lock, flags);
ret = 0; ret = 0;
goto done; goto done;
...@@ -1912,7 +1921,9 @@ int lbs_execute_next_command(struct lbs_private *priv) ...@@ -1912,7 +1921,9 @@ int lbs_execute_next_command(struct lbs_private *priv)
lbs_deb_host( lbs_deb_host(
"EXEC_NEXT_CMD: ignore EXIT_PS cmd in sleep\n"); "EXEC_NEXT_CMD: ignore EXIT_PS cmd in sleep\n");
list_del(&cmdnode->list); list_del(&cmdnode->list);
lbs_cleanup_and_insert_cmd(priv, cmdnode); spin_lock_irqsave(&priv->driver_lock, flags);
lbs_complete_command(priv, cmdnode, 0);
spin_unlock_irqrestore(&priv->driver_lock, flags);
priv->needtowakeup = 1; priv->needtowakeup = 1;
ret = 0; ret = 0;
......
...@@ -717,8 +717,7 @@ int lbs_process_rx_command(struct lbs_private *priv) ...@@ -717,8 +717,7 @@ int lbs_process_rx_command(struct lbs_private *priv)
lbs_deb_host("CMD_RESP: PS action 0x%X\n", action); lbs_deb_host("CMD_RESP: PS action 0x%X\n", action);
} }
__lbs_cleanup_and_insert_cmd(priv, priv->cur_cmd); lbs_complete_command(priv, priv->cur_cmd, result);
priv->cur_cmd = NULL;
spin_unlock_irqrestore(&priv->driver_lock, flags); spin_unlock_irqrestore(&priv->driver_lock, flags);
ret = 0; ret = 0;
...@@ -739,9 +738,7 @@ int lbs_process_rx_command(struct lbs_private *priv) ...@@ -739,9 +738,7 @@ int lbs_process_rx_command(struct lbs_private *priv)
break; break;
} }
lbs_complete_command(priv, priv->cur_cmd, result);
__lbs_cleanup_and_insert_cmd(priv, priv->cur_cmd);
priv->cur_cmd = NULL;
spin_unlock_irqrestore(&priv->driver_lock, flags); spin_unlock_irqrestore(&priv->driver_lock, flags);
ret = -1; ret = -1;
...@@ -760,8 +757,7 @@ int lbs_process_rx_command(struct lbs_private *priv) ...@@ -760,8 +757,7 @@ int lbs_process_rx_command(struct lbs_private *priv)
if (priv->cur_cmd) { if (priv->cur_cmd) {
/* Clean up and Put current command back to cmdfreeq */ /* Clean up and Put current command back to cmdfreeq */
__lbs_cleanup_and_insert_cmd(priv, priv->cur_cmd); lbs_complete_command(priv, priv->cur_cmd, result);
priv->cur_cmd = NULL;
} }
spin_unlock_irqrestore(&priv->driver_lock, flags); spin_unlock_irqrestore(&priv->driver_lock, flags);
......
...@@ -45,9 +45,8 @@ void lbs_get_fwversion(struct lbs_private *priv, ...@@ -45,9 +45,8 @@ void lbs_get_fwversion(struct lbs_private *priv,
/** The proc fs interface */ /** The proc fs interface */
int lbs_process_rx_command(struct lbs_private *priv); int lbs_process_rx_command(struct lbs_private *priv);
void __lbs_cleanup_and_insert_cmd(struct lbs_private *priv, void lbs_complete_command(struct lbs_private *priv, struct cmd_ctrl_node *cmd,
struct cmd_ctrl_node *ptempcmd); int result);
int lbs_hard_start_xmit(struct sk_buff *skb, struct net_device *dev); int lbs_hard_start_xmit(struct sk_buff *skb, struct net_device *dev);
int lbs_set_regiontable(struct lbs_private *priv, u8 region, u8 band); int lbs_set_regiontable(struct lbs_private *priv, u8 region, u8 band);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment