diff options
author | David Woodhouse <dwmw2@infradead.org> | 2007-12-07 10:13:05 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 18:06:12 -0500 |
commit | 1723047d6742cc172d5c0f1a5245deaee67ff331 (patch) | |
tree | 5285bceb2683c7c69249bf77b0a70fe1bb9d3729 /drivers/net/wireless/libertas | |
parent | 0856e6816b30a84aa74c70ecb2bde0c41402f647 (diff) |
libertas: Switch to using a callback function pointer for commands
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/libertas')
-rw-r--r-- | drivers/net/wireless/libertas/cmd.c | 31 | ||||
-rw-r--r-- | drivers/net/wireless/libertas/cmdresp.c | 23 | ||||
-rw-r--r-- | drivers/net/wireless/libertas/hostcmd.h | 1 |
3 files changed, 34 insertions, 21 deletions
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c index b1ea878863a8..ebfcb7bac681 100644 --- a/drivers/net/wireless/libertas/cmd.c +++ b/drivers/net/wireless/libertas/cmd.c | |||
@@ -1659,7 +1659,8 @@ static void cleanup_cmdnode(struct cmd_ctrl_node *ptempnode) | |||
1659 | wake_up_interruptible(&ptempnode->cmdwait_q); | 1659 | wake_up_interruptible(&ptempnode->cmdwait_q); |
1660 | ptempnode->wait_option = 0; | 1660 | ptempnode->wait_option = 0; |
1661 | ptempnode->pdata_buf = NULL; | 1661 | ptempnode->pdata_buf = NULL; |
1662 | ptempnode->pdata_size = 0; | 1662 | ptempnode->pdata_size = NULL; |
1663 | ptempnode->callback = NULL; | ||
1663 | 1664 | ||
1664 | if (ptempnode->bufvirtualaddr != NULL) | 1665 | if (ptempnode->bufvirtualaddr != NULL) |
1665 | memset(ptempnode->bufvirtualaddr, 0, MRVDRV_SIZE_OF_CMD_BUFFER); | 1666 | memset(ptempnode->bufvirtualaddr, 0, MRVDRV_SIZE_OF_CMD_BUFFER); |
@@ -1687,7 +1688,8 @@ void lbs_set_cmd_ctrl_node(struct lbs_private *priv, | |||
1687 | 1688 | ||
1688 | ptempnode->wait_option = wait_option; | 1689 | ptempnode->wait_option = wait_option; |
1689 | ptempnode->pdata_buf = pdata_buf; | 1690 | ptempnode->pdata_buf = pdata_buf; |
1690 | ptempnode->pdata_size = 0; | 1691 | ptempnode->pdata_size = NULL; |
1692 | ptempnode->callback = NULL; | ||
1691 | 1693 | ||
1692 | lbs_deb_leave(LBS_DEB_HOST); | 1694 | lbs_deb_leave(LBS_DEB_HOST); |
1693 | } | 1695 | } |
@@ -2012,10 +2014,26 @@ void lbs_ps_confirm_sleep(struct lbs_private *priv, u16 psmode) | |||
2012 | * @return -1 in case of a higher level error, otherwise | 2014 | * @return -1 in case of a higher level error, otherwise |
2013 | * the result code from the firmware | 2015 | * the result code from the firmware |
2014 | */ | 2016 | */ |
2015 | int lbs_cmd(struct lbs_private *priv, | 2017 | |
2016 | u16 command, | 2018 | static int lbs_cmd_callback(uint16_t respcmd, struct cmd_ds_command *resp, struct lbs_private *priv) |
2017 | void *cmd, int cmd_size, | 2019 | { |
2018 | void *rsp, int *rsp_size) | 2020 | struct cmd_ds_gen *r = (struct cmd_ds_gen *)resp; |
2021 | struct lbs_adapter *adapter = priv->adapter; | ||
2022 | u16 sz = cpu_to_le16(resp->size) - S_DS_GEN; | ||
2023 | |||
2024 | if (sz > *adapter->cur_cmd->pdata_size) { | ||
2025 | lbs_pr_err("response 0x%04x doesn't fit into buffer (%d > %d)\n", | ||
2026 | respcmd, sz, *adapter->cur_cmd->pdata_size); | ||
2027 | sz = *adapter->cur_cmd->pdata_size; | ||
2028 | } | ||
2029 | memcpy(adapter->cur_cmd->pdata_buf, r->cmdresp, sz); | ||
2030 | *adapter->cur_cmd->pdata_size = sz; | ||
2031 | |||
2032 | return 0; | ||
2033 | } | ||
2034 | |||
2035 | int lbs_cmd(struct lbs_private *priv, u16 command, void *cmd, int cmd_size, | ||
2036 | void *rsp, int *rsp_size) | ||
2019 | { | 2037 | { |
2020 | struct lbs_adapter *adapter = priv->adapter; | 2038 | struct lbs_adapter *adapter = priv->adapter; |
2021 | struct cmd_ctrl_node *cmdnode; | 2039 | struct cmd_ctrl_node *cmdnode; |
@@ -2053,6 +2071,7 @@ int lbs_cmd(struct lbs_private *priv, | |||
2053 | cmdnode->wait_option = CMD_OPTION_WAITFORRSP; | 2071 | cmdnode->wait_option = CMD_OPTION_WAITFORRSP; |
2054 | cmdnode->pdata_buf = rsp; | 2072 | cmdnode->pdata_buf = rsp; |
2055 | cmdnode->pdata_size = rsp_size; | 2073 | cmdnode->pdata_size = rsp_size; |
2074 | cmdnode->callback = lbs_cmd_callback; | ||
2056 | 2075 | ||
2057 | /* Set sequence number, clean result, move to buffer */ | 2076 | /* Set sequence number, clean result, move to buffer */ |
2058 | adapter->seqnum++; | 2077 | adapter->seqnum++; |
diff --git a/drivers/net/wireless/libertas/cmdresp.c b/drivers/net/wireless/libertas/cmdresp.c index 22a697363381..20ca38c7f870 100644 --- a/drivers/net/wireless/libertas/cmdresp.c +++ b/drivers/net/wireless/libertas/cmdresp.c | |||
@@ -880,22 +880,15 @@ int lbs_process_rx_command(struct lbs_private *priv) | |||
880 | goto done; | 880 | goto done; |
881 | } | 881 | } |
882 | 882 | ||
883 | if (adapter->cur_cmd->pdata_size) { | 883 | spin_unlock_irqrestore(&adapter->driver_lock, flags); |
884 | struct cmd_ds_gen *r = (struct cmd_ds_gen *)resp; | 884 | |
885 | u16 sz = cpu_to_le16(resp->size) - S_DS_GEN; | 885 | if (adapter->cur_cmd && adapter->cur_cmd->callback) |
886 | if (sz > *adapter->cur_cmd->pdata_size) { | 886 | ret = adapter->cur_cmd->callback(respcmd, resp, priv); |
887 | lbs_pr_err("response 0x%04x doesn't fit into " | 887 | else |
888 | "buffer (%d > %d)\n", respcmd, | ||
889 | sz, *adapter->cur_cmd->pdata_size); | ||
890 | sz = *adapter->cur_cmd->pdata_size; | ||
891 | } | ||
892 | memcpy(adapter->cur_cmd->pdata_buf, r->cmdresp, sz); | ||
893 | *adapter->cur_cmd->pdata_size = sz; | ||
894 | } else { | ||
895 | spin_unlock_irqrestore(&adapter->driver_lock, flags); | ||
896 | ret = handle_cmd_response(respcmd, resp, priv); | 888 | ret = handle_cmd_response(respcmd, resp, priv); |
897 | spin_lock_irqsave(&adapter->driver_lock, flags); | 889 | |
898 | } | 890 | spin_lock_irqsave(&adapter->driver_lock, flags); |
891 | |||
899 | if (adapter->cur_cmd) { | 892 | if (adapter->cur_cmd) { |
900 | /* Clean up and Put current command back to cmdfreeq */ | 893 | /* Clean up and Put current command back to cmdfreeq */ |
901 | __lbs_cleanup_and_insert_cmd(priv, adapter->cur_cmd); | 894 | __lbs_cleanup_and_insert_cmd(priv, adapter->cur_cmd); |
diff --git a/drivers/net/wireless/libertas/hostcmd.h b/drivers/net/wireless/libertas/hostcmd.h index be69ae652923..5ef65ae0de5a 100644 --- a/drivers/net/wireless/libertas/hostcmd.h +++ b/drivers/net/wireless/libertas/hostcmd.h | |||
@@ -72,6 +72,7 @@ struct cmd_ctrl_node { | |||
72 | /* command response */ | 72 | /* command response */ |
73 | void *pdata_buf; | 73 | void *pdata_buf; |
74 | int *pdata_size; | 74 | int *pdata_size; |
75 | int (*callback)(uint16_t respcmd, struct cmd_ds_command *resp, struct lbs_private *priv); | ||
75 | /* command data */ | 76 | /* command data */ |
76 | u8 *bufvirtualaddr; | 77 | u8 *bufvirtualaddr; |
77 | /* wait queue */ | 78 | /* wait queue */ |