#include "wext.h"
static void cleanup_cmdnode(struct cmd_ctrl_node *ptempnode);
+struct cmd_ctrl_node *lbs_get_cmd_ctrl_node(struct lbs_private *priv);
+void lbs_set_cmd_ctrl_node(struct lbs_private *priv,
+ struct cmd_ctrl_node *ptempnode,
+ u16 wait_option, void *pdata_buf);
+
static u16 commands_allowed_in_ps[] = {
CMD_802_11_RSSI,
return 0;
}
-static int lbs_cmd_hw_spec(lbs_private * priv, struct cmd_ds_command *cmd)
+static int lbs_cmd_hw_spec(struct lbs_private *priv, struct cmd_ds_command *cmd)
{
struct cmd_ds_get_hw_spec *hwspec = &cmd->params.hwspec;
return 0;
}
-static int lbs_cmd_802_11_ps_mode(lbs_private * priv,
+static int lbs_cmd_802_11_ps_mode(struct lbs_private *priv,
struct cmd_ds_command *cmd,
u16 cmd_action)
{
return 0;
}
-static int lbs_cmd_802_11_inactivity_timeout(lbs_private * priv,
+static int lbs_cmd_802_11_inactivity_timeout(struct lbs_private *priv,
struct cmd_ds_command *cmd,
u16 cmd_action, void *pdata_buf)
{
return 0;
}
-static int lbs_cmd_802_11_sleep_params(lbs_private * priv,
+static int lbs_cmd_802_11_sleep_params(struct lbs_private *priv,
struct cmd_ds_command *cmd,
u16 cmd_action)
{
- lbs_adapter *adapter = priv->adapter;
+ struct lbs_adapter *adapter = priv->adapter;
struct cmd_ds_802_11_sleep_params *sp = &cmd->params.sleep_params;
lbs_deb_enter(LBS_DEB_CMD);
return 0;
}
-static int lbs_cmd_802_11_set_wep(lbs_private * priv,
+static int lbs_cmd_802_11_set_wep(struct lbs_private *priv,
struct cmd_ds_command *cmd,
u32 cmd_act,
void * pdata_buf)
{
struct cmd_ds_802_11_set_wep *wep = &cmd->params.wep;
- lbs_adapter *adapter = priv->adapter;
+ struct lbs_adapter *adapter = priv->adapter;
int ret = 0;
struct assoc_request * assoc_req = pdata_buf;
return ret;
}
-static int lbs_cmd_802_11_enable_rsn(lbs_private * priv,
+static int lbs_cmd_802_11_enable_rsn(struct lbs_private *priv,
struct cmd_ds_command *cmd,
u16 cmd_action,
void * pdata_buf)
}
+static ssize_t lbs_tlv_size(const u8 *tlv, u16 size)
+{
+ ssize_t pos = 0;
+ struct mrvlietypesheader *tlv_h;
+ while (pos < size) {
+ u16 length;
+ tlv_h = (struct mrvlietypesheader *) tlv;
+ if (tlv_h->len == 0)
+ return pos;
+ length = le16_to_cpu(tlv_h->len) +
+ sizeof(struct mrvlietypesheader);
+ pos += length;
+ tlv += length;
+ }
+ return pos;
+}
+
+
+static void lbs_cmd_802_11_subscribe_event(struct lbs_private *priv,
+ struct cmd_ds_command *cmd, u16 cmd_action,
+ void *pdata_buf)
+{
+ struct cmd_ds_802_11_subscribe_event *events =
+ (struct cmd_ds_802_11_subscribe_event *) pdata_buf;
+
+ /* pdata_buf points to a struct cmd_ds_802_11_subscribe_event and room
+ * for various Marvell TLVs */
+
+ lbs_deb_enter(LBS_DEB_CMD);
+
+ cmd->size = cpu_to_le16(sizeof(*events)
+ - sizeof(events->tlv)
+ + S_DS_GEN);
+ cmd->params.subscribe_event.action = cpu_to_le16(cmd_action);
+ if (cmd_action == CMD_ACT_GET) {
+ cmd->params.subscribe_event.events = 0;
+ } else {
+ ssize_t sz = lbs_tlv_size(events->tlv, sizeof(events->tlv));
+ cmd->size = cpu_to_le16(le16_to_cpu(cmd->size) + sz);
+ cmd->params.subscribe_event.events = events->events;
+ memcpy(cmd->params.subscribe_event.tlv, events->tlv, sz);
+ }
+
+ lbs_deb_leave(LBS_DEB_CMD);
+}
+
static void set_one_wpa_key(struct MrvlIEtype_keyParamSet * pkeyparamset,
struct enc_key * pkey)
{
lbs_deb_leave(LBS_DEB_CMD);
}
-static int lbs_cmd_802_11_key_material(lbs_private * priv,
+static int lbs_cmd_802_11_key_material(struct lbs_private *priv,
struct cmd_ds_command *cmd,
u16 cmd_action,
u32 cmd_oid, void *pdata_buf)
return ret;
}
-static int lbs_cmd_802_11_reset(lbs_private * priv,
+static int lbs_cmd_802_11_reset(struct lbs_private *priv,
struct cmd_ds_command *cmd, int cmd_action)
{
struct cmd_ds_802_11_reset *reset = &cmd->params.reset;
return 0;
}
-static int lbs_cmd_802_11_get_log(lbs_private * priv,
+static int lbs_cmd_802_11_get_log(struct lbs_private *priv,
struct cmd_ds_command *cmd)
{
lbs_deb_enter(LBS_DEB_CMD);
return 0;
}
-static int lbs_cmd_802_11_get_stat(lbs_private * priv,
+static int lbs_cmd_802_11_get_stat(struct lbs_private *priv,
struct cmd_ds_command *cmd)
{
lbs_deb_enter(LBS_DEB_CMD);
return 0;
}
-static int lbs_cmd_802_11_snmp_mib(lbs_private * priv,
+static int lbs_cmd_802_11_snmp_mib(struct lbs_private *priv,
struct cmd_ds_command *cmd,
int cmd_action,
int cmd_oid, void *pdata_buf)
{
struct cmd_ds_802_11_snmp_mib *pSNMPMIB = &cmd->params.smib;
- lbs_adapter *adapter = priv->adapter;
+ struct lbs_adapter *adapter = priv->adapter;
u8 ucTemp;
lbs_deb_enter(LBS_DEB_CMD);
return 0;
}
-static int lbs_cmd_802_11_radio_control(lbs_private * priv,
+static int lbs_cmd_802_11_radio_control(struct lbs_private *priv,
struct cmd_ds_command *cmd,
int cmd_action)
{
- lbs_adapter *adapter = priv->adapter;
+ struct lbs_adapter *adapter = priv->adapter;
struct cmd_ds_802_11_radio_control *pradiocontrol = &cmd->params.radio;
lbs_deb_enter(LBS_DEB_CMD);
return 0;
}
-static int lbs_cmd_802_11_rf_tx_power(lbs_private * priv,
+static int lbs_cmd_802_11_rf_tx_power(struct lbs_private *priv,
struct cmd_ds_command *cmd,
u16 cmd_action, void *pdata_buf)
{
return 0;
}
-static int lbs_cmd_802_11_monitor_mode(lbs_private * priv,
+static int lbs_cmd_802_11_monitor_mode(struct lbs_private *priv,
struct cmd_ds_command *cmd,
u16 cmd_action, void *pdata_buf)
{
return 0;
}
-static int lbs_cmd_802_11_rate_adapt_rateset(lbs_private * priv,
+static int lbs_cmd_802_11_rate_adapt_rateset(struct lbs_private *priv,
struct cmd_ds_command *cmd,
u16 cmd_action)
{
struct cmd_ds_802_11_rate_adapt_rateset
*rateadapt = &cmd->params.rateset;
- lbs_adapter *adapter = priv->adapter;
+ struct lbs_adapter *adapter = priv->adapter;
lbs_deb_enter(LBS_DEB_CMD);
cmd->size =
return 0;
}
-static int lbs_cmd_802_11_data_rate(lbs_private * priv,
+static int lbs_cmd_802_11_data_rate(struct lbs_private *priv,
struct cmd_ds_command *cmd,
u16 cmd_action)
{
struct cmd_ds_802_11_data_rate *pdatarate = &cmd->params.drate;
- lbs_adapter *adapter = priv->adapter;
+ struct lbs_adapter *adapter = priv->adapter;
lbs_deb_enter(LBS_DEB_CMD);
return 0;
}
-static int lbs_cmd_mac_multicast_adr(lbs_private * priv,
+static int lbs_cmd_mac_multicast_adr(struct lbs_private *priv,
struct cmd_ds_command *cmd,
u16 cmd_action)
{
struct cmd_ds_mac_multicast_adr *pMCastAdr = &cmd->params.madr;
- lbs_adapter *adapter = priv->adapter;
+ struct lbs_adapter *adapter = priv->adapter;
lbs_deb_enter(LBS_DEB_CMD);
cmd->size = cpu_to_le16(sizeof(struct cmd_ds_mac_multicast_adr) +
return 0;
}
-static int lbs_cmd_802_11_rf_channel(lbs_private * priv,
+static int lbs_cmd_802_11_rf_channel(struct lbs_private *priv,
struct cmd_ds_command *cmd,
int option, void *pdata_buf)
{
return 0;
}
-static int lbs_cmd_802_11_rssi(lbs_private * priv,
+static int lbs_cmd_802_11_rssi(struct lbs_private *priv,
struct cmd_ds_command *cmd)
{
- lbs_adapter *adapter = priv->adapter;
+ struct lbs_adapter *adapter = priv->adapter;
lbs_deb_enter(LBS_DEB_CMD);
cmd->command = cpu_to_le16(CMD_802_11_RSSI);
return 0;
}
-static int lbs_cmd_reg_access(lbs_private * priv,
+static int lbs_cmd_reg_access(struct lbs_private *priv,
struct cmd_ds_command *cmdptr,
u8 cmd_action, void *pdata_buf)
{
return 0;
}
-static int lbs_cmd_802_11_mac_address(lbs_private * priv,
+static int lbs_cmd_802_11_mac_address(struct lbs_private *priv,
struct cmd_ds_command *cmd,
u16 cmd_action)
{
- lbs_adapter *adapter = priv->adapter;
+ struct lbs_adapter *adapter = priv->adapter;
lbs_deb_enter(LBS_DEB_CMD);
cmd->command = cpu_to_le16(CMD_802_11_MAC_ADDRESS);
return 0;
}
-static int lbs_cmd_802_11_eeprom_access(lbs_private * priv,
+static int lbs_cmd_802_11_eeprom_access(struct lbs_private *priv,
struct cmd_ds_command *cmd,
int cmd_action, void *pdata_buf)
{
return 0;
}
-static int lbs_cmd_bt_access(lbs_private * priv,
+static int lbs_cmd_bt_access(struct lbs_private *priv,
struct cmd_ds_command *cmd,
u16 cmd_action, void *pdata_buf)
{
return 0;
}
-static int lbs_cmd_fwt_access(lbs_private * priv,
+static int lbs_cmd_fwt_access(struct lbs_private *priv,
struct cmd_ds_command *cmd,
u16 cmd_action, void *pdata_buf)
{
return 0;
}
-static int lbs_cmd_mesh_access(lbs_private * priv,
+static int lbs_cmd_mesh_access(struct lbs_private *priv,
struct cmd_ds_command *cmd,
u16 cmd_action, void *pdata_buf)
{
return 0;
}
-static int lbs_cmd_set_boot2_ver(lbs_private * priv,
+static int lbs_cmd_set_boot2_ver(struct lbs_private *priv,
struct cmd_ds_command *cmd,
u16 cmd_action, void *pdata_buf)
{
* Note: NEVER use lbs_queue_cmd() with addtail==0 other than for
* the command timer, because it does not account for queued commands.
*/
-void lbs_queue_cmd(lbs_adapter * adapter, struct cmd_ctrl_node *cmdnode, u8 addtail)
+void lbs_queue_cmd(struct lbs_adapter *adapter,
+ struct cmd_ctrl_node *cmdnode,
+ u8 addtail)
{
unsigned long flags;
struct cmd_ds_command *cmdptr;
* For now - we are not performing the endian conversion the second time - but
* for PS and DEEP_SLEEP we need to worry
*/
-static int DownloadcommandToStation(lbs_private * priv,
+static int DownloadcommandToStation(struct lbs_private *priv,
struct cmd_ctrl_node *cmdnode)
{
unsigned long flags;
struct cmd_ds_command *cmdptr;
- lbs_adapter *adapter = priv->adapter;
+ struct lbs_adapter *adapter = priv->adapter;
int ret = -1;
u16 cmdsize;
u16 command;
return ret;
}
-static int lbs_cmd_mac_control(lbs_private * priv,
+static int lbs_cmd_mac_control(struct lbs_private *priv,
struct cmd_ds_command *cmd)
{
struct cmd_ds_mac_control *mac = &cmd->params.macctrl;
* This function inserts command node to cmdfreeq
* after cleans it. Requires adapter->driver_lock held.
*/
-void __lbs_cleanup_and_insert_cmd(lbs_private * priv, struct cmd_ctrl_node *ptempcmd)
+void __lbs_cleanup_and_insert_cmd(struct lbs_private *priv,
+ struct cmd_ctrl_node *ptempcmd)
{
- lbs_adapter *adapter = priv->adapter;
+ struct lbs_adapter *adapter = priv->adapter;
if (!ptempcmd)
return;
list_add_tail((struct list_head *)ptempcmd, &adapter->cmdfreeq);
}
-static void lbs_cleanup_and_insert_cmd(lbs_private * priv, struct cmd_ctrl_node *ptempcmd)
+static void lbs_cleanup_and_insert_cmd(struct lbs_private *priv,
+ struct cmd_ctrl_node *ptempcmd)
{
unsigned long flags;
spin_unlock_irqrestore(&priv->adapter->driver_lock, flags);
}
-int lbs_set_radio_control(lbs_private * priv)
+int lbs_set_radio_control(struct lbs_private *priv)
{
int ret = 0;
return ret;
}
-int lbs_set_mac_packet_filter(lbs_private * priv)
+int lbs_set_mac_packet_filter(struct lbs_private *priv)
{
int ret = 0;
/**
* @brief This function prepare the command before send to firmware.
*
- * @param priv A pointer to lbs_private structure
+ * @param priv A pointer to struct lbs_private structure
* @param cmd_no command number
* @param cmd_action command action: GET or SET
* @param wait_option wait option: wait response or not
* @param pdata_buf A pointer to informaion buffer
* @return 0 or -1
*/
-int lbs_prepare_and_send_command(lbs_private * priv,
+int lbs_prepare_and_send_command(struct lbs_private *priv,
u16 cmd_no,
u16 cmd_action,
u16 wait_option, u32 cmd_oid, void *pdata_buf)
{
int ret = 0;
- lbs_adapter *adapter = priv->adapter;
+ struct lbs_adapter *adapter = priv->adapter;
struct cmd_ctrl_node *cmdnode;
struct cmd_ds_command *cmdptr;
unsigned long flags;
goto done;
}
- cmdnode = lbs_get_free_cmd_ctrl_node(priv);
+ cmdnode = lbs_get_cmd_ctrl_node(priv);
if (cmdnode == NULL) {
lbs_deb_host("PREP_CMD: cmdnode is NULL\n");
goto done;
}
- lbs_set_cmd_ctrl_node(priv, cmdnode, cmd_oid, wait_option, pdata_buf);
+ lbs_set_cmd_ctrl_node(priv, cmdnode, wait_option, pdata_buf);
cmdptr = (struct cmd_ds_command *)cmdnode->bufvirtualaddr;
case CMD_802_11_INACTIVITY_TIMEOUT:
ret = lbs_cmd_802_11_inactivity_timeout(priv, cmdptr,
cmd_action, pdata_buf);
- lbs_set_cmd_ctrl_node(priv, cmdnode, 0, 0, pdata_buf);
+ lbs_set_cmd_ctrl_node(priv, cmdnode, 0, pdata_buf);
break;
case CMD_802_11_TPC_CFG:
ret = 0;
break;
}
+ case CMD_802_11_SUBSCRIBE_EVENT:
+ lbs_cmd_802_11_subscribe_event(priv, cmdptr,
+ cmd_action, pdata_buf);
+ break;
case CMD_802_11_PWR_CFG:
cmdptr->command = cpu_to_le16(CMD_802_11_PWR_CFG);
cmdptr->size =
* @brief This function allocates the command buffer and link
* it to command free queue.
*
- * @param priv A pointer to lbs_private structure
+ * @param priv A pointer to struct lbs_private structure
* @return 0 or -1
*/
-int lbs_allocate_cmd_buffer(lbs_private * priv)
+int lbs_allocate_cmd_buffer(struct lbs_private *priv)
{
int ret = 0;
u32 ulbufsize;
u32 i;
struct cmd_ctrl_node *tempcmd_array;
u8 *ptempvirtualaddr;
- lbs_adapter *adapter = priv->adapter;
+ struct lbs_adapter *adapter = priv->adapter;
lbs_deb_enter(LBS_DEB_HOST);
/**
* @brief This function frees the command buffer.
*
- * @param priv A pointer to lbs_private structure
+ * @param priv A pointer to struct lbs_private structure
* @return 0 or -1
*/
-int lbs_free_cmd_buffer(lbs_private * priv)
+int lbs_free_cmd_buffer(struct lbs_private *priv)
{
u32 ulbufsize; /* Someone needs to die for this. Slowly and painfully */
unsigned int i;
struct cmd_ctrl_node *tempcmd_array;
- lbs_adapter *adapter = priv->adapter;
+ struct lbs_adapter *adapter = priv->adapter;
lbs_deb_enter(LBS_DEB_HOST);
* @brief This function gets a free command node if available in
* command free queue.
*
- * @param priv A pointer to lbs_private structure
+ * @param priv A pointer to struct lbs_private structure
* @return cmd_ctrl_node A pointer to cmd_ctrl_node structure or NULL
*/
-struct cmd_ctrl_node *lbs_get_free_cmd_ctrl_node(lbs_private * priv)
+struct cmd_ctrl_node *lbs_get_cmd_ctrl_node(struct lbs_private *priv)
{
struct cmd_ctrl_node *tempnode;
- lbs_adapter *adapter = priv->adapter;
+ struct lbs_adapter *adapter = priv->adapter;
unsigned long flags;
lbs_deb_enter(LBS_DEB_HOST);
return;
ptempnode->cmdwaitqwoken = 1;
wake_up_interruptible(&ptempnode->cmdwait_q);
- ptempnode->status = 0;
- ptempnode->cmd_oid = (u32) 0;
ptempnode->wait_option = 0;
ptempnode->pdata_buf = NULL;
+ ptempnode->pdata_size = 0;
if (ptempnode->bufvirtualaddr != NULL)
memset(ptempnode->bufvirtualaddr, 0, MRVDRV_SIZE_OF_CMD_BUFFER);
/**
* @brief This function initializes the command node.
*
- * @param priv A pointer to lbs_private structure
+ * @param priv A pointer to struct lbs_private structure
* @param ptempnode A pointer to cmd_ctrl_node structure
- * @param cmd_oid cmd oid: treated as sub command
* @param wait_option wait option: wait response or not
* @param pdata_buf A pointer to informaion buffer
* @return 0 or -1
*/
-void lbs_set_cmd_ctrl_node(lbs_private * priv,
+void lbs_set_cmd_ctrl_node(struct lbs_private *priv,
struct cmd_ctrl_node *ptempnode,
- u32 cmd_oid, u16 wait_option, void *pdata_buf)
+ u16 wait_option, void *pdata_buf)
{
lbs_deb_enter(LBS_DEB_HOST);
if (!ptempnode)
return;
- ptempnode->cmd_oid = cmd_oid;
ptempnode->wait_option = wait_option;
ptempnode->pdata_buf = pdata_buf;
+ ptempnode->pdata_size = 0;
lbs_deb_leave(LBS_DEB_HOST);
}
* pending queue. It will put fimware back to PS mode
* if applicable.
*
- * @param priv A pointer to lbs_private structure
+ * @param priv A pointer to struct lbs_private structure
* @return 0 or -1
*/
-int lbs_execute_next_command(lbs_private * priv)
+int lbs_execute_next_command(struct lbs_private *priv)
{
- lbs_adapter *adapter = priv->adapter;
+ struct lbs_adapter *adapter = priv->adapter;
struct cmd_ctrl_node *cmdnode = NULL;
struct cmd_ds_command *cmdptr;
unsigned long flags;
return ret;
}
-void lbs_send_iwevcustom_event(lbs_private *priv, s8 *str)
+void lbs_send_iwevcustom_event(struct lbs_private *priv, s8 *str)
{
union iwreq_data iwrq;
u8 buf[50];
lbs_deb_leave(LBS_DEB_WEXT);
}
-static int sendconfirmsleep(lbs_private *priv, u8 *cmdptr, u16 size)
+static int sendconfirmsleep(struct lbs_private *priv, u8 *cmdptr, u16 size)
{
unsigned long flags;
- lbs_adapter *adapter = priv->adapter;
+ struct lbs_adapter *adapter = priv->adapter;
int ret = 0;
lbs_deb_enter(LBS_DEB_HOST);
return ret;
}
-void lbs_ps_sleep(lbs_private * priv, int wait_option)
+void lbs_ps_sleep(struct lbs_private *priv, int wait_option)
{
lbs_deb_enter(LBS_DEB_HOST);
/**
* @brief This function sends Exit_PS command to firmware.
*
- * @param priv A pointer to lbs_private structure
+ * @param priv A pointer to struct lbs_private structure
* @param wait_option wait response or not
* @return n/a
*/
-void lbs_ps_wakeup(lbs_private * priv, int wait_option)
+void lbs_ps_wakeup(struct lbs_private *priv, int wait_option)
{
__le32 Localpsmode;
* @brief This function checks condition and prepares to
* send sleep confirm command to firmware if ok.
*
- * @param priv A pointer to lbs_private structure
+ * @param priv A pointer to struct lbs_private structure
* @param psmode Power Saving mode
* @return n/a
*/
-void lbs_ps_confirm_sleep(lbs_private * priv, u16 psmode)
+void lbs_ps_confirm_sleep(struct lbs_private *priv, u16 psmode)
{
unsigned long flags =0;
- lbs_adapter *adapter = priv->adapter;
+ struct lbs_adapter *adapter = priv->adapter;
u8 allowed = 1;
lbs_deb_enter(LBS_DEB_HOST);
lbs_deb_leave(LBS_DEB_HOST);
}
+
+
+/**
+ * @brief Simple way to call firmware functions
+ *
+ * @param priv A pointer to struct lbs_private structure
+ * @param psmode one of the many CMD_802_11_xxxx
+ * @param cmd pointer to the parameters structure for above command
+ * (this should not include the command, size, sequence
+ * and result fields from struct cmd_ds_gen)
+ * @param cmd_size size structure pointed to by cmd
+ * @param rsp pointer to an area where the result should be placed
+ * @param rsp_size pointer to the size of the rsp area. If the firmware
+ * returns fewer bytes, then this *rsp_size will be
+ * changed to the actual size.
+ * @return -1 in case of a higher level error, otherwise
+ * the result code from the firmware
+ */
+int lbs_cmd(struct lbs_private *priv,
+ u16 command,
+ void *cmd, int cmd_size,
+ void *rsp, int *rsp_size)
+{
+ struct lbs_adapter *adapter = priv->adapter;
+ struct cmd_ctrl_node *cmdnode;
+ struct cmd_ds_gen *cmdptr;
+ unsigned long flags;
+ int ret = 0;
+
+ lbs_deb_enter(LBS_DEB_HOST);
+ lbs_deb_host("rsp at %p, rsp_size at %p\n", rsp, rsp_size);
+
+ if (!adapter || !rsp_size) {
+ lbs_deb_host("PREP_CMD: adapter is NULL\n");
+ ret = -1;
+ goto done;
+ }
+
+ if (adapter->surpriseremoved) {
+ lbs_deb_host("PREP_CMD: card removed\n");
+ ret = -1;
+ goto done;
+ }
+
+ cmdnode = lbs_get_cmd_ctrl_node(priv);
+
+ if (cmdnode == NULL) {
+ lbs_deb_host("PREP_CMD: cmdnode is NULL\n");
+
+ /* Wake up main thread to execute next command */
+ wake_up_interruptible(&priv->waitq);
+ ret = -1;
+ goto done;
+ }
+
+ cmdptr = (struct cmd_ds_gen *)cmdnode->bufvirtualaddr;
+ cmdnode->wait_option = CMD_OPTION_WAITFORRSP;
+ cmdnode->pdata_buf = rsp;
+ cmdnode->pdata_size = rsp_size;
+
+ /* Set sequence number, clean result, move to buffer */
+ adapter->seqnum++;
+ cmdptr->command = cpu_to_le16(command);
+ cmdptr->size = cpu_to_le16(cmd_size + S_DS_GEN);
+ cmdptr->seqnum = cpu_to_le16(adapter->seqnum);
+ cmdptr->result = 0;
+ memcpy(cmdptr->cmdresp, cmd, cmd_size);
+
+ lbs_deb_host("PREP_CMD: command 0x%04x\n", command);
+
+ /* here was the big old switch() statement, which is now obsolete,
+ * because the caller of lbs_cmd() sets up all of *cmd for us. */
+
+ cmdnode->cmdwaitqwoken = 0;
+ lbs_queue_cmd(adapter, cmdnode, 1);
+ wake_up_interruptible(&priv->waitq);
+
+ might_sleep();
+ wait_event_interruptible(cmdnode->cmdwait_q, cmdnode->cmdwaitqwoken);
+
+ spin_lock_irqsave(&adapter->driver_lock, flags);
+ if (adapter->cur_cmd_retcode) {
+ lbs_deb_host("PREP_CMD: command failed with return code %d\n",
+ adapter->cur_cmd_retcode);
+ adapter->cur_cmd_retcode = 0;
+ ret = -1;
+ }
+ spin_unlock_irqrestore(&adapter->driver_lock, flags);
+
+done:
+ lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret);
+ return ret;
+}
+EXPORT_SYMBOL_GPL(lbs_cmd);
+
+