]> Pileus Git - ~andy/linux/blobdiff - drivers/net/wireless/iwlegacy/iwl3945-base.c
iwlegacy: s/index/idx/
[~andy/linux] / drivers / net / wireless / iwlegacy / iwl3945-base.c
index 5037216041ca5113346c584db1e98a98d7140e35..924420870a2f5146d43040d39bb7f0bb908009ca 100644 (file)
@@ -68,7 +68,7 @@
 #define DRV_DESCRIPTION        \
 "Intel(R) PRO/Wireless 3945ABG/BG Network Connection driver for Linux"
 
-#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
+#ifdef CONFIG_IWLEGACY_DEBUG
 #define VD "d"
 #else
 #define VD
@@ -144,7 +144,7 @@ static int il3945_set_ccmp_dynamic_key_info(struct il_priv *il,
        key_flags |= (STA_KEY_FLG_CCMP | STA_KEY_FLG_MAP_KEY_MSK);
        key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS);
 
-       if (sta_id == il->contexts[IL_RXON_CTX_BSS].bcast_sta_id)
+       if (sta_id == il->ctx.bcast_sta_id)
                key_flags |= STA_KEY_MULTICAST_MSK;
 
        keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
@@ -163,7 +163,7 @@ static int il3945_set_ccmp_dynamic_key_info(struct il_priv *il,
        if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK)
                        == STA_KEY_FLG_NO_ENC)
                il->stations[sta_id].sta.key.key_offset =
-                                il_get_free_ucode_key_index(il);
+                                il_get_free_ucode_key_idx(il);
        /* else, we are overriding an existing key => no need to allocated room
        * in uCode. */
 
@@ -318,7 +318,7 @@ unsigned int il3945_fill_beacon_frame(struct il_priv *il,
                                int left)
 {
 
-       if (!il_is_associated(il, IL_RXON_CTX_BSS) || !il->beacon_skb)
+       if (!il_is_associated(il) || !il->beacon_skb)
                return 0;
 
        if (il->beacon_skb->len > left)
@@ -345,7 +345,7 @@ static int il3945_send_beacon_cmd(struct il_priv *il)
        }
 
        rate = il_get_lowest_plcp(il,
-                               &il->contexts[IL_RXON_CTX_BSS]);
+                               &il->ctx);
 
        frame_size = il3945_hw_get_beacon_cmd(il, frame, rate);
 
@@ -500,7 +500,7 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb)
 
        fc = hdr->frame_control;
 
-#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
+#ifdef CONFIG_IWLEGACY_DEBUG
        if (ieee80211_is_auth(fc))
                D_TX("Sending AUTH frame\n");
        else if (ieee80211_is_assoc_req(fc))
@@ -513,9 +513,9 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb)
 
        hdr_len = ieee80211_hdrlen(fc);
 
-       /* Find index into station table for destination station */
+       /* Find idx into station table for destination station */
        sta_id = il_sta_id_or_broadcast(
-                       il, &il->contexts[IL_RXON_CTX_BSS],
+                       il, &il->ctx,
                        info->control.sta);
        if (sta_id == IL_INVALID_STATION) {
                D_DROP("Dropping - INVALID STATION: %pM\n",
@@ -541,12 +541,12 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb)
 
        spin_lock_irqsave(&il->lock, flags);
 
-       idx = il_get_cmd_index(q, q->write_ptr, 0);
+       idx = il_get_cmd_idx(q, q->write_ptr, 0);
 
        /* Set up driver data for this TFD */
        memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct il_tx_info));
        txq->txb[q->write_ptr].skb = skb;
-       txq->txb[q->write_ptr].ctx = &il->contexts[IL_RXON_CTX_BSS];
+       txq->txb[q->write_ptr].ctx = &il->ctx;
 
        /* Init first empty entry in queue's array of Tx/cmd buffers */
        out_cmd = txq->cmd[idx];
@@ -557,13 +557,13 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb)
 
        /*
         * Set up the Tx-command (not MAC!) header.
-        * Store the chosen Tx queue and TFD index within the sequence field;
+        * Store the chosen Tx queue and TFD idx within the sequence field;
         * after Tx, uCode's Tx response will return this value so driver can
         * locate the frame within the tx queue and do post-tx processing.
         */
        out_cmd->hdr.cmd = REPLY_TX;
        out_cmd->hdr.sequence = cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) |
-                               INDEX_TO_SEQ(q->write_ptr)));
+                               IDX_TO_SEQ(q->write_ptr)));
 
        /* Copy MAC header from skb into command buffer */
        memcpy(tx_cmd->hdr, hdr, hdr_len);
@@ -641,12 +641,12 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb)
        }
 
 
-       /* Tell device the write index *just past* this latest filled TFD */
+       /* Tell device the write idx *just past* this latest filled TFD */
        q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd);
        il_txq_update_write_ptr(il, txq);
        spin_unlock_irqrestore(&il->lock, flags);
 
