iwl3945: Remaining host command cleanups
authorSamuel Ortiz <samuel.ortiz@intel.com>
Fri, 23 Jan 2009 21:45:20 +0000 (13:45 -0800)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 29 Jan 2009 21:01:37 +0000 (16:01 -0500)
With the recent host command routines merge, we can now look at the various
host command helpers and get rid of the duplicated ones.

Signed-off-by: Samuel Ortiz <samuel.ortiz@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/iwlwifi/iwl-3945.c
drivers/net/wireless/iwlwifi/iwl-3945.h
drivers/net/wireless/iwlwifi/iwl-agn.c
drivers/net/wireless/iwlwifi/iwl-core.c
drivers/net/wireless/iwlwifi/iwl-core.h
drivers/net/wireless/iwlwifi/iwl-scan.c
drivers/net/wireless/iwlwifi/iwl-sta.c
drivers/net/wireless/iwlwifi/iwl-sta.h
drivers/net/wireless/iwlwifi/iwl3945-base.c

index 7f1e04205f30eb01f8d2da7d67f713d014c5f4a8..12f93b6207d6b90b49c491591793d4daf7889c42 100644 (file)
@@ -41,6 +41,7 @@
 #include "iwl-fh.h"
 #include "iwl-3945-fh.h"
 #include "iwl-commands.h"
+#include "iwl-sta.h"
 #include "iwl-3945.h"
 #include "iwl-eeprom.h"
 #include "iwl-helpers.h"
@@ -895,7 +896,8 @@ u8 iwl3945_sync_sta(struct iwl_priv *priv, int sta_id, u16 tx_rate, u8 flags)
 
        spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
 
-       iwl3945_send_add_station(priv, &station->sta, flags);
+       iwl_send_add_sta(priv,
+                        (struct iwl_addsta_cmd *)&station->sta, flags);
        IWL_DEBUG_RATE("SCALE sync station %d to rate %d\n",
                        sta_id, tx_rate);
        return sta_id;
@@ -2376,6 +2378,13 @@ static u16 iwl3945_get_hcmd_size(u8 cmd_id, u16 len)
        }
 }
 
+static u16 iwl3945_build_addsta_hcmd(const struct iwl_addsta_cmd *cmd, u8 *data)
+{
+       u16 size = (u16)sizeof(struct iwl3945_addsta_cmd);
+       memcpy(data, cmd, size);
+       return size;
+}
+
 /**
  * iwl3945_init_hw_rate_table - Initialize the hardware rate fallback table
  */
