aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2007-12-11 12:33:30 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:06:41 -0500
commit7ad994dec7d36c319cb35cbf3a920d3bda96e6b0 (patch)
treeb186f3896514d34a86438b61bf3770fde0e4d960 /drivers
parentb15152a4033d4c82015bb79c6b81eeb0a2edeeea (diff)
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: Dan Williams <dcbw@redhat.com> Signed-off-by: David Woodhouse <dwmw2@infradead.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/libertas/cmd.c22
-rw-r--r--drivers/net/wireless/libertas/cmd.h8
-rw-r--r--drivers/net/wireless/libertas/cmdresp.c7
-rw-r--r--drivers/net/wireless/libertas/hostcmd.h12
4 files changed, 31 insertions, 18 deletions
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c
index 2efba5708041..78870c770428 100644
--- a/drivers/net/wireless/libertas/cmd.c
+++ b/drivers/net/wireless/libertas/cmd.c
@@ -1988,12 +1988,13 @@ void lbs_ps_confirm_sleep(struct lbs_private *priv, u16 psmode)
1988 * the result code from the firmware 1988 * the result code from the firmware
1989 */ 1989 */
1990 1990
1991int __lbs_cmd(struct lbs_private *priv, uint16_t command, void *cmd, int cmd_size, 1991int __lbs_cmd(struct lbs_private *priv, uint16_t command,
1992 int (*callback)(struct lbs_private *, unsigned long, struct cmd_ds_command *), 1992 struct cmd_header *in_cmd, int in_cmd_size,
1993 int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *),
1993 unsigned long callback_arg) 1994 unsigned long callback_arg)
1994{ 1995{
1995 struct cmd_ctrl_node *cmdnode; 1996 struct cmd_ctrl_node *cmdnode;
1996 struct cmd_ds_gen *cmdptr; 1997 struct cmd_header *send_cmd;
1997 unsigned long flags; 1998 unsigned long flags;
1998 int ret = 0; 1999 int ret = 0;
1999 2000
@@ -2012,7 +2013,6 @@ int __lbs_cmd(struct lbs_private *priv, uint16_t command, void *cmd, int cmd_siz
2012 } 2013 }
2013 2014
2014 cmdnode = lbs_get_cmd_ctrl_node(priv); 2015 cmdnode = lbs_get_cmd_ctrl_node(priv);
2015
2016 if (cmdnode == NULL) { 2016 if (cmdnode == NULL) {
2017 lbs_deb_host("PREP_CMD: cmdnode is NULL\n"); 2017 lbs_deb_host("PREP_CMD: cmdnode is NULL\n");
2018 2018
@@ -2022,18 +2022,20 @@ int __lbs_cmd(struct lbs_private *priv, uint16_t command, void *cmd, int cmd_siz
2022 goto done; 2022 goto done;
2023 } 2023 }
2024 2024
2025 cmdptr = (struct cmd_ds_gen *)cmdnode->bufvirtualaddr; 2025 send_cmd = (struct cmd_header *) cmdnode->bufvirtualaddr;
2026 cmdnode->wait_option = CMD_OPTION_WAITFORRSP; 2026 cmdnode->wait_option = CMD_OPTION_WAITFORRSP;
2027 cmdnode->callback = callback; 2027 cmdnode->callback = callback;
2028 cmdnode->callback_arg = callback_arg; 2028 cmdnode->callback_arg = callback_arg;
2029 2029
2030 /* Copy the incoming command to the buffer */
2031 memcpy(send_cmd, in_cmd, in_cmd_size);
2032
2030 /* Set sequence number, clean result, move to buffer */ 2033 /* Set sequence number, clean result, move to buffer */
2031 priv->seqnum++; 2034 priv->seqnum++;
2032 cmdptr->command = cpu_to_le16(command); 2035 send_cmd->command = cpu_to_le16(command);
2033 cmdptr->size = cpu_to_le16(cmd_size + S_DS_GEN); 2036 send_cmd->size = cpu_to_le16(in_cmd_size);
2034 cmdptr->seqnum = cpu_to_le16(priv->seqnum); 2037 send_cmd->seqnum = cpu_to_le16(priv->seqnum);
2035 cmdptr->result = 0; 2038 send_cmd->result = 0;
2036 memcpy(cmdptr->cmdresp, cmd, cmd_size);
2037 2039
2038 lbs_deb_host("PREP_CMD: command 0x%04x\n", command); 2040 lbs_deb_host("PREP_CMD: command 0x%04x\n", command);
2039 2041
diff --git a/drivers/net/wireless/libertas/cmd.h b/drivers/net/wireless/libertas/cmd.h
index 546db4996487..259d3e87193f 100644
--- a/drivers/net/wireless/libertas/cmd.h
+++ b/drivers/net/wireless/libertas/cmd.h
@@ -7,10 +7,12 @@
7#include "dev.h" 7#include "dev.h"
8 8
9#define lbs_cmd(priv, cmdnr, cmd, callback, callback_arg) \ 9#define lbs_cmd(priv, cmdnr, cmd, callback, callback_arg) \
10 __lbs_cmd(priv, cmdnr, &cmd, sizeof(cmd), callback, callback_arg) 10 __lbs_cmd(priv, cmdnr, (struct cmd_header *) &cmd, sizeof(cmd), \
11 callback, callback_arg)
11 12
12int __lbs_cmd(struct lbs_private *priv, uint16_t command, void *cmd, int cmd_size, 13int __lbs_cmd(struct lbs_private *priv, uint16_t command,
13 int (*callback)(struct lbs_private *, unsigned long, struct cmd_ds_command *), 14 struct cmd_header *in_cmd, int in_cmd_size,
15 int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *),
14 unsigned long callback_arg); 16 unsigned long callback_arg);
15 17
16#endif /* _LBS_CMD_H */ 18#endif /* _LBS_CMD_H */
diff --git a/drivers/net/wireless/libertas/cmdresp.c b/drivers/net/wireless/libertas/cmdresp.c
index 7bad257fd9cb..91136697f697 100644
--- a/drivers/net/wireless/libertas/cmdresp.c
+++ b/drivers/net/wireless/libertas/cmdresp.c
@@ -861,9 +861,10 @@ int lbs_process_rx_command(struct lbs_private *priv)
861 861
862 spin_unlock_irqrestore(&priv->driver_lock, flags); 862 spin_unlock_irqrestore(&priv->driver_lock, flags);
863 863
864 if (priv->cur_cmd && priv->cur_cmd->callback) 864 if (priv->cur_cmd && priv->cur_cmd->callback) {
865 ret = priv->cur_cmd->callback(priv, priv->cur_cmd->callback_arg, resp); 865 ret = priv->cur_cmd->callback(priv, priv->cur_cmd->callback_arg,
866 else 866 (struct cmd_header *) resp);
867 } else
867 ret = handle_cmd_response(priv, 0, resp); 868 ret = handle_cmd_response(priv, 0, resp);
868 869
869 spin_lock_irqsave(&priv->driver_lock, flags); 870 spin_lock_irqsave(&priv->driver_lock, flags);
diff --git a/drivers/net/wireless/libertas/hostcmd.h b/drivers/net/wireless/libertas/hostcmd.h
index ed502b74fa3c..93ac46a05c54 100644
--- a/drivers/net/wireless/libertas/hostcmd.h
+++ b/drivers/net/wireless/libertas/hostcmd.h
@@ -65,13 +65,20 @@ struct rxpd {
65 u8 reserved[3]; 65 u8 reserved[3];
66}; 66};
67 67
68struct cmd_header {
69 __le16 command;
70 __le16 size;
71 __le16 seqnum;
72 __le16 result;
73} __attribute__ ((packed));
74
68struct cmd_ctrl_node { 75struct cmd_ctrl_node {
69 struct list_head list; 76 struct list_head list;
70 /* wait for finish or not */ 77 /* wait for finish or not */
71 u16 wait_option; 78 u16 wait_option;
72 /* command response */ 79 /* command response */
73 void *pdata_buf; 80 void *pdata_buf;
74 int (*callback)(struct lbs_private *priv, unsigned long arg, struct cmd_ds_command *resp); 81 int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *);
75 unsigned long callback_arg; 82 unsigned long callback_arg;
76 /* command data */ 83 /* command data */
77 u8 *bufvirtualaddr; 84 u8 *bufvirtualaddr;
@@ -424,6 +431,8 @@ struct cmd_ds_802_11_monitor_mode {
424}; 431};
425 432
426struct cmd_ds_set_boot2_ver { 433struct cmd_ds_set_boot2_ver {
434 struct cmd_header hdr;
435
427 __le16 action; 436 __le16 action;
428 __le16 version; 437 __le16 version;
429}; 438};
@@ -678,7 +687,6 @@ struct cmd_ds_command {
678 struct cmd_ds_bt_access bt; 687 struct cmd_ds_bt_access bt;
679 struct cmd_ds_fwt_access fwt; 688 struct cmd_ds_fwt_access fwt;
680 struct cmd_ds_mesh_access mesh; 689 struct cmd_ds_mesh_access mesh;
681 struct cmd_ds_set_boot2_ver boot2_ver;
682 struct cmd_ds_get_tsf gettsf; 690 struct cmd_ds_get_tsf gettsf;
683 struct cmd_ds_802_11_subscribe_event subscribe_event; 691 struct cmd_ds_802_11_subscribe_event subscribe_event;
684 struct cmd_ds_802_11_beacon_control bcn_ctrl; 692 struct cmd_ds_802_11_beacon_control bcn_ctrl;