OSDN Git Service

iwlwifi: emliminate iwl3945_mac_get_stats mac80211 handler
[android-x86/kernel.git] / drivers / net / wireless / iwlwifi / iwl3945-base.c
index 3738ffa..667ea70 100644 (file)
@@ -53,6 +53,7 @@
 #include "iwl-3945.h"
 #include "iwl-3945-fh.h"
 #include "iwl-helpers.h"
+#include "iwl-dev.h"
 
 static int iwl3945_tx_queue_update_write_ptr(struct iwl3945_priv *priv,
                                  struct iwl3945_tx_queue *txq);
@@ -132,44 +133,17 @@ static const struct ieee80211_supported_band *iwl3945_get_band(
  * (#0-3) for data tx via EDCA.  An additional 2 HCCA queues are unused.
  ***************************************************/
 
-int iwl3945_queue_space(const struct iwl3945_queue *q)
-{
-       int s = q->read_ptr - q->write_ptr;
-
-       if (q->read_ptr > q->write_ptr)
-               s -= q->n_bd;
-
-       if (s <= 0)
-               s += q->n_window;
-       /* keep some reserve to not confuse empty and full situations */
-       s -= 2;
-       if (s < 0)
-               s = 0;
-       return s;
-}
-
-int iwl3945_x2_queue_used(const struct iwl3945_queue *q, int i)
+int iwl3945_x2_queue_used(const struct iwl_queue *q, int i)
 {
        return q->write_ptr > q->read_ptr ?
                (i >= q->read_ptr && i < q->write_ptr) :
                !(i < q->read_ptr && i >= q->write_ptr);
 }
 
-
-static inline u8 get_cmd_index(struct iwl3945_queue *q, u32 index, int is_huge)
-{
-       /* This is for scan command, the big buffer at end of command array */
-       if (is_huge)
-               return q->n_window;     /* must be power of 2 */
-
-       /* Otherwise, use normal size buffers */
-       return index & (q->n_window - 1);
-}
-
 /**
  * iwl3945_queue_init - Initialize queue's high/low-water and read/write indexes
  */
-static int iwl3945_queue_init(struct iwl3945_priv *priv, struct iwl3945_queue *q,
+static int iwl3945_queue_init(struct iwl3945_priv *priv, struct iwl_queue *q,
                          int count, int slots_num, u32 id)
 {
        q->n_bd = count;
@@ -297,7 +271,7 @@ int iwl3945_tx_queue_init(struct iwl3945_priv *priv,
  */
 void iwl3945_tx_queue_free(struct iwl3945_priv *priv, struct iwl3945_tx_queue *txq)
 {
-       struct iwl3945_queue *q = &txq->q;
+       struct iwl_queue *q = &txq->q;
        struct pci_dev *dev = priv->pci_dev;
        int len;
 
@@ -581,7 +555,7 @@ static const char *get_cmd_string(u8 cmd)
 static int iwl3945_enqueue_hcmd(struct iwl3945_priv *priv, struct iwl3945_host_cmd *cmd)
 {
        struct iwl3945_tx_queue *txq = &priv->txq[IWL_CMD_QUEUE_NUM];
-       struct iwl3945_queue *q = &txq->q;
+       struct iwl_queue *q = &txq->q;
        struct iwl3945_tfd_frame *tfd;
        u32 *control_flags;
        struct iwl3945_cmd *out_cmd;
@@ -596,7 +570,7 @@ static int iwl3945_enqueue_hcmd(struct iwl3945_priv *priv, struct iwl3945_host_c
        /* If any of the command structures end up being larger than
         * the TFD_MAX_PAYLOAD_SIZE, and it sent as a 'small' command then
         * we will need to increase the size of the TFD entries */
-       BUG_ON((fix_size > TFD_MAX_PAYLOAD_SIZE) &&
+       BUG_ON((fix_size > TFD39_MAX_PAYLOAD_SIZE) &&
               !(cmd->meta.flags & CMD_SIZE_HUGE));
 
 
@@ -605,7 +579,7 @@ static int iwl3945_enqueue_hcmd(struct iwl3945_priv *priv, struct iwl3945_host_c
                return -EIO;
        }
 
-       if (iwl3945_queue_space(q) < ((cmd->meta.flags & CMD_ASYNC) ? 2 : 1)) {
+       if (iwl_queue_space(q) < ((cmd->meta.flags & CMD_ASYNC) ? 2 : 1)) {
                IWL_ERROR("No space for Tx\n");
                return -ENOSPC;
        }
@@ -1815,7 +1789,7 @@ static void iwl3945_activate_qos(struct iwl3945_priv *priv, u8 force)
 
 /* default power management (not Tx power) table values */
 /* for TIM  0-10 */
-static struct iwl3945_power_vec_entry range_0[IWL_POWER_AC] = {
+static struct iwl_power_vec_entry range_0[IWL39_POWER_AC] = {
        {{NOSLP, SLP_TIMEOUT(0), SLP_TIMEOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0},
        {{SLP, SLP_TIMEOUT(200), SLP_TIMEOUT(500), SLP_VEC(1, 2, 3, 4, 4)}, 0},
        {{SLP, SLP_TIMEOUT(200), SLP_TIMEOUT(300), SLP_VEC(2, 4, 6, 7, 7)}, 0},
@@ -1825,7 +1799,7 @@ static struct iwl3945_power_vec_entry range_0[IWL_POWER_AC] = {
 };
 
 /* for TIM > 10 */
-static struct iwl3945_power_vec_entry range_1[IWL_POWER_AC] = {
+static struct iwl_power_vec_entry range_1[IWL39_POWER_AC] = {
        {{NOSLP, SLP_TIMEOUT(0), SLP_TIMEOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0},
        {{SLP, SLP_TIMEOUT(200), SLP_TIMEOUT(500),
                 SLP_VEC(1, 2, 3, 4, 0xFF)}, 0},
@@ -1842,7 +1816,7 @@ int iwl3945_power_init_handle(struct iwl3945_priv *priv)
 {
        int rc = 0, i;
        struct iwl3945_power_mgr *pow_data;
-       int size = sizeof(struct iwl3945_power_vec_entry) * IWL_POWER_AC;
+       int size = sizeof(struct iwl_power_vec_entry) * IWL39_POWER_AC;
        u16 pci_pm;
 
        IWL_DEBUG_POWER("Initialize power \n");
@@ -1865,7 +1839,7 @@ int iwl3945_power_init_handle(struct iwl3945_priv *priv)
 
                IWL_DEBUG_POWER("adjust power command flags\n");
 
-               for (i = 0; i < IWL_POWER_AC; i++) {
+               for (i = 0; i < IWL39_POWER_AC; i++) {
                        cmd = &pow_data->pwr_range_0[i].cmd;
 
                        if (pci_pm & 0x1)
@@ -1883,7 +1857,7 @@ static int iwl3945_update_power_cmd(struct iwl3945_priv *priv,
        int rc = 0, i;
        u8 skip;
        u32 max_sleep = 0;
-       struct iwl3945_power_vec_entry *range;
+       struct iwl_power_vec_entry *range;
        u8 period = 0;
        struct iwl3945_power_mgr *pow_data;
 
@@ -1951,10 +1925,10 @@ static int iwl3945_send_power_mode(struct iwl3945_priv *priv, u32 mode)
         * if plugged into AC power, set to CAM ("continuously aware mode"),
         * else user level */
        switch (mode) {
-       case IWL_POWER_BATTERY:
+       case IWL39_POWER_BATTERY:
                final_mode = IWL_POWER_INDEX_3;
                break;
-       case IWL_POWER_AC:
+       case IWL39_POWER_AC:
                final_mode = IWL_POWER_MODE_CAM;
                break;
        default:
@@ -2171,7 +2145,7 @@ static void iwl3945_set_flags_for_phymode(struct iwl3945_priv *priv,
 static void iwl3945_connection_init_rx_config(struct iwl3945_priv *priv,
                                              int mode)
 {
-       const struct iwl3945_channel_info *ch_info;
+       const struct iwl_channel_info *ch_info;
 
        memset(&priv->staging_rxon, 0, sizeof(priv->staging_rxon));
 
@@ -2241,7 +2215,7 @@ static void iwl3945_connection_init_rx_config(struct iwl3945_priv *priv,
 static int iwl3945_set_mode(struct iwl3945_priv *priv, int mode)
 {
        if (mode == NL80211_IFTYPE_ADHOC) {
-               const struct iwl3945_channel_info *ch_info;
+               const struct iwl_channel_info *ch_info;
 
                ch_info = iwl3945_get_channel_info(priv,
                        priv->band,
@@ -2457,7 +2431,7 @@ static int iwl3945_tx_skb(struct iwl3945_priv *priv, struct sk_buff *skb)
        u32 *control_flags;
        int txq_id = skb_get_queue_mapping(skb);
        struct iwl3945_tx_queue *txq = NULL;
-       struct iwl3945_queue *q = NULL;
+       struct iwl_queue *q = NULL;
        dma_addr_t phys_addr;
        dma_addr_t txcmd_phys;
        struct iwl3945_cmd *out_cmd = NULL;
@@ -2652,7 +2626,7 @@ static int iwl3945_tx_skb(struct iwl3945_priv *priv, struct sk_buff *skb)
        if (rc)
                return rc;
 
-       if ((iwl3945_queue_space(q) < q->high_mark)
+       if ((iwl_queue_space(q) < q->high_mark)
            && priv->mac80211_registered) {
                if (wait_write_ptr) {
                        spin_lock_irqsave(&priv->lock, flags);
@@ -3305,7 +3279,7 @@ static void iwl3945_cmd_queue_reclaim(struct iwl3945_priv *priv,
                                      int txq_id, int index)
 {
        struct iwl3945_tx_queue *txq = &priv->txq[txq_id];
-       struct iwl3945_queue *q = &txq->q;
+       struct iwl_queue *q = &txq->q;
        int nfreed = 0;
 
        if ((index >= q->n_bd) || (iwl3945_x2_queue_used(q, index) == 0)) {
@@ -4524,8 +4498,9 @@ static void iwl3945_init_band_reference(const struct iwl3945_priv *priv, int ban
  *
  * Based on band and channel number.
  */
-const struct iwl3945_channel_info *iwl3945_get_channel_info(const struct iwl3945_priv *priv,
-                                                   enum ieee80211_band band, u16 channel)
+const struct iwl_channel_info *
+iwl3945_get_channel_info(const struct iwl3945_priv *priv,
+                        enum ieee80211_band band, u16 channel)
 {
        int i;
 
@@ -4560,7 +4535,7 @@ static int iwl3945_init_channel_map(struct iwl3945_priv *priv)
        const u8 *eeprom_ch_index = NULL;
        const struct iwl_eeprom_channel *eeprom_ch_info = NULL;
        int band, ch;
-       struct iwl3945_channel_info *ch_info;
+       struct iwl_channel_info *ch_info;
 
        if (priv->channel_count) {
                IWL_DEBUG_INFO("Channel map already initialized.\n");
@@ -4584,7 +4559,7 @@ static int iwl3945_init_channel_map(struct iwl3945_priv *priv)
 
        IWL_DEBUG_INFO("Parsing data for %d channels.\n", priv->channel_count);
 
-       priv->channel_info = kzalloc(sizeof(struct iwl3945_channel_info) *
+       priv->channel_info = kzalloc(sizeof(struct iwl_channel_info) *
                                     priv->channel_count, GFP_KERNEL);
        if (!priv->channel_info) {
                IWL_ERROR("Could not allocate channel_info\n");
@@ -4746,7 +4721,7 @@ static int iwl3945_get_channels_for_scan(struct iwl3945_priv *priv,
 {
        const struct ieee80211_channel *channels = NULL;
        const struct ieee80211_supported_band *sband;
-       const struct iwl3945_channel_info *ch_info;
+       const struct iwl_channel_info *ch_info;
        u16 passive_dwell = 0;
        u16 active_dwell = 0;
        int added, i;
@@ -4843,7 +4818,7 @@ static void iwl3945_init_hw_rates(struct iwl3945_priv *priv,
                rates[i].hw_value = i; /* Rate scaling will work on indexes */
                rates[i].hw_value_short = i;
                rates[i].flags = 0;
-               if ((i > IWL_LAST_OFDM_RATE) || (i < IWL_FIRST_OFDM_RATE)) {
+               if ((i > IWL39_LAST_OFDM_RATE) || (i < IWL_FIRST_OFDM_RATE)) {
                        /*
                         * If CCK != 1M then set short preamble rate flag.
                         */
@@ -4858,7 +4833,7 @@ static void iwl3945_init_hw_rates(struct iwl3945_priv *priv,
  */
 static int iwl3945_init_geos(struct iwl3945_priv *priv)
 {
-       struct iwl3945_channel_info *ch;
+       struct iwl_channel_info *ch;
        struct ieee80211_supported_band *sband;
        struct ieee80211_channel *channels;
        struct ieee80211_channel *geo_ch;
@@ -6585,7 +6560,7 @@ static int iwl3945_mac_add_interface(struct ieee80211_hw *hw,
 static int iwl3945_mac_config(struct ieee80211_hw *hw, u32 changed)
 {
        struct iwl3945_priv *priv = hw->priv;
-       const struct iwl3945_channel_info *ch_info;
+       const struct iwl_channel_info *ch_info;
        struct ieee80211_conf *conf = &hw->conf;
        unsigned long flags;
        int ret = 0;
@@ -7112,7 +7087,7 @@ static int iwl3945_mac_get_tx_stats(struct ieee80211_hw *hw,
        struct iwl3945_priv *priv = hw->priv;
        int i, avail;
        struct iwl3945_tx_queue *txq;
-       struct iwl3945_queue *q;
+       struct iwl_queue *q;
        unsigned long flags;
 
        IWL_DEBUG_MAC80211("enter\n");
@@ -7127,7 +7102,7 @@ static int iwl3945_mac_get_tx_stats(struct ieee80211_hw *hw,
        for (i = 0; i < AC_NUM; i++) {
                txq = &priv->txq[i];
                q = &txq->q;
-               avail = iwl3945_queue_space(q);
+               avail = iwl_queue_space(q);
 
                stats[i].len = q->n_window - avail;
                stats[i].limit = q->n_window - q->high_mark;
@@ -7141,12 +7116,6 @@ static int iwl3945_mac_get_tx_stats(struct ieee80211_hw *hw,
        return 0;
 }
 
-static int iwl3945_mac_get_stats(struct ieee80211_hw *hw,
-                            struct ieee80211_low_level_stats *stats)
-{
-       return 0;
-}
-
 static void iwl3945_mac_reset_tsf(struct ieee80211_hw *hw)
 {
        struct iwl3945_priv *priv = hw->priv;
@@ -7511,8 +7480,9 @@ static ssize_t store_power_level(struct device *d,
                goto out;
        }
 
-       if ((mode < 1) || (mode > IWL_POWER_LIMIT) || (mode == IWL_POWER_AC))
-               mode = IWL_POWER_AC;
+       if ((mode < 1) || (mode > IWL39_POWER_LIMIT) ||
+           (mode == IWL39_POWER_AC))
+               mode = IWL39_POWER_AC;
        else
                mode |= IWL_POWER_ENABLED;
 
@@ -7560,10 +7530,10 @@ static ssize_t show_power_level(struct device *d,
        p += sprintf(p, "%d ", level);
        switch (level) {
        case IWL_POWER_MODE_CAM:
-       case IWL_POWER_AC:
+       case IWL39_POWER_AC:
                p += sprintf(p, "(AC)");
                break;
-       case IWL_POWER_BATTERY:
+       case IWL39_POWER_BATTERY:
                p += sprintf(p, "(BATTERY)");
                break;
        default:
@@ -7786,7 +7756,6 @@ static struct ieee80211_ops iwl3945_hw_ops = {
        .config_interface = iwl3945_mac_config_interface,
        .configure_filter = iwl3945_configure_filter,
        .set_key = iwl3945_mac_set_key,
-       .get_stats = iwl3945_mac_get_stats,
        .get_tx_stats = iwl3945_mac_get_tx_stats,
        .conf_tx = iwl3945_mac_conf_tx,
        .reset_tsf = iwl3945_mac_reset_tsf,
@@ -7968,7 +7937,7 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
 
        priv->rates_mask = IWL_RATES_MASK;
        /* If power management is turned on, default to AC mode */
-       priv->power_mode = IWL_POWER_AC;
+       priv->power_mode = IWL39_POWER_AC;
        priv->user_txpower_limit = IWL_DEFAULT_TX_POWER;
 
        err = iwl3945_init_channel_map(priv);