-       if ((il_queue_space(q) < q->high_mark)
+       if (il_queue_space(q) < q->high_mark
            && il->mac80211_registered) {
                if (wait_write_ptr) {
                        spin_lock_irqsave(&il->lock, flags);
@@ -671,7 +671,7 @@ static int il3945_get_measurement(struct il_priv *il,
                               u8 type)
 {
        struct il_spectrum_cmd spectrum;
-       struct il_rx_packet *pkt;
+       struct il_rx_pkt *pkt;
        struct il_host_cmd cmd = {
                .id = REPLY_SPECTRUM_MEASUREMENT_CMD,
                .data = (void *)&spectrum,
@@ -681,9 +681,9 @@ static int il3945_get_measurement(struct il_priv *il,
        int rc;
        int spectrum_resp_status;
        int duration = le16_to_cpu(params->duration);
-       struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS];
+       struct il_rxon_context *ctx = &il->ctx;
 
-       if (il_is_associated(il, IL_RXON_CTX_BSS))
+       if (il_is_associated(il))
                add_time = il_usecs_to_beacons(il,
                        le64_to_cpu(params->start_time) - il->_3945.last_tsf,
                        le16_to_cpu(ctx->timing.beacon_interval));
@@ -697,7 +697,7 @@ static int il3945_get_measurement(struct il_priv *il,
        cmd.len = sizeof(spectrum);
        spectrum.len = cpu_to_le16(cmd.len - sizeof(spectrum.len));
 
-       if (il_is_associated(il, IL_RXON_CTX_BSS))
+       if (il_is_associated(il))
                spectrum.start_time =
                        il_add_beacon_time(il,
                                il->_3945.last_beacon_time, add_time,
@@ -716,7 +716,7 @@ static int il3945_get_measurement(struct il_priv *il,
        if (rc)
                return rc;
 
-       pkt = (struct il_rx_packet *)cmd.reply_page;
+       pkt = (struct il_rx_pkt *)cmd.reply_page;
        if (pkt->hdr.flags & IL_CMD_FAILED_MSK) {
                IL_ERR("Bad return from REPLY_RX_ON_ASSOC command\n");
                rc = -EIO;
@@ -745,9 +745,9 @@ static int il3945_get_measurement(struct il_priv *il,
 }
 
 static void il3945_rx_reply_alive(struct il_priv *il,
-                              struct il_rx_mem_buffer *rxb)
+                              struct il_rx_buf *rxb)
 {
-       struct il_rx_packet *pkt = rxb_addr(rxb);
+       struct il_rx_pkt *pkt = rxb_addr(rxb);
        struct il_alive_resp *palive;
        struct delayed_work *pwork;
 
@@ -781,21 +781,21 @@ static void il3945_rx_reply_alive(struct il_priv *il,
 }
 
 static void il3945_rx_reply_add_sta(struct il_priv *il,
-                                struct il_rx_mem_buffer *rxb)
+                                struct il_rx_buf *rxb)
 {
-#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
-       struct il_rx_packet *pkt = rxb_addr(rxb);
+#ifdef CONFIG_IWLEGACY_DEBUG
+       struct il_rx_pkt *pkt = rxb_addr(rxb);
 #endif
 
        D_RX("Received REPLY_ADD_STA: 0x%02X\n", pkt->u.status);
 }
 
 static void il3945_rx_beacon_notif(struct il_priv *il,
-                               struct il_rx_mem_buffer *rxb)
+                               struct il_rx_buf *rxb)
 {
-       struct il_rx_packet *pkt = rxb_addr(rxb);
+       struct il_rx_pkt *pkt = rxb_addr(rxb);
        struct il3945_beacon_notif *beacon = &(pkt->u.beacon_status);
-#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
+#ifdef CONFIG_IWLEGACY_DEBUG
        u8 rate = beacon->beacon_notify_hdr.rate;
 
        D_RX("beacon status %x retries %d iss %d "
@@ -814,9 +814,9 @@ static void il3945_rx_beacon_notif(struct il_priv *il,
 /* Handle notification from uCode that card's power state is changing
  * due to software, hardware, or critical temperature RFKILL */
 static void il3945_rx_card_state_notif(struct il_priv *il,
-                                   struct il_rx_mem_buffer *rxb)
+                                   struct il_rx_buf *rxb)
 {
-       struct il_rx_packet *pkt = rxb_addr(rxb);
+       struct il_rx_pkt *pkt = rxb_addr(rxb);
        u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags);
        unsigned long status = il->status;
 
@@ -862,16 +862,16 @@ static void il3945_setup_rx_handlers(struct il_priv *il)
                        il_rx_spectrum_measure_notif;
        il->rx_handlers[PM_SLEEP_NOTIFICATION] = il_rx_pm_sleep_notif;
        il->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] =
-           il_rx_pm_debug_statistics_notif;
+           il_rx_pm_debug_stats_notif;
        il->rx_handlers[BEACON_NOTIFICATION] = il3945_rx_beacon_notif;
 
        /*
         * The same handler is used for both the REPLY to a discrete
-        * statistics request from the host as well as for the periodic
-        * statistics notifications (after received beacons) from the uCode.
+        * stats request from the host as well as for the periodic
+        * stats notifications (after received beacons) from the uCode.
         */
-       il->rx_handlers[REPLY_STATISTICS_CMD] = il3945_reply_statistics;
-       il->rx_handlers[STATISTICS_NOTIFICATION] = il3945_hw_rx_statistics;
+       il->rx_handlers[REPLY_STATISTICS_CMD] = il3945_reply_stats;
+       il->rx_handlers[STATISTICS_NOTIFICATION] = il3945_hw_rx_stats;
 
        il_setup_rx_scan_handlers(il);
        il->rx_handlers[CARD_STATE_NOTIFICATION] = il3945_rx_card_state_notif;
@@ -889,25 +889,25 @@ static void il3945_setup_rx_handlers(struct il_priv *il)
  * 0 to 31
  *
  * Rx Queue Indexes
- * The host/firmware share two index registers for managing the Rx buffers.
+ * The host/firmware share two idx registers for managing the Rx buffers.
  *
- * The READ index maps to the first position that the firmware may be writing
+ * The READ idx maps to the first position that the firmware may be writing
  * to -- the driver can read up to (but not including) this position and get
  * good data.
- * The READ index is managed by the firmware once the card is enabled.
+ * The READ idx is managed by the firmware once the card is enabled.
  *
- * The WRITE index maps to the last position the driver has read from -- the
+ * The WRITE idx maps to the last position the driver has read from -- the
  * position preceding WRITE is the last slot the firmware can place a packet.
  *
  * The queue is empty (no good data) if WRITE = READ - 1, and is full if
  * WRITE = READ.
  *
  * During initialization, the host sets up the READ queue position to the first
- * INDEX position, and WRITE to the last (READ - 1 wrapped)
+ * IDX position, and WRITE to the last (READ - 1 wrapped)
  *
- * When the firmware places a packet in a buffer, it will advance the READ index
- * and fire the RX interrupt.  The driver can then query the READ index and
- * process as many packets as possible, moving the WRITE index forward as it
+ * When the firmware places a packet in a buffer, it will advance the READ idx
+ * and fire the RX interrupt.  The driver can then query the READ idx and
+ * process as many packets as possible, moving the WRITE idx forward as it
  * resets the Rx queue buffers with new memory.
  *
  * The management in the driver is as follows:
@@ -915,13 +915,13 @@ static void il3945_setup_rx_handlers(struct il_priv *il)
  *   iwl->rxq->free_count drops to or below RX_LOW_WATERMARK, work is scheduled
  *   to replenish the iwl->rxq->rx_free.
  * + In il3945_rx_replenish (scheduled) if 'processed' != 'read' then the
- *   iwl->rxq is replenished and the READ INDEX is updated (updating the
- *   'processed' and 'read' driver indexes as well)
+ *   iwl->rxq is replenished and the READ IDX is updated (updating the
+ *   'processed' and 'read' driver idxes as well)
  * + A received packet is processed and handed to the kernel network stack,
- *   detached from the iwl->rxq.  The driver 'processed' index is updated.
+ *   detached from the iwl->rxq.  The driver 'processed' idx is updated.
  * + The Host/Firmware iwl->rxq is replenished at tasklet time from the rx_free
  *   list. If there are no allocated buffers in iwl->rxq->rx_free, the READ
- *   INDEX is not incremented and iwl->status(RX_STALLED) is set.  If there
+ *   IDX is not incremented and iwl->status(RX_STALLED) is set.  If there
  *   were enough free buffers and RX_STALLED is set it is cleared.
  *
  *
@@ -931,12 +931,12 @@ static void il3945_setup_rx_handlers(struct il_priv *il)
  *                            il3945_rx_queue_restock
  * il3945_rx_queue_restock() Moves available buffers from rx_free into Rx
  *                            queue, updates firmware pointers, and updates
- *                            the WRITE index.  If insufficient rx_free buffers
+ *                            the WRITE idx.  If insufficient rx_free buffers
  *                            are available, schedules il3945_rx_replenish
  *
  * -- enable interrupts --
- * ISR - il3945_rx()         Detach il_rx_mem_buffers from pool up to the
- *                            READ INDEX, detaching the SKB from the pool.
+ * ISR - il3945_rx()         Detach il_rx_bufs from pool up to the
+ *                            READ IDX, detaching the SKB from the pool.
  *                            Moves the packet buffer from queue to rx_used.
  *                            Calls il3945_rx_queue_restock to refill any empty
  *                            slots.
@@ -960,7 +960,7 @@ static inline __le32 il3945_dma_addr2rbd_ptr(struct il_priv *il,
  * and we have free pre-allocated buffers, fill the ranks as much
  * as we can, pulling from rx_free.
  *
- * This moves the 'write' index forward to catch up with 'processed', and
+ * This moves the 'write' idx forward to catch up with 'processed', and
  * also updates the memory address in the firmware to reference the new
  * target buffer.
  */
@@ -968,16 +968,16 @@ static void il3945_rx_queue_restock(struct il_priv *il)
 {
        struct il_rx_queue *rxq = &il->rxq;
        struct list_head *element;
-       struct il_rx_mem_buffer *rxb;
+       struct il_rx_buf *rxb;
        unsigned long flags;
        int write;
 
        spin_lock_irqsave(&rxq->lock, flags);
        write = rxq->write & ~0x7;
-       while ((il_rx_queue_space(rxq) > 0) && (rxq->free_count)) {
+       while (il_rx_queue_space(rxq) > 0 && rxq->free_count) {
                /* Get next free Rx buffer, remove from free list */
                element = rxq->rx_free.next;
-               rxb = list_entry(element, struct il_rx_mem_buffer, list);
+               rxb = list_entry(element, struct il_rx_buf, list);
                list_del(element);
 
                /* Point to Rx buffer via next RBD in circular buffer */
@@ -995,8 +995,8 @@ static void il3945_rx_queue_restock(struct il_priv *il)
 
        /* If we've added more space for the firmware to place data, tell it.
         * Increment device's write pointer in multiples of 8. */
-       if ((rxq->write_actual != (rxq->write & ~0x7))
-           || (abs(rxq->write - rxq->read) > 7)) {
+       if (rxq->write_actual != (rxq->write & ~0x7) ||
+           abs(rxq->write - rxq->read) > 7) {
                spin_lock_irqsave(&rxq->lock, flags);
                rxq->need_update = 1;
                spin_unlock_irqrestore(&rxq->lock, flags);
@@ -1016,7 +1016,7 @@ static void il3945_rx_allocate(struct il_priv *il, gfp_t priority)
 {
        struct il_rx_queue *rxq = &il->rxq;
        struct list_head *element;
-       struct il_rx_mem_buffer *rxb;
+       struct il_rx_buf *rxb;
        struct page *page;
        unsigned long flags;
        gfp_t gfp_mask = priority;
@@ -1041,7 +1041,7 @@ static void il3945_rx_allocate(struct il_priv *il, gfp_t priority)
                if (!page) {
                        if (net_ratelimit())
                                D_INFO("Failed to allocate SKB buffer.\n");
-                       if ((rxq->free_count <= RX_LOW_WATERMARK) &&
+                       if (rxq->free_count <= RX_LOW_WATERMARK &&
                            net_ratelimit())
                                IL_ERR("Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n",
                                         priority == GFP_ATOMIC ?  "GFP_ATOMIC" : "GFP_KERNEL",
@@ -1059,7 +1059,7 @@ static void il3945_rx_allocate(struct il_priv *il, gfp_t priority)
                        return;
                }
                element = rxq->rx_used.next;
-               rxb = list_entry(element, struct il_rx_mem_buffer, list);
+               rxb = list_entry(element, struct il_rx_buf, list);
                list_del(element);
                spin_unlock_irqrestore(&rxq->lock, flags);
 
@@ -1201,8 +1201,8 @@ int il3945_calc_db_from_ratio(int sig_ratio)
  */
 static void il3945_rx_handle(struct il_priv *il)
 {
-       struct il_rx_mem_buffer *rxb;
-       struct il_rx_packet *pkt;
+       struct il_rx_buf *rxb;
+       struct il_rx_pkt *pkt;
        struct il_rx_queue *rxq = &il->rxq;
        u32 r, i;
        int reclaim;
@@ -1211,7 +1211,7 @@ static void il3945_rx_handle(struct il_priv *il)
        u32 count = 8;
        int total_empty = 0;
 
-       /* uCode's read index (stored in shared DRAM) indicates the last Rx
+       /* uCode's read idx (stored in shared DRAM) indicates the last Rx
         * buffer that the driver may process (last buffer filled by ucode). */
        r = le16_to_cpu(rxq->rb_stts->closed_rb_num) &  0x0FFF;
        i = rxq->read;
@@ -1254,8 +1254,8 @@ static void il3945_rx_handle(struct il_priv *il)
                 * Ucode should set SEQ_RX_FRAME bit if ucode-originated,
                 *   but apparently a few don't get set; catch them here. */
                reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME) &&
-                       (pkt->hdr.cmd != STATISTICS_NOTIFICATION) &&
-                       (pkt->hdr.cmd != REPLY_TX);
+                       pkt->hdr.cmd != STATISTICS_NOTIFICATION &&
+                       pkt->hdr.cmd != REPLY_TX;
 
                /* Based on type of command response or notification,
                 *   handle those that need handling via function in
@@ -1410,7 +1410,7 @@ static void il3945_irq_tasklet(struct il_priv *il)
        u32 inta, handled = 0;
        u32 inta_fh;
        unsigned long flags;
-#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
+#ifdef CONFIG_IWLEGACY_DEBUG
        u32 inta_mask;
 #endif
 
@@ -1428,7 +1428,7 @@ static void il3945_irq_tasklet(struct il_priv *il)
        inta_fh = _il_rd(il, CSR_FH_INT_STATUS);
        _il_wr(il, CSR_FH_INT_STATUS, inta_fh);
 
-#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
+#ifdef CONFIG_IWLEGACY_DEBUG
        if (il_get_debug_level(il) & IL_DL_ISR) {
                /* just for debug */
                inta_mask = _il_rd(il, CSR_INT_MASK);
@@ -1463,7 +1463,7 @@ static void il3945_irq_tasklet(struct il_priv *il)
                return;
        }
 
-#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
+#ifdef CONFIG_IWLEGACY_DEBUG
        if (il_get_debug_level(il) & (IL_DL_ISR)) {
                /* NIC fires this, but we don't use it, redundant with WAKEUP */
                if (inta & CSR_INT_BIT_SCD) {
@@ -1541,7 +1541,7 @@ static void il3945_irq_tasklet(struct il_priv *il)
        if (test_bit(STATUS_INT_ENABLED, &il->status))
                il_enable_interrupts(il);
 
-#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
+#ifdef CONFIG_IWLEGACY_DEBUG
        if (il_get_debug_level(il) & (IL_DL_ISR)) {
                inta = _il_rd(il, CSR_INT);
                inta_mask = _il_rd(il, CSR_INT_MASK);
@@ -1612,12 +1612,12 @@ static int il3945_get_channels_for_scan(struct il_priv *il,
                 * hearing clear Rx packet).*/
                if (IL_UCODE_API(il->ucode_ver) >= 2) {
                        if (n_probes)
-                               scan_ch->type |= IWL39_SCAN_PROBE_MASK(n_probes);
+                               scan_ch->type |= IL39_SCAN_PROBE_MASK(n_probes);
                } else {
                        /* uCode v1 does not allow setting direct probe bits on
                         * passive channel. */
                        if ((scan_ch->type & 1) && n_probes)
-                               scan_ch->type |= IWL39_SCAN_PROBE_MASK(n_probes);
+                               scan_ch->type |= IL39_SCAN_PROBE_MASK(n_probes);
                }
 
                /* Set txpower levels to defaults */
@@ -1654,12 +1654,12 @@ static void il3945_init_hw_rates(struct il_priv *il,
 {
        int i;
 
-       for (i = 0; i < IL_RATE_COUNT_LEGACY; i++) {
+       for (i = 0; i < RATE_COUNT_LEGACY; i++) {
                rates[i].bitrate = il3945_rates[i].ieee * 5;
-               rates[i].hw_value = i; /* Rate scaling will work on indexes */
+               rates[i].hw_value = i; /* Rate scaling will work on idxes */
                rates[i].hw_value_short = i;
                rates[i].flags = 0;
-               if ((i > IWL39_LAST_OFDM_RATE) || (i < IL_FIRST_OFDM_RATE)) {
+               if (i > IL39_LAST_OFDM_RATE || i < IL_FIRST_OFDM_RATE) {
                        /*
                         * If CCK != 1M then set short preamble rate flag.
                         */
@@ -1699,7 +1699,7 @@ static int il3945_verify_inst_full(struct il_priv *il, __le32 *image, u32 len)
        D_INFO("ucode inst image size is %u\n", len);
 
        il_wr(il, HBUS_TARG_MEM_RADDR,
-                              IWL39_RTC_INST_LOWER_BOUND);
+                              IL39_RTC_INST_LOWER_BOUND);
 
        errcnt = 0;
        for (; len > 0; len -= sizeof(u32), image++) {
@@ -1746,7 +1746,7 @@ static int il3945_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len)
                /* NOTE: Use the debugless read so we don't flood kernel log
                 * if IL_DL_IO is set */
                il_wr(il, HBUS_TARG_MEM_RADDR,
-                       i + IWL39_RTC_INST_LOWER_BOUND);
+                       i + IL39_RTC_INST_LOWER_BOUND);
                val = _il_rd(il, HBUS_TARG_MEM_RDAT);
                if (val != le32_to_cpu(*image)) {
 #if 0 /* Enable this if you want to see details */
@@ -1820,7 +1820,7 @@ static void il3945_nic_start(struct il_priv *il)
        _il_wr(il, CSR_RESET, 0);
 }
 
-#define IWL3945_UCODE_GET(item)                                                \
+#define IL3945_UCODE_GET(item)                                         \
 static u32 il3945_ucode_get_##item(const struct il_ucode_header *ucode)\
 {                                                                      \
        return le32_to_cpu(ucode->v1.item);                             \
@@ -1836,11 +1836,11 @@ static u8 *il3945_ucode_get_data(const struct il_ucode_header *ucode)
        return (u8 *) ucode->v1.data;
 }
 
-IWL3945_UCODE_GET(inst_size);
-IWL3945_UCODE_GET(data_size);
-IWL3945_UCODE_GET(init_size);
-IWL3945_UCODE_GET(init_data_size);
-IWL3945_UCODE_GET(boot_size);
+IL3945_UCODE_GET(inst_size);
+IL3945_UCODE_GET(data_size);
+IL3945_UCODE_GET(init_size);
+IL3945_UCODE_GET(init_data_size);
+IL3945_UCODE_GET(boot_size);
 
 /**
  * il3945_read_ucode - Read uCode images from disk file.
@@ -1850,7 +1850,7 @@ IWL3945_UCODE_GET(boot_size);
 static int il3945_read_ucode(struct il_priv *il)
 {
        const struct il_ucode_header *ucode;
-       int ret = -EINVAL, index;
+       int ret = -EINVAL, idx;
        const struct firmware *ucode_raw;
        /* firmware file name contains uCode/driver compatibility version */
        const char *name_pre = il->cfg->fw_name_pre;
@@ -1863,8 +1863,8 @@ static int il3945_read_ucode(struct il_priv *il)
 
        /* Ask kernel firmware_class module to get the boot firmware off disk.
         * request_firmware() is synchronous, file is in memory on return. */
-       for (index = api_max; index >= api_min; index--) {
-               sprintf(buf, "%s%u%s", name_pre, index, ".ucode");
+       for (idx = api_max; idx >= api_min; idx--) {
+               sprintf(buf, "%s%u%s", name_pre, idx, ".ucode");
                ret = request_firmware(&ucode_raw, buf, &il->pci_dev->dev);
                if (ret < 0) {
                        IL_ERR("%s firmware file req failed: %d\n",
@@ -1874,7 +1874,7 @@ static int il3945_read_ucode(struct il_priv *il)
                        else
                                goto error;
                } else {
-                       if (index < api_max)
+                       if (idx < api_max)
                                IL_ERR("Loaded firmware %s, "
                                        "which is deprecated. "
                                        " Please use API v%u instead.\n",
@@ -1967,34 +1967,34 @@ static int il3945_read_ucode(struct il_priv *il)
        }
 
        /* Verify that uCode images will fit in card's SRAM */
-       if (inst_size > IWL39_MAX_INST_SIZE) {
+       if (inst_size > IL39_MAX_INST_SIZE) {
                D_INFO("uCode instr len %d too large to fit in\n",
                               inst_size);
                ret = -EINVAL;
                goto err_release;
        }
 
-       if (data_size > IWL39_MAX_DATA_SIZE) {
+       if (data_size > IL39_MAX_DATA_SIZE) {
                D_INFO("uCode data len %d too large to fit in\n",
                               data_size);
                ret = -EINVAL;
                goto err_release;
        }
-       if (init_size > IWL39_MAX_INST_SIZE) {
+       if (init_size > IL39_MAX_INST_SIZE) {
                D_INFO(
                                "uCode init instr len %d too large to fit in\n",
                                init_size);
                ret = -EINVAL;
                goto err_release;
        }
-       if (init_data_size > IWL39_MAX_DATA_SIZE) {
+       if (init_data_size > IL39_MAX_DATA_SIZE) {
                D_INFO(
                                "uCode init data len %d too large to fit in\n",
                                init_data_size);
                ret = -EINVAL;
                goto err_release;
        }
-       if (boot_size > IWL39_MAX_BSM_SIZE) {
+       if (boot_size > IL39_MAX_BSM_SIZE) {
                D_INFO(
                                "uCode boot instr len %d too large to fit in\n",
                                boot_size);
@@ -2189,7 +2189,7 @@ static void il3945_alive_start(struct il_priv *il)
 {
        int thermal_spin = 0;
        u32 rfkill;
-       struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS];
+       struct il_rxon_context *ctx = &il->ctx;
 
        D_INFO("Runtime Alive received.\n");
 
@@ -2239,11 +2239,11 @@ static void il3945_alive_start(struct il_priv *il)
 
        ieee80211_wake_queues(il->hw);
 
-       il->active_rate = IL_RATES_MASK_3945;
+       il->active_rate = RATES_MASK_3945;
 
        il_power_update_mode(il, true);
 
-       if (il_is_associated(il, IL_RXON_CTX_BSS)) {
+       if (il_is_associated(il)) {
                struct il3945_rxon_cmd *active_rxon =
                                (struct il3945_rxon_cmd *)(&ctx->active);
 
@@ -2372,7 +2372,7 @@ static void il3945_down(struct il_priv *il)
 
 static int il3945_alloc_bcast_station(struct il_priv *il)
 {
-       struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS];
+       struct il_rxon_context *ctx = &il->ctx;
        unsigned long flags;
        u8 sta_id;
 
@@ -2581,7 +2581,7 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif)
        scan->quiet_plcp_th = IL_PLCP_QUIET_THRESH;
        scan->quiet_time = IL_ACTIVE_QUIET_TIME;
 
-       if (il_is_associated(il, IL_RXON_CTX_BSS)) {
+       if (il_is_associated(il)) {
                u16 interval;
                u32 extra;
                u32 suspend_time = 100;
@@ -2634,7 +2634,7 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif)
        /* We don't build a direct scan probe request; the uCode will do
         * that based on the direct_mask added to each channel entry */
        scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK;
-       scan->tx_cmd.sta_id = il->contexts[IL_RXON_CTX_BSS].bcast_sta_id;
+       scan->tx_cmd.sta_id = il->ctx.bcast_sta_id;
        scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE;
 
        /* flags + rate selection */
@@ -2642,11 +2642,11 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif)
        switch (il->scan_band) {
        case IEEE80211_BAND_2GHZ:
                scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK;
-               scan->tx_cmd.rate = IL_RATE_1M_PLCP;
+               scan->tx_cmd.rate = RATE_1M_PLCP;
                band = IEEE80211_BAND_2GHZ;
                break;
        case IEEE80211_BAND_5GHZ:
-               scan->tx_cmd.rate = IL_RATE_6M_PLCP;
+               scan->tx_cmd.rate = RATE_6M_PLCP;
                band = IEEE80211_BAND_5GHZ;
                break;
        default:
@@ -2692,7 +2692,7 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif)
 
 void il3945_post_scan(struct il_priv *il)
 {
-       struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS];
+       struct il_rxon_context *ctx = &il->ctx;
 
        /*
         * Since setting the RXON may have been deferred while
@@ -2750,7 +2750,7 @@ void il3945_post_associate(struct il_priv *il)
 {
        int rc = 0;
        struct ieee80211_conf *conf = NULL;
-       struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS];
+       struct il_rxon_context *ctx = &il->ctx;
 
        if (!ctx->vif || !il->is_open)
                return;
@@ -2917,7 +2917,7 @@ static void il3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
 
 void il3945_config_ap(struct il_priv *il)
 {
-       struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS];
+       struct il_rxon_context *ctx = &il->ctx;
        struct ieee80211_vif *vif = ctx->vif;
        int rc = 0;
 
@@ -2925,7 +2925,7 @@ void il3945_config_ap(struct il_priv *il)
                return;
 
        /* The following should be done only at AP bring up */
-       if (!(il_is_associated(il, IL_RXON_CTX_BSS))) {
+       if (!(il_is_associated(il))) {
 
                /* RXON - unassoc (to set timing command) */
                ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
@@ -2986,11 +2986,11 @@ static int il3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
            !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE))
                return -EOPNOTSUPP;
 
-       static_key = !il_is_associated(il, IL_RXON_CTX_BSS);
+       static_key = !il_is_associated(il);
 
        if (!static_key) {
                sta_id = il_sta_id_or_broadcast(
-                               il, &il->contexts[IL_RXON_CTX_BSS], sta);
+                               il, &il->ctx, sta);
                if (sta_id == IL_INVALID_STATION)
                        return -EINVAL;
        }
@@ -3042,7 +3042,7 @@ static int il3945_mac_sta_add(struct ieee80211_hw *hw,
 
 
        ret = il_add_station_common(il,
-                               &il->contexts[IL_RXON_CTX_BSS],
+                               &il->ctx,
                                     sta->addr, is_ap, sta, &sta_id);
        if (ret) {
                IL_ERR("Unable to add station %pM (%d)\n",
@@ -3070,7 +3070,7 @@ static void il3945_configure_filter(struct ieee80211_hw *hw,
 {
        struct il_priv *il = hw->priv;
        __le32 filter_or = 0, filter_nand = 0;
-       struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS];
+       struct il_rxon_context *ctx = &il->ctx;
 
 #define CHK(test, flag)        do { \
        if (*total_flags & (test))              \
@@ -3118,7 +3118,7 @@ static void il3945_configure_filter(struct ieee80211_hw *hw,
  *
  *****************************************************************************/
 
-#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
+#ifdef CONFIG_IWLEGACY_DEBUG
 
 /*
  * The following adds a new attribute to the sysfs representation
@@ -3160,7 +3160,7 @@ static ssize_t il3945_store_debug_level(struct device *d,
 static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO,
                        il3945_show_debug_level, il3945_store_debug_level);
 
-#endif /* CONFIG_IWLWIFI_LEGACY_DEBUG */
+#endif /* CONFIG_IWLEGACY_DEBUG */
 
 static ssize_t il3945_show_temperature(struct device *d,
                                struct device_attribute *attr, char *buf)
@@ -3205,7 +3205,7 @@ static ssize_t il3945_show_flags(struct device *d,
                          struct device_attribute *attr, char *buf)
 {
        struct il_priv *il = dev_get_drvdata(d);
-       struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS];
+       struct il_rxon_context *ctx = &il->ctx;
 
        return sprintf(buf, "0x%04X\n", ctx->active.flags);
 }
@@ -3216,7 +3216,7 @@ static ssize_t il3945_store_flags(struct device *d,
 {
        struct il_priv *il = dev_get_drvdata(d);
        u32 flags = simple_strtoul(buf, NULL, 0);
-       struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS];
+       struct il_rxon_context *ctx = &il->ctx;
 
        mutex_lock(&il->mutex);
        if (le32_to_cpu(ctx->staging.flags) != flags) {
@@ -3241,7 +3241,7 @@ static ssize_t il3945_show_filter_flags(struct device *d,
                                 struct device_attribute *attr, char *buf)
 {
        struct il_priv *il = dev_get_drvdata(d);
-       struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS];
+       struct il_rxon_context *ctx = &il->ctx;
 
        return sprintf(buf, "0x%04X\n",
                le32_to_cpu(ctx->active.filter_flags));
@@ -3252,7 +3252,7 @@ static ssize_t il3945_store_filter_flags(struct device *d,
                                  const char *buf, size_t count)
 {
        struct il_priv *il = dev_get_drvdata(d);
-       struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS];
+       struct il_rxon_context *ctx = &il->ctx;
        u32 filter_flags = simple_strtoul(buf, NULL, 0);
 
        mutex_lock(&il->mutex);
@@ -3294,7 +3294,7 @@ static ssize_t il3945_show_measurement(struct device *d,
        il->measurement_status = 0;
        spin_unlock_irqrestore(&il->lock, flags);
 
-       while (size && (PAGE_SIZE - len)) {
+       while (size && PAGE_SIZE - len) {
                hex_dump_to_buffer(data + ofs, size, 16, 1, buf + len,
                                   PAGE_SIZE - len, 1);
                len = strlen(buf);
@@ -3313,7 +3313,7 @@ static ssize_t il3945_store_measurement(struct device *d,
                                 const char *buf, size_t count)
 {
        struct il_priv *il = dev_get_drvdata(d);
-       struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS];
+       struct il_rxon_context *ctx = &il->ctx;
        struct ieee80211_measurement_params params = {
                .channel = le16_to_cpu(ctx->active.channel),
                .start_time = cpu_to_le64(il->_3945.last_tsf),
@@ -3406,7 +3406,7 @@ static ssize_t il3945_store_antenna(struct device *d,
                return count;
        }
 
-       if ((ant >= 0) && (ant <= 2)) {
+       if (ant >= 0 && ant <= 2) {
                D_INFO("Setting antenna select to %d.\n", ant);
                il3945_mod_params.antenna = (enum il3945_antenna)ant;
        } else
@@ -3495,7 +3495,7 @@ static struct attribute *il3945_sysfs_entries[] = {
        &dev_attr_status.attr,
        &dev_attr_temperature.attr,
        &dev_attr_tx_power.attr,
-#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
+#ifdef CONFIG_IWLEGACY_DEBUG
        &dev_attr_debug_level.attr,
 #endif
        NULL
@@ -3583,7 +3583,7 @@ err:
        return ret;
 }
 
-#define IWL3945_MAX_PROBE_REQUEST      200
+#define IL3945_MAX_PROBE_REQUEST       200
 
 static int il3945_setup_mac(struct il_priv *il)
 {
@@ -3599,7 +3599,7 @@ static int il3945_setup_mac(struct il_priv *il)
                    IEEE80211_HW_SPECTRUM_MGMT;
 
        hw->wiphy->interface_modes =
-               il->contexts[IL_RXON_CTX_BSS].interface_modes;
+               il->ctx.interface_modes;
 
        hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY |
                            WIPHY_FLAG_DISABLE_BEACON_HINTS |
@@ -3607,7 +3607,7 @@ static int il3945_setup_mac(struct il_priv *il)
 
        hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX_3945;
        /* we create the 802.11 header and a zero-length SSID element */
-       hw->wiphy->max_scan_ie_len = IWL3945_MAX_PROBE_REQUEST - 24 - 2;
+       hw->wiphy->max_scan_ie_len = IL3945_MAX_PROBE_REQUEST - 24 - 2;
 
        /* Default value; 4 EDCA QOS priorities */
        hw->queues = 4;
@@ -3634,7 +3634,7 @@ static int il3945_setup_mac(struct il_priv *il)
 
 static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
-       int err = 0, i;
+       int err = 0;
        struct il_priv *il;
        struct ieee80211_hw *hw;
        struct il_cfg *cfg = (struct il_cfg *)(ent->driver_data);
@@ -3656,26 +3656,22 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en
        il = hw->priv;
        SET_IEEE80211_DEV(hw, &pdev->dev);
 
-       il->cmd_queue = IWL39_CMD_QUEUE_NUM;
+       il->cmd_queue = IL39_CMD_QUEUE_NUM;
 
-       /* 3945 has only one valid context */
-       il->valid_contexts = BIT(IL_RXON_CTX_BSS);
+       il->ctx.ctxid = 0;
 
-       for (i = 0; i < NUM_IL_RXON_CTX; i++)
-               il->contexts[i].ctxid = i;
-
-       il->contexts[IL_RXON_CTX_BSS].rxon_cmd = REPLY_RXON;
-       il->contexts[IL_RXON_CTX_BSS].rxon_timing_cmd = REPLY_RXON_TIMING;
-       il->contexts[IL_RXON_CTX_BSS].rxon_assoc_cmd = REPLY_RXON_ASSOC;
-       il->contexts[IL_RXON_CTX_BSS].qos_cmd = REPLY_QOS_PARAM;
-       il->contexts[IL_RXON_CTX_BSS].ap_sta_id = IL_AP_ID;
-       il->contexts[IL_RXON_CTX_BSS].wep_key_cmd = REPLY_WEPKEY;
-       il->contexts[IL_RXON_CTX_BSS].interface_modes =
+       il->ctx.rxon_cmd = REPLY_RXON;
+       il->ctx.rxon_timing_cmd = REPLY_RXON_TIMING;
+       il->ctx.rxon_assoc_cmd = REPLY_RXON_ASSOC;
+       il->ctx.qos_cmd = REPLY_QOS_PARAM;
+       il->ctx.ap_sta_id = IL_AP_ID;
+       il->ctx.wep_key_cmd = REPLY_WEPKEY;
+       il->ctx.interface_modes =
                BIT(NL80211_IFTYPE_STATION) |
                BIT(NL80211_IFTYPE_ADHOC);
-       il->contexts[IL_RXON_CTX_BSS].ibss_devtype = RXON_DEV_TYPE_IBSS;
-       il->contexts[IL_RXON_CTX_BSS].station_devtype = RXON_DEV_TYPE_ESS;
-       il->contexts[IL_RXON_CTX_BSS].unused_devtype = RXON_DEV_TYPE_ESS;
+       il->ctx.ibss_devtype = RXON_DEV_TYPE_IBSS;
+       il->ctx.station_devtype = RXON_DEV_TYPE_ESS;
+       il->ctx.unused_devtype = RXON_DEV_TYPE_ESS;
 
        /*
         * Disabling hardware scan means that mac80211 will perform scans
@@ -3812,7 +3808,7 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en
 
        il_set_rxon_channel(il,
                             &il->bands[IEEE80211_BAND_2GHZ].channels[5],
-                            &il->contexts[IL_RXON_CTX_BSS]);
+                            &il->ctx);
        il3945_setup_deferred_work(il);
        il3945_setup_rx_handlers(il);
        il_power_initialize(il);
@@ -3992,7 +3988,7 @@ static void __exit il3945_exit(void)
        il3945_rate_control_unregister();
 }
 
-MODULE_FIRMWARE(IWL3945_MODULE_FIRMWARE(IWL3945_UCODE_API_MAX));
+MODULE_FIRMWARE(IL3945_MODULE_FIRMWARE(IL3945_UCODE_API_MAX));
 
 module_param_named(antenna, il3945_mod_params.antenna, int, S_IRUGO);
 MODULE_PARM_DESC(antenna, "select antenna (1=Main, 2=Aux, default 0 [both])");
@@ -4002,7 +3998,7 @@ MODULE_PARM_DESC(swcrypto,
 module_param_named(disable_hw_scan, il3945_mod_params.disable_hw_scan,
                int, S_IRUGO);
 MODULE_PARM_DESC(disable_hw_scan, "disable hardware scanning (default 1)");
-#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG
+#ifdef CONFIG_IWLEGACY_DEBUG
 module_param_named(debug, il_debug_level, uint, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(debug, "debug output mask");
 #endif