@@ -2743,6 +2752,7 @@ static struct iwl_lib_ops iwl3945_lib = {
 
 static struct iwl_hcmd_utils_ops iwl3945_hcmd_utils = {
        .get_hcmd_size = iwl3945_get_hcmd_size,
+       .build_addsta_hcmd = iwl3945_build_addsta_hcmd,
 };
 
 static struct iwl_ops iwl3945_ops = {
index 77e97eaa4e4e9ddaba31cf5898474665ba9d99cb..fef54e9cf8a8ccd3a921d56243bb5788e62809ba 100644 (file)
@@ -222,7 +222,6 @@ extern int __must_check iwl3945_send_cmd(struct iwl_priv *priv,
                                         struct iwl_host_cmd *cmd);
 extern unsigned int iwl3945_fill_beacon_frame(struct iwl_priv *priv,
                                        struct ieee80211_hdr *hdr,int left);
-extern int iwl3945_send_statistics_request(struct iwl_priv *priv);
 extern void iwl3945_set_decrypted_flag(struct iwl_priv *priv, struct sk_buff *skb,
                                   u32 decrypt_res,
                                   struct ieee80211_rx_status *stats);
index 5c6b3fe3eedfb6197a0c67b21a3ae96fa02fa47d..757a9bd3ecd6a8830d641acd92fbc3270d1b1c74 100644 (file)
@@ -310,20 +310,6 @@ void iwl_update_chain_flags(struct iwl_priv *priv)
        iwl_commit_rxon(priv);
 }
 
-static int iwl_send_bt_config(struct iwl_priv *priv)
-{
-       struct iwl_bt_cmd bt_cmd = {
-               .flags = 3,
-               .lead_time = 0xAA,
-               .max_kill = 1,
-               .kill_ack_mask = 0,
-               .kill_cts_mask = 0,
-       };
-
-       return iwl_send_cmd_pdu(priv, REPLY_BT_CONFIG,
-                               sizeof(struct iwl_bt_cmd), &bt_cmd);
-}
-
 static void iwl_clear_free_frames(struct iwl_priv *priv)
 {
        struct list_head *element;
index 902b75f25ea55587d5b8e042662e7a8d7498572a..21f386568c9c1957e38e3afb6c8410a96d122b52 100644 (file)
@@ -1007,6 +1007,21 @@ void iwl_enable_interrupts(struct iwl_priv *priv)
 }
 EXPORT_SYMBOL(iwl_enable_interrupts);
 
+int iwl_send_bt_config(struct iwl_priv *priv)
+{
+       struct iwl_bt_cmd bt_cmd = {
+               .flags = 3,
+               .lead_time = 0xAA,
+               .max_kill = 1,
+               .kill_ack_mask = 0,
+               .kill_cts_mask = 0,
+       };
+
+       return iwl_send_cmd_pdu(priv, REPLY_BT_CONFIG,
+                               sizeof(struct iwl_bt_cmd), &bt_cmd);
+}
+EXPORT_SYMBOL(iwl_send_bt_config);
+
 int iwl_send_statistics_request(struct iwl_priv *priv, u8 flags)
 {
        u32 stat_flags = 0;
index 0c6250cd51dbe4cb5dfe22dd2f80645d91df2650..c8e1dad6fb54cc76780a8c382215e21d06214b31 100644 (file)
@@ -335,6 +335,7 @@ void iwl_bg_scan_check(struct work_struct *data);
 void iwl_bg_abort_scan(struct work_struct *work);
 void iwl_bg_scan_completed(struct work_struct *work);
 void iwl_setup_scan_deferred_work(struct iwl_priv *priv);
+int iwl_send_scan_abort(struct iwl_priv *priv);
 
 /* For faster active scanning, scan will move to the next channel if fewer than
  * PLCP_QUIET_THRESH packets are heard on this channel within
@@ -468,6 +469,7 @@ static inline int iwl_is_ready_rf(struct iwl_priv *priv)
 }
 
 extern void iwl_rf_kill_ct_config(struct iwl_priv *priv);
+extern int iwl_send_bt_config(struct iwl_priv *priv);
 extern int iwl_send_statistics_request(struct iwl_priv *priv, u8 flags);
 extern int iwl_verify_ucode(struct iwl_priv *priv);
 extern int iwl_send_lq_cmd(struct iwl_priv *priv,
index 0ce122a1734161e06e6b3a675e52cfb89e0e8b11..c282d1d294e6208bb4fa04efe43016d1df743004 100644 (file)
@@ -109,7 +109,7 @@ int iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms)
 }
 EXPORT_SYMBOL(iwl_scan_cancel_timeout);
 
-static int iwl_send_scan_abort(struct iwl_priv *priv)
+int iwl_send_scan_abort(struct iwl_priv *priv)
 {
        int ret = 0;
        struct iwl_rx_packet *res;
@@ -150,7 +150,7 @@ static int iwl_send_scan_abort(struct iwl_priv *priv)
 
        return ret;
 }
-
+EXPORT_SYMBOL(iwl_send_scan_abort);
 
 /* Service response to REPLY_SCAN_CMD (0x80) */
 static void iwl_rx_reply_scan(struct iwl_priv *priv,
index 0cbb4495c062fc1c40a6015ef01ab37fc88e79ee..9bba98e5e056d24f1474e7dd83d1533a7430f5b4 100644 (file)
@@ -86,7 +86,8 @@ static void iwl_sta_ucode_activate(struct iwl_priv *priv, u8 sta_id)
 
        spin_lock_irqsave(&priv->sta_lock, flags);
 
-       if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE))
+       if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE) &&
+           !(priv->stations_39[sta_id].used & IWL_STA_DRIVER_ACTIVE))
                IWL_ERR(priv, "ACTIVATE a non DRIVER active station %d\n",
                        sta_id);
 
