Commit 7ad994de authored by Dan Williams's avatar Dan Williams Committed by David S. Miller

libertas: clean up direct command handling

Move direct command handling through __lbs_cmd() over to using the
header as the first member of the command structure, and only define
the __lbs_cmd() callback in one place rather than 3.  Convert boot2
version command to new usage.
Signed-off-by: default avatarDan Williams <dcbw@redhat.com>
Signed-off-by: default avatarDavid Woodhouse <dwmw2@infradead.org>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent b15152a4
...@@ -1988,12 +1988,13 @@ void lbs_ps_confirm_sleep(struct lbs_private *priv, u16 psmode) ...@@ -1988,12 +1988,13 @@ void lbs_ps_confirm_sleep(struct lbs_private *priv, u16 psmode)
* the result code from the firmware * the result code from the firmware
*/ */
int __lbs_cmd(struct lbs_private *priv, uint16_t command, void *cmd, int cmd_size, int __lbs_cmd(struct lbs_private *priv, uint16_t command,
int (*callback)(struct lbs_private *, unsigned long, struct cmd_ds_command *), struct cmd_header *in_cmd, int in_cmd_size,
int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *),
unsigned long callback_arg) unsigned long callback_arg)
{ {
struct cmd_ctrl_node *cmdnode; struct cmd_ctrl_node *cmdnode;
struct cmd_ds_gen *cmdptr; struct cmd_header *send_cmd;
unsigned long flags; unsigned long flags;
int ret = 0; int ret = 0;
...@@ -2012,7 +2013,6 @@ int __lbs_cmd(struct lbs_private *priv, uint16_t command, void *cmd, int cmd_siz ...@@ -2012,7 +2013,6 @@ int __lbs_cmd(struct lbs_private *priv, uint16_t command, void *cmd, int cmd_siz
} }
cmdnode = lbs_get_cmd_ctrl_node(priv); cmdnode = lbs_get_cmd_ctrl_node(priv);
if (cmdnode == NULL) { if (cmdnode == NULL) {
lbs_deb_host("PREP_CMD: cmdnode is NULL\n"); lbs_deb_host("PREP_CMD: cmdnode is NULL\n");
...@@ -2022,18 +2022,20 @@ int __lbs_cmd(struct lbs_private *priv, uint16_t command, void *cmd, int cmd_siz ...@@ -2022,18 +2022,20 @@ int __lbs_cmd(struct lbs_private *priv, uint16_t command, void *cmd, int cmd_siz
goto done; goto done;
} }
cmdptr = (struct cmd_ds_gen *)cmdnode->bufvirtualaddr; send_cmd = (struct cmd_header *) cmdnode->bufvirtualaddr;
cmdnode->wait_option = CMD_OPTION_WAITFORRSP; cmdnode->wait_option = CMD_OPTION_WAITFORRSP;
cmdnode->callback = callback; cmdnode->callback = callback;
cmdnode->callback_arg = callback_arg; cmdnode->callback_arg = callback_arg;
/* Copy the incoming command to the buffer */
memcpy(send_cmd, in_cmd, in_cmd_size);
/* Set sequence number, clean result, move to buffer */ /* Set sequence number, clean result, move to buffer */
priv->seqnum++; priv->seqnum++;
cmdptr->command = cpu_to_le16(command); send_cmd->command = cpu_to_le16(command);
cmdptr->size = cpu_to_le16(cmd_size + S_DS_GEN); send_cmd->size = cpu_to_le16(in_cmd_size);
cmdptr->seqnum = cpu_to_le16(priv->seqnum); send_cmd->seqnum = cpu_to_le16(priv->seqnum);
cmdptr->result = 0; send_cmd->result = 0;
memcpy(cmdptr->cmdresp, cmd, cmd_size);
lbs_deb_host("PREP_CMD: command 0x%04x\n", command); lbs_deb_host("PREP_CMD: command 0x%04x\n", command);
......
...@@ -7,10 +7,12 @@ ...@@ -7,10 +7,12 @@
#include "dev.h" #include "dev.h"
#define lbs_cmd(priv, cmdnr, cmd, callback, callback_arg) \ #define lbs_cmd(priv, cmdnr, cmd, callback, callback_arg) \
__lbs_cmd(priv, cmdnr, &cmd, sizeof(cmd), callback, callback_arg) __lbs_cmd(priv, cmdnr, (struct cmd_header *) &cmd, sizeof(cmd), \
callback, callback_arg)
int __lbs_cmd(struct lbs_private *priv, uint16_t command, void *cmd, int cmd_size, int __lbs_cmd(struct lbs_private *priv, uint16_t command,
int (*callback)(struct lbs_private *, unsigned long, struct cmd_ds_command *), struct cmd_header *in_cmd, int in_cmd_size,
int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *),
unsigned long callback_arg); unsigned long callback_arg);
#endif /* _LBS_CMD_H */ #endif /* _LBS_CMD_H */
...@@ -861,9 +861,10 @@ int lbs_process_rx_command(struct lbs_private *priv) ...@@ -861,9 +861,10 @@ int lbs_process_rx_command(struct lbs_private *priv)
spin_unlock_irqrestore(&priv->driver_lock, flags); spin_unlock_irqrestore(&priv->driver_lock, flags);
if (priv->cur_cmd && priv->cur_cmd->callback) if (priv->cur_cmd && priv->cur_cmd->callback) {
ret = priv->cur_cmd->callback(priv, priv->cur_cmd->callback_arg, resp); ret = priv->cur_cmd->callback(priv, priv->cur_cmd->callback_arg,
else (struct cmd_header *) resp);
} else
ret = handle_cmd_response(priv, 0, resp); ret = handle_cmd_response(priv, 0, resp);
spin_lock_irqsave(&priv->driver_lock, flags); spin_lock_irqsave(&priv->driver_lock, flags);
......
...@@ -65,13 +65,20 @@ struct rxpd { ...@@ -65,13 +65,20 @@ struct rxpd {
u8 reserved[3]; u8 reserved[3];
}; };
struct cmd_header {
__le16 command;
__le16 size;
__le16 seqnum;
__le16 result;
} __attribute__ ((packed));
struct cmd_ctrl_node { struct cmd_ctrl_node {
struct list_head list; struct list_head list;
/* wait for finish or not */ /* wait for finish or not */
u16 wait_option; u16 wait_option;
/* command response */ /* command response */
void *pdata_buf; void *pdata_buf;
int (*callback)(struct lbs_private *priv, unsigned long arg, struct cmd_ds_command *resp); int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *);
unsigned long callback_arg; unsigned long callback_arg;
/* command data */ /* command data */
u8 *bufvirtualaddr; u8 *bufvirtualaddr;
...@@ -424,6 +431,8 @@ struct cmd_ds_802_11_monitor_mode { ...@@ -424,6 +431,8 @@ struct cmd_ds_802_11_monitor_mode {
}; };
struct cmd_ds_set_boot2_ver { struct cmd_ds_set_boot2_ver {
struct cmd_header hdr;
__le16 action; __le16 action;
__le16 version; __le16 version;
}; };
...@@ -678,7 +687,6 @@ struct cmd_ds_command { ...@@ -678,7 +687,6 @@ struct cmd_ds_command {
struct cmd_ds_bt_access bt; struct cmd_ds_bt_access bt;
struct cmd_ds_fwt_access fwt; struct cmd_ds_fwt_access fwt;
struct cmd_ds_mesh_access mesh; struct cmd_ds_mesh_access mesh;
struct cmd_ds_set_boot2_ver boot2_ver;
struct cmd_ds_get_tsf gettsf; struct cmd_ds_get_tsf gettsf;
struct cmd_ds_802_11_subscribe_event subscribe_event; struct cmd_ds_802_11_subscribe_event subscribe_event;
struct cmd_ds_802_11_beacon_control bcn_ctrl; struct cmd_ds_802_11_beacon_control bcn_ctrl;
......
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