]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/wireless/libertas/cmd.c
libertas: Byteswap cmdptr->size in lbs_cmd()
[linux-2.6-omap-h63xx.git] / drivers / net / wireless / libertas / cmd.c
index 3702c5da1f6f8bcdf96127b7f6904a2a5a2139af..7097dcf7abc8289db6c10806f3b37360cd3f4117 100644 (file)
 #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,
@@ -37,7 +42,7 @@ static u8 is_command_allowed_in_ps(__le16 command)
        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;
 
@@ -51,7 +56,7 @@ static int lbs_cmd_hw_spec(lbs_private * priv, struct cmd_ds_command *cmd)
        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)
 {
@@ -90,7 +95,7 @@ static int lbs_cmd_802_11_ps_mode(lbs_private * priv,
        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)
 {
@@ -114,11 +119,11 @@ static int lbs_cmd_802_11_inactivity_timeout(lbs_private * priv,
        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);
@@ -145,13 +150,13 @@ static int lbs_cmd_802_11_sleep_params(lbs_private * priv,
        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;
 
@@ -219,7 +224,7 @@ done:
        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)
@@ -246,6 +251,52 @@ static int lbs_cmd_802_11_enable_rsn(lbs_private * priv,
 }
 
 
+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)
 {
@@ -272,7 +323,7 @@ static void set_one_wpa_key(struct MrvlIEtype_keyParamSet * pkeyparamset,
        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)
@@ -319,7 +370,7 @@ done:
        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;
@@ -334,7 +385,7 @@ static int lbs_cmd_802_11_reset(lbs_private * priv,
        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);
@@ -346,7 +397,7 @@ static int lbs_cmd_802_11_get_log(lbs_private * priv,
        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);
@@ -358,13 +409,13 @@ static int lbs_cmd_802_11_get_stat(lbs_private * priv,
        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);
@@ -479,11 +530,11 @@ static int lbs_cmd_802_11_snmp_mib(lbs_private * priv,
        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);
@@ -519,7 +570,7 @@ static int lbs_cmd_802_11_radio_control(lbs_private * priv,
        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)
 {
@@ -563,7 +614,7 @@ static int lbs_cmd_802_11_rf_tx_power(lbs_private * priv,
        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)
 {
@@ -583,13 +634,13 @@ static int lbs_cmd_802_11_monitor_mode(lbs_private * priv,
        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 =
@@ -605,12 +656,12 @@ static int lbs_cmd_802_11_rate_adapt_rateset(lbs_private * priv,
        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);
 
@@ -632,12 +683,12 @@ static int lbs_cmd_802_11_data_rate(lbs_private * priv,
        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) +
@@ -655,7 +706,7 @@ static int lbs_cmd_mac_multicast_adr(lbs_private * priv,
        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)
 {
@@ -676,10 +727,10 @@ static int lbs_cmd_802_11_rf_channel(lbs_private * priv,
        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);
@@ -698,7 +749,7 @@ static int lbs_cmd_802_11_rssi(lbs_private * priv,
        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)
 {
@@ -773,11 +824,11 @@ static int lbs_cmd_reg_access(lbs_private * priv,
        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);
@@ -797,7 +848,7 @@ static int lbs_cmd_802_11_mac_address(lbs_private * priv,
        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)
 {
@@ -819,7 +870,7 @@ static int lbs_cmd_802_11_eeprom_access(lbs_private * priv,
        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)
 {
@@ -857,7 +908,7 @@ static int lbs_cmd_bt_access(lbs_private * priv,
        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)
 {
@@ -879,7 +930,7 @@ static int lbs_cmd_fwt_access(lbs_private * priv,
        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)
 {
@@ -923,7 +974,7 @@ static int lbs_cmd_bcn_ctrl(struct lbs_private * priv,
        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)
 {
@@ -938,7 +989,9 @@ static int lbs_cmd_set_boot2_ver(lbs_private * priv,
  * 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;
@@ -990,12 +1043,12 @@ done:
  * 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;
@@ -1060,7 +1113,7 @@ done:
        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;
@@ -1082,9 +1135,10 @@ static int lbs_cmd_mac_control(lbs_private * priv,
  *  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;
@@ -1093,7 +1147,8 @@ void __lbs_cleanup_and_insert_cmd(lbs_private * priv, struct cmd_ctrl_node *ptem
        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;
 
@@ -1102,7 +1157,7 @@ static void lbs_cleanup_and_insert_cmd(lbs_private * priv, struct cmd_ctrl_node
        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;
 
@@ -1120,7 +1175,7 @@ int lbs_set_radio_control(lbs_private * priv)
        return ret;
 }
 
-int lbs_set_mac_packet_filter(lbs_private * priv)
+int lbs_set_mac_packet_filter(struct lbs_private *priv)
 {
        int ret = 0;
 
@@ -1137,7 +1192,7 @@ int lbs_set_mac_packet_filter(lbs_private * priv)
 /**
  *  @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
@@ -1145,13 +1200,13 @@ int lbs_set_mac_packet_filter(lbs_private * priv)
  *  @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;
@@ -1170,7 +1225,7 @@ int lbs_prepare_and_send_command(lbs_private * priv,
                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");
@@ -1181,7 +1236,7 @@ int lbs_prepare_and_send_command(lbs_private * priv,
                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;
 
@@ -1354,7 +1409,7 @@ int lbs_prepare_and_send_command(lbs_private * priv,
        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:
@@ -1390,6 +1445,10 @@ int lbs_prepare_and_send_command(lbs_private * priv,
                        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 =
@@ -1470,17 +1529,17 @@ EXPORT_SYMBOL_GPL(lbs_prepare_and_send_command);
  *  @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);
 
@@ -1522,15 +1581,15 @@ done:
 /**
  *  @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);
 
@@ -1566,13 +1625,13 @@ done:
  *  @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);
@@ -1613,10 +1672,9 @@ static void cleanup_cmdnode(struct cmd_ctrl_node *ptempnode)
                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);
@@ -1627,25 +1685,24 @@ static void cleanup_cmdnode(struct cmd_ctrl_node *ptempnode)
 /**
  *  @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);
 }
@@ -1655,12 +1712,12 @@ void lbs_set_cmd_ctrl_node(lbs_private * priv,
  *  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;
@@ -1807,7 +1864,7 @@ done:
        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];
@@ -1831,10 +1888,10 @@ void lbs_send_iwevcustom_event(lbs_private *priv, s8 *str)
        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);
@@ -1873,7 +1930,7 @@ static int sendconfirmsleep(lbs_private *priv, u8 *cmdptr, u16 size)
        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);
 
@@ -1891,11 +1948,11 @@ void lbs_ps_sleep(lbs_private * priv, int wait_option)
 /**
  *  @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;
 
@@ -1914,14 +1971,14 @@ void lbs_ps_wakeup(lbs_private * priv, int wait_option)
  *  @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);
@@ -1952,3 +2009,99 @@ void lbs_ps_confirm_sleep(lbs_private * priv, u16 psmode)
 
        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);
+
+