@@ -131,7 +132,7 @@ static int iwl_add_sta_callback(struct iwl_priv *priv,
        return 1;
 }
 
-static int iwl_send_add_sta(struct iwl_priv *priv,
+int iwl_send_add_sta(struct iwl_priv *priv,
                     struct iwl_addsta_cmd *sta, u8 flags)
 {
        struct iwl_rx_packet *res = NULL;
@@ -179,6 +180,7 @@ static int iwl_send_add_sta(struct iwl_priv *priv,
 
        return ret;
 }
+EXPORT_SYMBOL(iwl_send_add_sta);
 
 static void iwl_set_ht_add_station(struct iwl_priv *priv, u8 index,
                                   struct ieee80211_sta_ht_cap *sta_ht_inf)
index 3fe7cc575fa63ae19d353be6da17cfec9a1f7c5d..97f6169007f8f282f75f082f2e03a70507b98db5 100644 (file)
@@ -56,6 +56,8 @@ int iwl_remove_station(struct iwl_priv *priv, const u8 *addr, int is_ap);
 void iwl_clear_stations_table(struct iwl_priv *priv);
 int iwl_get_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr);
 int iwl_get_ra_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr);
+int iwl_send_add_sta(struct iwl_priv *priv,
+                    struct iwl_addsta_cmd *sta, u8 flags);
 u8 iwl_add_station_flags(struct iwl_priv *priv, const u8 *addr,
                        int is_ap, u8 flags,
                        struct ieee80211_sta_ht_cap *ht_info);
index 13fb61851845bb0671c1a3aa2ec856092cd8fef7..d09325591de00d465c1faaea681e82a8fcfc5275 100644 (file)
@@ -51,6 +51,7 @@
 #include "iwl-fh.h"
 #include "iwl-3945-fh.h"
 #include "iwl-commands.h"
+#include "iwl-sta.h"
 #include "iwl-3945.h"
 #include "iwl-helpers.h"
 #include "iwl-core.h"
@@ -226,24 +227,12 @@ u8 iwl3945_add_station(struct iwl_priv *priv, const u8 *addr, int is_ap, u8 flag
        spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
 
        /* Add station to device's station table */
-       iwl3945_send_add_station(priv, &station->sta, flags);
+       iwl_send_add_sta(priv,
+                        (struct iwl_addsta_cmd *)&station->sta, flags);
        return index;
 
 }
 
