aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/libertas/cmd.c
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2007-12-07 19:59:54 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:06:16 -0500
commit448a51ae0684c146c9f9ba4e178ab2182512258f (patch)
tree865dc30fe6ec85b901b8f944d11aa852ffd7a605 /drivers/net/wireless/libertas/cmd.c
parentac47246e246c183ed68b3fdb307a83d00313a325 (diff)
libertas: switch lbs_cmd() to take a callback function pointer
All existing code which sends commands is set up to have some function called with the results, not to get data back. It's more versatile this way, and providing it with a callback function which involves memcpy() is hardly difficult. Signed-off-by: David Woodhouse <dwmw2@infradead.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/libertas/cmd.c')
-rw-r--r--drivers/net/wireless/libertas/cmd.c30
1 files changed, 4 insertions, 26 deletions
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c
index 092c295e3802..6838c9cd856e 100644
--- a/drivers/net/wireless/libertas/cmd.c
+++ b/drivers/net/wireless/libertas/cmd.c
@@ -1657,7 +1657,6 @@ static void cleanup_cmdnode(struct cmd_ctrl_node *ptempnode)
1657 wake_up_interruptible(&ptempnode->cmdwait_q); 1657 wake_up_interruptible(&ptempnode->cmdwait_q);
1658 ptempnode->wait_option = 0; 1658 ptempnode->wait_option = 0;
1659 ptempnode->pdata_buf = NULL; 1659 ptempnode->pdata_buf = NULL;
1660 ptempnode->pdata_size = NULL;
1661 ptempnode->callback = NULL; 1660 ptempnode->callback = NULL;
1662 1661
1663 if (ptempnode->bufvirtualaddr != NULL) 1662 if (ptempnode->bufvirtualaddr != NULL)
@@ -1686,7 +1685,6 @@ void lbs_set_cmd_ctrl_node(struct lbs_private *priv,
1686 1685
1687 ptempnode->wait_option = wait_option; 1686 ptempnode->wait_option = wait_option;
1688 ptempnode->pdata_buf = pdata_buf; 1687 ptempnode->pdata_buf = pdata_buf;
1689 ptempnode->pdata_size = NULL;
1690 ptempnode->callback = NULL; 1688 ptempnode->callback = NULL;
1691 1689
1692 lbs_deb_leave(LBS_DEB_HOST); 1690 lbs_deb_leave(LBS_DEB_HOST);
@@ -2013,25 +2011,8 @@ void lbs_ps_confirm_sleep(struct lbs_private *priv, u16 psmode)
2013 * the result code from the firmware 2011 * the result code from the firmware
2014 */ 2012 */
2015 2013
2016static int lbs_cmd_callback(uint16_t respcmd, struct cmd_ds_command *resp, struct lbs_private *priv) 2014int lbs_cmd(struct lbs_private *priv, uint16_t command, void *cmd, int cmd_size,
2017{ 2015 int (*callback)(uint16_t, struct cmd_ds_command *, struct lbs_private *))
2018 struct cmd_ds_gen *r = (struct cmd_ds_gen *)resp;
2019 struct lbs_adapter *adapter = priv->adapter;
2020 u16 sz = le16_to_cpu(resp->size) - S_DS_GEN;
2021
2022 if (sz > *adapter->cur_cmd->pdata_size) {
2023 lbs_pr_err("response 0x%04x doesn't fit into buffer (%d > %d)\n",
2024 respcmd, sz, *adapter->cur_cmd->pdata_size);
2025 sz = *adapter->cur_cmd->pdata_size;
2026 }
2027 memcpy(adapter->cur_cmd->pdata_buf, r->cmdresp, sz);
2028 *adapter->cur_cmd->pdata_size = sz;
2029
2030 return 0;
2031}
2032
2033int lbs_cmd(struct lbs_private *priv, u16 command, void *cmd, int cmd_size,
2034 void *rsp, int *rsp_size)
2035{ 2016{
2036 struct lbs_adapter *adapter = priv->adapter; 2017 struct lbs_adapter *adapter = priv->adapter;
2037 struct cmd_ctrl_node *cmdnode; 2018 struct cmd_ctrl_node *cmdnode;
@@ -2040,9 +2021,8 @@ int lbs_cmd(struct lbs_private *priv, u16 command, void *cmd, int cmd_size,
2040 int ret = 0; 2021 int ret = 0;
2041 2022
2042 lbs_deb_enter(LBS_DEB_HOST); 2023 lbs_deb_enter(LBS_DEB_HOST);
2043 lbs_deb_host("rsp at %p, rsp_size at %p\n", rsp, rsp_size);
2044 2024
2045 if (!adapter || !rsp_size) { 2025 if (!adapter) {
2046 lbs_deb_host("PREP_CMD: adapter is NULL\n"); 2026 lbs_deb_host("PREP_CMD: adapter is NULL\n");
2047 ret = -1; 2027 ret = -1;
2048 goto done; 2028 goto done;
@@ -2067,9 +2047,7 @@ int lbs_cmd(struct lbs_private *priv, u16 command, void *cmd, int cmd_size,
2067 2047
2068 cmdptr = (struct cmd_ds_gen *)cmdnode->bufvirtualaddr; 2048 cmdptr = (struct cmd_ds_gen *)cmdnode->bufvirtualaddr;
2069 cmdnode->wait_option = CMD_OPTION_WAITFORRSP; 2049 cmdnode->wait_option = CMD_OPTION_WAITFORRSP;
2070 cmdnode->pdata_buf = rsp; 2050 cmdnode->callback = callback;
2071 cmdnode->pdata_size = rsp_size;
2072 cmdnode->callback = lbs_cmd_callback;
2073 2051
2074 /* Set sequence number, clean result, move to buffer */ 2052 /* Set sequence number, clean result, move to buffer */
2075 adapter->seqnum++; 2053 adapter->seqnum++;