-int iwl3945_send_statistics_request(struct iwl_priv *priv)
-{
-       u32 val = 0;
-
-       struct iwl_host_cmd cmd = {
-               .id = REPLY_STATISTICS_CMD,
-               .len = sizeof(val),
-               .data = &val,
-       };
-
-       return iwl_send_cmd_sync(priv, &cmd);
-}
-
 /**
  * iwl3945_set_rxon_channel - Set the phymode and channel values in staging RXON
  * @band: 2.4 or 5 GHz band
@@ -611,95 +600,6 @@ static int iwl3945_commit_rxon(struct iwl_priv *priv)
        return 0;
 }
 
-static int iwl3945_send_bt_config(struct iwl_priv *priv)
-{
-       struct iwl_bt_cmd bt_cmd = {
-               .flags = 3,
-               .lead_time = 0xAA,
-               .max_kill = 1,
-               .kill_ack_mask = 0,
-               .kill_cts_mask = 0,
-       };
-
-       return iwl_send_cmd_pdu(priv, REPLY_BT_CONFIG,
-                                       sizeof(bt_cmd), &bt_cmd);
-}
-
-static int iwl3945_add_sta_sync_callback(struct iwl_priv *priv,
-                                    struct iwl_cmd *cmd, struct sk_buff *skb)
-{
-       struct iwl_rx_packet *res = NULL;
-
-       if (!skb) {
-               IWL_ERR(priv, "Error: Response NULL in REPLY_ADD_STA.\n");
-               return 1;
-       }
-
-       res = (struct iwl_rx_packet *)skb->data;
-       if (res->hdr.flags & IWL_CMD_FAILED_MSK) {
-               IWL_ERR(priv, "Bad return from REPLY_ADD_STA (0x%08X)\n",
-                         res->hdr.flags);
-               return 1;
-       }
-
-       switch (res->u.add_sta.status) {
-       case ADD_STA_SUCCESS_MSK:
-               break;
-       default:
-               break;
-       }
-
-       /* We didn't cache the SKB; let the caller free it */
-       return 1;
-}
-
-int iwl3945_send_add_station(struct iwl_priv *priv,
-                        struct iwl3945_addsta_cmd *sta, u8 flags)
-{
-       struct iwl_rx_packet *res = NULL;
-       int rc = 0;
-       struct iwl_host_cmd cmd = {
-               .id = REPLY_ADD_STA,
-               .len = sizeof(struct iwl3945_addsta_cmd),
-               .meta.flags = flags,
-               .data = sta,
-       };
-
-       if (flags & CMD_ASYNC)
-               cmd.meta.u.callback = iwl3945_add_sta_sync_callback;
-       else
-               cmd.meta.flags |= CMD_WANT_SKB;
-
-       rc = iwl_send_cmd(priv, &cmd);
-
-       if (rc || (flags & CMD_ASYNC))
-               return rc;
-
-       res = (struct iwl_rx_packet *)cmd.meta.u.skb->data;
-       if (res->hdr.flags & IWL_CMD_FAILED_MSK) {
-               IWL_ERR(priv, "Bad return from REPLY_ADD_STA (0x%08X)\n",
-                         res->hdr.flags);
-               rc = -EIO;
-       }
-
-       if (rc == 0) {
-               switch (res->u.add_sta.status) {
-               case ADD_STA_SUCCESS_MSK:
-                       IWL_DEBUG_INFO("REPLY_ADD_STA PASSED\n");
-                       break;
-               default:
-                       rc = -EIO;
-                       IWL_WARN(priv, "REPLY_ADD_STA failed\n");
-                       break;
-               }
-       }
-
-       priv->alloc_rxb_skb--;
-       dev_kfree_skb_any(cmd.meta.u.skb);
-
-       return rc;
-}
-
 static int iwl3945_update_sta_key_info(struct iwl_priv *priv,
                                   struct ieee80211_key_conf *keyconf,
                                   u8 sta_id)
@@ -734,7 +634,8 @@ static int iwl3945_update_sta_key_info(struct iwl_priv *priv,
        spin_unlock_irqrestore(&priv->sta_lock, flags);
 
        IWL_DEBUG_INFO("hwcrypto: modify ucode station key info\n");
-       iwl3945_send_add_station(priv, &priv->stations_39[sta_id].sta, 0);
+       iwl_send_add_sta(priv,
+               (struct iwl_addsta_cmd *)&priv->stations_39[sta_id].sta, 0);
        return 0;
 }
 
@@ -752,7 +653,8 @@ static int iwl3945_clear_sta_key_info(struct iwl_priv *priv, u8 sta_id)
        spin_unlock_irqrestore(&priv->sta_lock, flags);
 
        IWL_DEBUG_INFO("hwcrypto: clear ucode station key info\n");
-       iwl3945_send_add_station(priv, &priv->stations_39[sta_id].sta, 0);
+       iwl_send_add_sta(priv,
+               (struct iwl_addsta_cmd *)&priv->stations_39[sta_id].sta, 0);
        return 0;
 }
 
@@ -4005,7 +3907,7 @@ static void iwl3945_alive_start(struct iwl_priv *priv)
        }
 
        /* Configure Bluetooth device coexistence support */
-       iwl3945_send_bt_config(priv);
+       iwl_send_bt_config(priv);
 
        /* Configure the adapter for unassociated operation */
        iwl3945_commit_rxon(priv);
@@ -5810,7 +5712,7 @@ static ssize_t show_statistics(struct device *d,
                return -EAGAIN;
 
        mutex_lock(&priv->mutex);
-       rc = iwl3945_send_statistics_request(priv);
+       rc = iwl_send_statistics_request(priv, 0);
        mutex_unlock(&priv->mutex);
 
        if (rc) {