]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/wireless/iwlwifi/iwl3945-base.c
iwl3945: include iwl-core.h
[linux-2.6-omap-h63xx.git] / drivers / net / wireless / iwlwifi / iwl3945-base.c
index d64580805d6efbef7cb48a5bafec23ca02f55f6d..c3fd7c651ba21615b3d913af20fdc6c4273540f9 100644 (file)
 
 #include <asm/div64.h>
 
-#include "iwl-3945-core.h"
+#define DRV_NAME       "iwl3945"
+
+#include "iwl-commands.h"
 #include "iwl-3945.h"
+#include "iwl-3945-fh.h"
 #include "iwl-helpers.h"
-
-#ifdef CONFIG_IWL3945_DEBUG
-u32 iwl3945_debug_level;
-#endif
+#include "iwl-core.h"
+#include "iwl-dev.h"
 
 static int iwl3945_tx_queue_update_write_ptr(struct iwl3945_priv *priv,
                                  struct iwl3945_tx_queue *txq);
@@ -73,7 +74,6 @@ int iwl3945_param_queues_num = IWL39_MAX_NUM_QUEUES; /* def: 8 Tx queues */
 
 /*
  * module name, copyright, version, etc.
- * NOTE: DRV_NAME is defined in iwlwifi.h for use by iwl-debug.h and printk
  */
 
 #define DRV_DESCRIPTION        \
@@ -91,10 +91,10 @@ int iwl3945_param_queues_num = IWL39_MAX_NUM_QUEUES; /* def: 8 Tx queues */
 #define VS
 #endif
 
-#define IWLWIFI_VERSION "1.2.26k" VD VS
+#define IWL39_VERSION "1.2.26k" VD VS
 #define DRV_COPYRIGHT  "Copyright(c) 2003-2008 Intel Corporation"
 #define DRV_AUTHOR     "<ilw@linux.intel.com>"
-#define DRV_VERSION     IWLWIFI_VERSION
+#define DRV_VERSION     IWL39_VERSION
 
 
 MODULE_DESCRIPTION(DRV_DESCRIPTION);
@@ -133,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;
@@ -298,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;
 
@@ -460,8 +433,6 @@ u8 iwl3945_add_station(struct iwl3945_priv *priv, const u8 *addr, int is_ap, u8
        /* Turn on both antennas for the station... */
        station->sta.rate_n_flags =
                        iwl3945_hw_set_rate_n_flags(rate, RATE_MCS_ANT_AB_MSK);
-       station->current_rate.rate_n_flags =
-                       le16_to_cpu(station->sta.rate_n_flags);
 
        spin_unlock_irqrestore(&priv->sta_lock, flags_spin);
 
@@ -520,56 +491,6 @@ static inline int iwl3945_is_ready_rf(struct iwl3945_priv *priv)
 /*************** HOST COMMAND QUEUE FUNCTIONS   *****/
 
 #define IWL_CMD(x) case x: return #x
-
-static const char *get_cmd_string(u8 cmd)
-{
-       switch (cmd) {
-               IWL_CMD(REPLY_ALIVE);
-               IWL_CMD(REPLY_ERROR);
-               IWL_CMD(REPLY_RXON);
-               IWL_CMD(REPLY_RXON_ASSOC);
-               IWL_CMD(REPLY_QOS_PARAM);
-               IWL_CMD(REPLY_RXON_TIMING);
-               IWL_CMD(REPLY_ADD_STA);
-               IWL_CMD(REPLY_REMOVE_STA);
-               IWL_CMD(REPLY_REMOVE_ALL_STA);
-               IWL_CMD(REPLY_3945_RX);
-               IWL_CMD(REPLY_TX);
-               IWL_CMD(REPLY_RATE_SCALE);
-               IWL_CMD(REPLY_LEDS_CMD);
-               IWL_CMD(REPLY_TX_LINK_QUALITY_CMD);
-               IWL_CMD(RADAR_NOTIFICATION);
-               IWL_CMD(REPLY_QUIET_CMD);
-               IWL_CMD(REPLY_CHANNEL_SWITCH);
-               IWL_CMD(CHANNEL_SWITCH_NOTIFICATION);
-               IWL_CMD(REPLY_SPECTRUM_MEASUREMENT_CMD);
-               IWL_CMD(SPECTRUM_MEASURE_NOTIFICATION);
-               IWL_CMD(POWER_TABLE_CMD);
-               IWL_CMD(PM_SLEEP_NOTIFICATION);
-               IWL_CMD(PM_DEBUG_STATISTIC_NOTIFIC);
-               IWL_CMD(REPLY_SCAN_CMD);
-               IWL_CMD(REPLY_SCAN_ABORT_CMD);
-               IWL_CMD(SCAN_START_NOTIFICATION);
-               IWL_CMD(SCAN_RESULTS_NOTIFICATION);
-               IWL_CMD(SCAN_COMPLETE_NOTIFICATION);
-               IWL_CMD(BEACON_NOTIFICATION);
-               IWL_CMD(REPLY_TX_BEACON);
-               IWL_CMD(WHO_IS_AWAKE_NOTIFICATION);
-               IWL_CMD(QUIET_NOTIFICATION);
-               IWL_CMD(REPLY_TX_PWR_TABLE_CMD);
-               IWL_CMD(MEASURE_ABORT_NOTIFICATION);
-               IWL_CMD(REPLY_BT_CONFIG);
-               IWL_CMD(REPLY_STATISTICS_CMD);
-               IWL_CMD(STATISTICS_NOTIFICATION);
-               IWL_CMD(REPLY_CARD_STATE_CMD);
-               IWL_CMD(CARD_STATE_NOTIFICATION);
-               IWL_CMD(MISSED_BEACONS_NOTIFICATION);
-       default:
-               return "UNKNOWN";
-
-       }
-}
-
 #define HOST_COMPLETE_TIMEOUT (HZ / 2)
 
 /**
@@ -584,7 +505,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;
@@ -599,7 +520,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));
 
 
@@ -608,7 +529,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;
        }
@@ -634,7 +555,7 @@ static int iwl3945_enqueue_hcmd(struct iwl3945_priv *priv, struct iwl3945_host_c
        out_cmd->hdr.sequence = cpu_to_le16(QUEUE_TO_SEQ(IWL_CMD_QUEUE_NUM) |
                        INDEX_TO_SEQ(q->write_ptr));
        if (out_cmd->meta.flags & CMD_SIZE_HUGE)
-               out_cmd->hdr.sequence |= cpu_to_le16(SEQ_HUGE_FRAME);
+               out_cmd->hdr.sequence |= SEQ_HUGE_FRAME;
 
        phys_addr = txq->dma_addr_cmd + sizeof(txq->cmd[0]) * idx +
                        offsetof(struct iwl3945_cmd, hdr);
@@ -745,7 +666,7 @@ static int iwl3945_send_cmd_sync(struct iwl3945_priv *priv, struct iwl3945_host_
                IWL_ERROR("Error: Response NULL in '%s'\n",
                          get_cmd_string(cmd->id));
                ret = -EIO;
-               goto out;
+               goto cancel;
        }
 
        ret = 0;
@@ -851,10 +772,11 @@ static int iwl3945_set_rxon_channel(struct iwl3945_priv *priv,
  * be #ifdef'd out once the driver is stable and folks aren't actively
  * making changes
  */
-static int iwl3945_check_rxon_cmd(struct iwl3945_rxon_cmd *rxon)
+static int iwl3945_check_rxon_cmd(struct iwl3945_priv *priv)
 {
        int error = 0;
        int counter = 1;
+       struct iwl3945_rxon_cmd *rxon = &priv->staging_rxon;
 
        if (rxon->flags & RXON_FLG_BAND_24G_MSK) {
                error |= le32_to_cpu(rxon->flags &
@@ -969,7 +891,7 @@ static int iwl3945_full_rxon_required(struct iwl3945_priv *priv)
 static int iwl3945_send_rxon_assoc(struct iwl3945_priv *priv)
 {
        int rc = 0;
-       struct iwl3945_rx_packet *res = NULL;
+       struct iwl_rx_packet *res = NULL;
        struct iwl3945_rxon_assoc_cmd rxon_assoc;
        struct iwl3945_host_cmd cmd = {
                .id = REPLY_RXON_ASSOC,
@@ -998,7 +920,7 @@ static int iwl3945_send_rxon_assoc(struct iwl3945_priv *priv)
        if (rc)
                return rc;
 
-       res = (struct iwl3945_rx_packet *)cmd.meta.u.skb->data;
+       res = (struct iwl_rx_packet *)cmd.meta.u.skb->data;
        if (res->hdr.flags & IWL_CMD_FAILED_MSK) {
                IWL_ERROR("Bad return from REPLY_RXON_ASSOC command\n");
                rc = -EIO;
@@ -1035,7 +957,7 @@ static int iwl3945_commit_rxon(struct iwl3945_priv *priv)
            ~(RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_SEL_MSK);
        priv->staging_rxon.flags |= iwl3945_get_antenna_flags(priv);
 
-       rc = iwl3945_check_rxon_cmd(&priv->staging_rxon);
+       rc = iwl3945_check_rxon_cmd(priv);
        if (rc) {
                IWL_ERROR("Invalid RXON configuration.  Not committing.\n");
                return -EINVAL;
@@ -1138,7 +1060,7 @@ static int iwl3945_commit_rxon(struct iwl3945_priv *priv)
 
 static int iwl3945_send_bt_config(struct iwl3945_priv *priv)
 {
-       struct iwl3945_bt_cmd bt_cmd = {
+       struct iwl_bt_cmd bt_cmd = {
                .flags = 3,
                .lead_time = 0xAA,
                .max_kill = 1,
@@ -1147,13 +1069,13 @@ static int iwl3945_send_bt_config(struct iwl3945_priv *priv)
        };
 
        return iwl3945_send_cmd_pdu(priv, REPLY_BT_CONFIG,
-                               sizeof(struct iwl3945_bt_cmd), &bt_cmd);
+                                       sizeof(bt_cmd), &bt_cmd);
 }
 
 static int iwl3945_send_scan_abort(struct iwl3945_priv *priv)
 {
        int rc = 0;
-       struct iwl3945_rx_packet *res;
+       struct iwl_rx_packet *res;
        struct iwl3945_host_cmd cmd = {
                .id = REPLY_SCAN_ABORT_CMD,
                .meta.flags = CMD_WANT_SKB,
@@ -1173,7 +1095,7 @@ static int iwl3945_send_scan_abort(struct iwl3945_priv *priv)
                return rc;
        }
 
-       res = (struct iwl3945_rx_packet *)cmd.meta.u.skb->data;
+       res = (struct iwl_rx_packet *)cmd.meta.u.skb->data;
        if (res->u.status != CAN_ABORT_STATUS) {
                /* The scan abort will return 1 for success or
                 * 2 for "failure".  A failure condition can be
@@ -1226,14 +1148,14 @@ static int iwl3945_send_card_state(struct iwl3945_priv *priv, u32 flags, u8 meta
 static int iwl3945_add_sta_sync_callback(struct iwl3945_priv *priv,
                                     struct iwl3945_cmd *cmd, struct sk_buff *skb)
 {
-       struct iwl3945_rx_packet *res = NULL;
+       struct iwl_rx_packet *res = NULL;
 
        if (!skb) {
                IWL_ERROR("Error: Response NULL in REPLY_ADD_STA.\n");
                return 1;
        }
 
-       res = (struct iwl3945_rx_packet *)skb->data;
+       res = (struct iwl_rx_packet *)skb->data;
        if (res->hdr.flags & IWL_CMD_FAILED_MSK) {
                IWL_ERROR("Bad return from REPLY_ADD_STA (0x%08X)\n",
                          res->hdr.flags);
@@ -1254,7 +1176,7 @@ static int iwl3945_add_sta_sync_callback(struct iwl3945_priv *priv,
 int iwl3945_send_add_station(struct iwl3945_priv *priv,
                         struct iwl3945_addsta_cmd *sta, u8 flags)
 {
-       struct iwl3945_rx_packet *res = NULL;
+       struct iwl_rx_packet *res = NULL;
        int rc = 0;
        struct iwl3945_host_cmd cmd = {
                .id = REPLY_ADD_STA,
@@ -1273,7 +1195,7 @@ int iwl3945_send_add_station(struct iwl3945_priv *priv,
        if (rc || (flags & CMD_ASYNC))
                return rc;
 
-       res = (struct iwl3945_rx_packet *)cmd.meta.u.skb->data;
+       res = (struct iwl_rx_packet *)cmd.meta.u.skb->data;
        if (res->hdr.flags & IWL_CMD_FAILED_MSK) {
                IWL_ERROR("Bad return from REPLY_ADD_STA (0x%08X)\n",
                          res->hdr.flags);
@@ -1342,7 +1264,8 @@ static int iwl3945_clear_sta_key_info(struct iwl3945_priv *priv, u8 sta_id)
 
        spin_lock_irqsave(&priv->sta_lock, flags);
        memset(&priv->stations[sta_id].keyinfo, 0, sizeof(struct iwl3945_hw_key));
-       memset(&priv->stations[sta_id].sta.key, 0, sizeof(struct iwl3945_keyinfo));
+       memset(&priv->stations[sta_id].sta.key, 0,
+               sizeof(struct iwl4965_keyinfo));
        priv->stations[sta_id].sta.key.key_flags = STA_KEY_FLG_NO_ENC;
        priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK;
        priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
@@ -1671,11 +1594,11 @@ static u16 iwl3945_fill_probe_req(struct iwl3945_priv *priv,
  * QoS  support
 */
 static int iwl3945_send_qos_params_command(struct iwl3945_priv *priv,
-                                      struct iwl3945_qosparam_cmd *qos)
+                                      struct iwl_qosparam_cmd *qos)
 {
 
        return iwl3945_send_cmd_pdu(priv, REPLY_QOS_PARAM,
-                               sizeof(struct iwl3945_qosparam_cmd), qos);
+                               sizeof(struct iwl_qosparam_cmd), qos);
 }
 
 static void iwl3945_reset_qos(struct iwl3945_priv *priv)
@@ -1804,8 +1727,9 @@ static void iwl3945_activate_qos(struct iwl3945_priv *priv, u8 force)
  */
 #define MSEC_TO_USEC 1024
 
-#define NOSLP __constant_cpu_to_le32(0)
-#define SLP IWL_POWER_DRIVER_ALLOW_SLEEP_MSK
+
+#define NOSLP __constant_cpu_to_le16(0), 0, 0
+#define SLP IWL_POWER_DRIVER_ALLOW_SLEEP_MSK, 0, 0
 #define SLP_TIMEOUT(T) __constant_cpu_to_le32((T) * MSEC_TO_USEC)
 #define SLP_VEC(X0, X1, X2, X3, X4) {__constant_cpu_to_le32(X0), \
                                     __constant_cpu_to_le32(X1), \
@@ -1813,10 +1737,9 @@ static void iwl3945_activate_qos(struct iwl3945_priv *priv, u8 force)
                                     __constant_cpu_to_le32(X3), \
                                     __constant_cpu_to_le32(X4)}
 
-
 /* 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},
@@ -1826,7 +1749,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},
@@ -1843,7 +1766,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");
@@ -1862,11 +1785,11 @@ int iwl3945_power_init_handle(struct iwl3945_priv *priv)
        if (rc != 0)
                return 0;
        else {
-               struct iwl3945_powertable_cmd *cmd;
+               struct iwl_powertable_cmd *cmd;
 
                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)
@@ -1879,12 +1802,12 @@ int iwl3945_power_init_handle(struct iwl3945_priv *priv)
 }
 
 static int iwl3945_update_power_cmd(struct iwl3945_priv *priv,
-                               struct iwl3945_powertable_cmd *cmd, u32 mode)
+                               struct iwl_powertable_cmd *cmd, u32 mode)
 {
        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;
 
@@ -1946,16 +1869,16 @@ static int iwl3945_send_power_mode(struct iwl3945_priv *priv, u32 mode)
 {
        u32 uninitialized_var(final_mode);
        int rc;
-       struct iwl3945_powertable_cmd cmd;
+       struct iwl_powertable_cmd cmd;
 
        /* If on battery, set to 3,
         * 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:
@@ -1965,7 +1888,9 @@ static int iwl3945_send_power_mode(struct iwl3945_priv *priv, u32 mode)
 
        iwl3945_update_power_cmd(priv, &cmd, final_mode);
 
-       rc = iwl3945_send_cmd_pdu(priv, POWER_TABLE_CMD, sizeof(cmd), &cmd);
+       /* FIXME use get_hcmd_size 3945 command is 4 bytes shorter */
+       rc = iwl3945_send_cmd_pdu(priv, POWER_TABLE_CMD,
+                               sizeof(struct iwl3945_powertable_cmd), &cmd);
 
        if (final_mode == IWL_POWER_MODE_CAM)
                clear_bit(STATUS_POWER_PMI, &priv->status);
@@ -2054,13 +1979,10 @@ static void iwl3945_setup_rxon_timing(struct iwl3945_priv *priv)
        conf = ieee80211_get_hw_conf(priv->hw);
 
        spin_lock_irqsave(&priv->lock, flags);
-       priv->rxon_timing.timestamp.dw[1] = cpu_to_le32(priv->timestamp1);
-       priv->rxon_timing.timestamp.dw[0] = cpu_to_le32(priv->timestamp0);
-
+       priv->rxon_timing.timestamp = cpu_to_le64(priv->timestamp);
        priv->rxon_timing.listen_interval = INTEL_CONN_LISTEN_INTERVAL;
 
-       tsf = priv->timestamp1;
-       tsf = ((tsf << 32) | priv->timestamp0);
+       tsf = priv->timestamp;
 
        beacon_int = priv->beacon_int;
        spin_unlock_irqrestore(&priv->lock, flags);
@@ -2173,7 +2095,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));
 
@@ -2243,7 +2165,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,
@@ -2434,7 +2356,7 @@ static int iwl3945_get_sta_id(struct iwl3945_priv *priv, struct ieee80211_hdr *h
                IWL_DEBUG_DROP("Station %pM not in station map. "
                               "Defaulting to broadcast...\n",
                               hdr->addr1);
-               iwl3945_print_hex_dump(IWL_DL_DROP, (u8 *) hdr, sizeof(*hdr));
+               iwl_print_hex_dump(priv, IWL_DL_DROP, (u8 *) hdr, sizeof(*hdr));
                return priv->hw_setting.bcast_sta_id;
        }
        /* If we are in monitor mode, use BCAST. This is required for
@@ -2459,7 +2381,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;
@@ -2578,7 +2500,7 @@ static int iwl3945_tx_skb(struct iwl3945_priv *priv, struct sk_buff *skb)
         * We'll tell device about this padding later.
         */
        len = priv->hw_setting.tx_cmd_len +
-               sizeof(struct iwl3945_cmd_header) + hdr_len;
+                       sizeof(struct iwl_cmd_header) + hdr_len;
 
        len_org = len;
        len = (len + 3) & ~3;
@@ -2640,10 +2562,10 @@ static int iwl3945_tx_skb(struct iwl3945_priv *priv, struct sk_buff *skb)
                txq->need_update = 0;
        }
 
-       iwl3945_print_hex_dump(IWL_DL_TX, out_cmd->cmd.payload,
+       iwl_print_hex_dump(priv, IWL_DL_TX, out_cmd->cmd.payload,
                           sizeof(out_cmd->cmd.tx));
 
-       iwl3945_print_hex_dump(IWL_DL_TX, (u8 *)out_cmd->cmd.tx.hdr,
+       iwl_print_hex_dump(priv, IWL_DL_TX, (u8 *)out_cmd->cmd.tx.hdr,
                           ieee80211_hdrlen(fc));
 
        /* Tell device the write index *just past* this latest filled TFD */
@@ -2654,7 +2576,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);
@@ -2867,8 +2789,8 @@ static int iwl3945_get_measurement(struct iwl3945_priv *priv,
                               struct ieee80211_measurement_params *params,
                               u8 type)
 {
-       struct iwl3945_spectrum_cmd spectrum;
-       struct iwl3945_rx_packet *res;
+       struct iwl_spectrum_cmd spectrum;
+       struct iwl_rx_packet *res;
        struct iwl3945_host_cmd cmd = {
                .id = REPLY_SPECTRUM_MEASUREMENT_CMD,
                .data = (void *)&spectrum,
@@ -2913,7 +2835,7 @@ static int iwl3945_get_measurement(struct iwl3945_priv *priv,
        if (rc)
                return rc;
 
-       res = (struct iwl3945_rx_packet *)cmd.meta.u.skb->data;
+       res = (struct iwl_rx_packet *)cmd.meta.u.skb->data;
        if (res->hdr.flags & IWL_CMD_FAILED_MSK) {
                IWL_ERROR("Bad return from REPLY_RX_ON_ASSOC command\n");
                rc = -EIO;
@@ -2945,8 +2867,8 @@ static int iwl3945_get_measurement(struct iwl3945_priv *priv,
 static void iwl3945_rx_reply_alive(struct iwl3945_priv *priv,
                               struct iwl3945_rx_mem_buffer *rxb)
 {
-       struct iwl3945_rx_packet *pkt = (void *)rxb->skb->data;
-       struct iwl3945_alive_resp *palive;
+       struct iwl_rx_packet *pkt = (void *)rxb->skb->data;
+       struct iwl_alive_resp *palive;
        struct delayed_work *pwork;
 
        palive = &pkt->u.alive_frame;
@@ -2958,14 +2880,13 @@ static void iwl3945_rx_reply_alive(struct iwl3945_priv *priv,
 
        if (palive->ver_subtype == INITIALIZE_SUBTYPE) {
                IWL_DEBUG_INFO("Initialization Alive received.\n");
-               memcpy(&priv->card_alive_init,
-                      &pkt->u.alive_frame,
-                      sizeof(struct iwl3945_init_alive_resp));
+               memcpy(&priv->card_alive_init, &pkt->u.alive_frame,
+                      sizeof(struct iwl_alive_resp));
                pwork = &priv->init_alive_start;
        } else {
                IWL_DEBUG_INFO("Runtime Alive received.\n");
                memcpy(&priv->card_alive, &pkt->u.alive_frame,
-                      sizeof(struct iwl3945_alive_resp));
+                      sizeof(struct iwl_alive_resp));
                pwork = &priv->alive_start;
                iwl3945_disable_events(priv);
        }
@@ -2982,7 +2903,7 @@ static void iwl3945_rx_reply_alive(struct iwl3945_priv *priv,
 static void iwl3945_rx_reply_add_sta(struct iwl3945_priv *priv,
                                 struct iwl3945_rx_mem_buffer *rxb)
 {
-       struct iwl3945_rx_packet *pkt = (void *)rxb->skb->data;
+       struct iwl_rx_packet *pkt = (void *)rxb->skb->data;
 
        IWL_DEBUG_RX("Received REPLY_ADD_STA: 0x%02X\n", pkt->u.status);
        return;
@@ -2991,7 +2912,7 @@ static void iwl3945_rx_reply_add_sta(struct iwl3945_priv *priv,
 static void iwl3945_rx_reply_error(struct iwl3945_priv *priv,
                               struct iwl3945_rx_mem_buffer *rxb)
 {
-       struct iwl3945_rx_packet *pkt = (void *)rxb->skb->data;
+       struct iwl_rx_packet *pkt = (void *)rxb->skb->data;
 
        IWL_ERROR("Error Reply type 0x%08X cmd %s (0x%02X) "
                "seq 0x%04X ser 0x%08X\n",
@@ -3006,9 +2927,9 @@ static void iwl3945_rx_reply_error(struct iwl3945_priv *priv,
 
 static void iwl3945_rx_csa(struct iwl3945_priv *priv, struct iwl3945_rx_mem_buffer *rxb)
 {
-       struct iwl3945_rx_packet *pkt = (void *)rxb->skb->data;
+       struct iwl_rx_packet *pkt = (void *)rxb->skb->data;
        struct iwl3945_rxon_cmd *rxon = (void *)&priv->active_rxon;
-       struct iwl3945_csa_notification *csa = &(pkt->u.csa_notif);
+       struct iwl_csa_notification *csa = &(pkt->u.csa_notif);
        IWL_DEBUG_11H("CSA notif: channel %d, status %d\n",
                      le16_to_cpu(csa->channel), le32_to_cpu(csa->status));
        rxon->channel = csa->channel;
@@ -3019,8 +2940,8 @@ static void iwl3945_rx_spectrum_measure_notif(struct iwl3945_priv *priv,
                                          struct iwl3945_rx_mem_buffer *rxb)
 {
 #ifdef CONFIG_IWL3945_SPECTRUM_MEASUREMENT
-       struct iwl3945_rx_packet *pkt = (void *)rxb->skb->data;
-       struct iwl3945_spectrum_notification *report = &(pkt->u.spectrum_notif);
+       struct iwl_rx_packet *pkt = (void *)rxb->skb->data;
+       struct iwl_spectrum_notification *report = &(pkt->u.spectrum_notif);
 
        if (!report->state) {
                IWL_DEBUG(IWL_DL_11H | IWL_DL_INFO,
@@ -3037,8 +2958,8 @@ static void iwl3945_rx_pm_sleep_notif(struct iwl3945_priv *priv,
                                  struct iwl3945_rx_mem_buffer *rxb)
 {
 #ifdef CONFIG_IWL3945_DEBUG
-       struct iwl3945_rx_packet *pkt = (void *)rxb->skb->data;
-       struct iwl3945_sleep_notification *sleep = &(pkt->u.sleep_notif);
+       struct iwl_rx_packet *pkt = (void *)rxb->skb->data;
+       struct iwl_sleep_notification *sleep = &(pkt->u.sleep_notif);
        IWL_DEBUG_RX("sleep mode: %d, src: %d\n",
                     sleep->pm_sleep_mode, sleep->pm_wakeup_src);
 #endif
@@ -3047,11 +2968,12 @@ static void iwl3945_rx_pm_sleep_notif(struct iwl3945_priv *priv,
 static void iwl3945_rx_pm_debug_statistics_notif(struct iwl3945_priv *priv,
                                             struct iwl3945_rx_mem_buffer *rxb)
 {
-       struct iwl3945_rx_packet *pkt = (void *)rxb->skb->data;
+       struct iwl_rx_packet *pkt = (void *)rxb->skb->data;
        IWL_DEBUG_RADIO("Dumping %d bytes of unhandled "
                        "notification for %s:\n",
                        le32_to_cpu(pkt->len), get_cmd_string(pkt->hdr.cmd));
-       iwl3945_print_hex_dump(IWL_DL_RADIO, pkt->u.raw, le32_to_cpu(pkt->len));
+       iwl_print_hex_dump(priv, IWL_DL_RADIO, pkt->u.raw,
+                          le32_to_cpu(pkt->len));
 }
 
 static void iwl3945_bg_beacon_update(struct work_struct *work)
@@ -3083,7 +3005,7 @@ static void iwl3945_rx_beacon_notif(struct iwl3945_priv *priv,
                                struct iwl3945_rx_mem_buffer *rxb)
 {
 #ifdef CONFIG_IWL3945_DEBUG
-       struct iwl3945_rx_packet *pkt = (void *)rxb->skb->data;
+       struct iwl_rx_packet *pkt = (void *)rxb->skb->data;
        struct iwl3945_beacon_notif *beacon = &(pkt->u.beacon_status);
        u8 rate = beacon->beacon_notify_hdr.rate;
 
@@ -3106,9 +3028,9 @@ static void iwl3945_rx_reply_scan(struct iwl3945_priv *priv,
                              struct iwl3945_rx_mem_buffer *rxb)
 {
 #ifdef CONFIG_IWL3945_DEBUG
-       struct iwl3945_rx_packet *pkt = (void *)rxb->skb->data;
-       struct iwl3945_scanreq_notification *notif =
-           (struct iwl3945_scanreq_notification *)pkt->u.raw;
+       struct iwl_rx_packet *pkt = (void *)rxb->skb->data;
+       struct iwl_scanreq_notification *notif =
+           (struct iwl_scanreq_notification *)pkt->u.raw;
 
        IWL_DEBUG_RX("Scan request status = 0x%x\n", notif->status);
 #endif
@@ -3118,9 +3040,9 @@ static void iwl3945_rx_reply_scan(struct iwl3945_priv *priv,
 static void iwl3945_rx_scan_start_notif(struct iwl3945_priv *priv,
                                    struct iwl3945_rx_mem_buffer *rxb)
 {
-       struct iwl3945_rx_packet *pkt = (void *)rxb->skb->data;
-       struct iwl3945_scanstart_notification *notif =
-           (struct iwl3945_scanstart_notification *)pkt->u.raw;
+       struct iwl_rx_packet *pkt = (void *)rxb->skb->data;
+       struct iwl_scanstart_notification *notif =
+           (struct iwl_scanstart_notification *)pkt->u.raw;
        priv->scan_start_tsf = le32_to_cpu(notif->tsf_low);
        IWL_DEBUG_SCAN("Scan start: "
                       "%d [802.11%s] "
@@ -3135,9 +3057,9 @@ static void iwl3945_rx_scan_start_notif(struct iwl3945_priv *priv,
 static void iwl3945_rx_scan_results_notif(struct iwl3945_priv *priv,
                                      struct iwl3945_rx_mem_buffer *rxb)
 {
-       struct iwl3945_rx_packet *pkt = (void *)rxb->skb->data;
-       struct iwl3945_scanresults_notification *notif =
-           (struct iwl3945_scanresults_notification *)pkt->u.raw;
+       struct iwl_rx_packet *pkt = (void *)rxb->skb->data;
+       struct iwl_scanresults_notification *notif =
+           (struct iwl_scanresults_notification *)pkt->u.raw;
 
        IWL_DEBUG_SCAN("Scan ch.res: "
                       "%d [802.11%s] "
@@ -3160,8 +3082,8 @@ static void iwl3945_rx_scan_results_notif(struct iwl3945_priv *priv,
 static void iwl3945_rx_scan_complete_notif(struct iwl3945_priv *priv,
                                       struct iwl3945_rx_mem_buffer *rxb)
 {
-       struct iwl3945_rx_packet *pkt = (void *)rxb->skb->data;
-       struct iwl3945_scancomplete_notification *scan_notif = (void *)pkt->u.raw;
+       struct iwl_rx_packet *pkt = (void *)rxb->skb->data;
+       struct iwl_scancomplete_notification *scan_notif = (void *)pkt->u.raw;
 
        IWL_DEBUG_SCAN("Scan complete: %d channels (TSF 0x%08X:%08X) - %d\n",
                       scan_notif->scanned_channels,
@@ -3223,7 +3145,7 @@ reschedule:
 static void iwl3945_rx_card_state_notif(struct iwl3945_priv *priv,
                                    struct iwl3945_rx_mem_buffer *rxb)
 {
-       struct iwl3945_rx_packet *pkt = (void *)rxb->skb->data;
+       struct iwl_rx_packet *pkt = (void *)rxb->skb->data;
        u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags);
        unsigned long status = priv->status;
 
@@ -3307,7 +3229,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)) {
@@ -3341,11 +3263,11 @@ static void iwl3945_cmd_queue_reclaim(struct iwl3945_priv *priv,
 static void iwl3945_tx_cmd_complete(struct iwl3945_priv *priv,
                                struct iwl3945_rx_mem_buffer *rxb)
 {
-       struct iwl3945_rx_packet *pkt = (struct iwl3945_rx_packet *)rxb->skb->data;
+       struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data;
        u16 sequence = le16_to_cpu(pkt->hdr.sequence);
        int txq_id = SEQ_TO_QUEUE(sequence);
        int index = SEQ_TO_INDEX(sequence);
-       int huge = sequence & SEQ_HUGE_FRAME;
+       int huge =  !!(pkt->hdr.sequence & SEQ_HUGE_FRAME);
        int cmd_index;
        struct iwl3945_cmd *cmd;
 
@@ -3479,14 +3401,14 @@ int iwl3945_rx_queue_update_write_ptr(struct iwl3945_priv *priv, struct iwl3945_
                        goto exit_unlock;
 
                /* Device expects a multiple of 8 */
-               iwl3945_write_direct32(priv, FH_RSCSR_CHNL0_WPTR,
+               iwl3945_write_direct32(priv, FH39_RSCSR_CHNL0_WPTR,
                                     q->write & ~0x7);
                iwl3945_release_nic_access(priv);
 
        /* Else device is assumed to be awake */
        } else
                /* Device expects a multiple of 8 */
-               iwl3945_write32(priv, FH_RSCSR_CHNL0_WPTR, q->write & ~0x7);
+               iwl3945_write32(priv, FH39_RSCSR_CHNL0_WPTR, q->write & ~0x7);
 
 
        q->need_update = 0;
@@ -3803,7 +3725,7 @@ int iwl3945_calc_sig_qual(int rssi_dbm, int noise_dbm)
 static void iwl3945_rx_handle(struct iwl3945_priv *priv)
 {
        struct iwl3945_rx_mem_buffer *rxb;
-       struct iwl3945_rx_packet *pkt;
+       struct iwl_rx_packet *pkt;
        struct iwl3945_rx_queue *rxq = &priv->rxq;
        u32 r, i;
        int reclaim;
@@ -3835,7 +3757,7 @@ static void iwl3945_rx_handle(struct iwl3945_priv *priv)
                pci_dma_sync_single_for_cpu(priv->pci_dev, rxb->dma_addr,
                                            IWL_RX_BUF_SIZE,
                                            PCI_DMA_FROMDEVICE);
-               pkt = (struct iwl3945_rx_packet *)rxb->skb->data;
+               pkt = (struct iwl_rx_packet *)rxb->skb->data;
 
                /* Reclaim a command buffer only if this packet is a response
                 *   to a (driver-originated) command.
@@ -3851,13 +3773,13 @@ static void iwl3945_rx_handle(struct iwl3945_priv *priv)
                 *   handle those that need handling via function in
                 *   rx_handlers table.  See iwl3945_setup_rx_handlers() */
                if (priv->rx_handlers[pkt->hdr.cmd]) {
-                       IWL_DEBUG(IWL_DL_HOST_COMMAND | IWL_DL_RX | IWL_DL_ISR,
+                       IWL_DEBUG(IWL_DL_HCMD | IWL_DL_RX | IWL_DL_ISR,
                                "r = %d, i = %d, %s, 0x%02x\n", r, i,
                                get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd);
                        priv->rx_handlers[pkt->hdr.cmd] (priv, rxb);
                } else {
                        /* No handling needed */
-                       IWL_DEBUG(IWL_DL_HOST_COMMAND | IWL_DL_RX | IWL_DL_ISR,
+                       IWL_DEBUG(IWL_DL_HCMD | IWL_DL_RX | IWL_DL_ISR,
                                "r %d i %d No handler needed for %s, 0x%02x\n",
                                r, i, get_cmd_string(pkt->hdr.cmd),
                                pkt->hdr.cmd);
@@ -3952,10 +3874,11 @@ static int iwl3945_tx_queue_update_write_ptr(struct iwl3945_priv *priv,
 }
 
 #ifdef CONFIG_IWL3945_DEBUG
-static void iwl3945_print_rx_config_cmd(struct iwl3945_rxon_cmd *rxon)
+static void iwl3945_print_rx_config_cmd(struct iwl3945_priv *priv,
+                                       struct iwl3945_rxon_cmd *rxon)
 {
        IWL_DEBUG_RADIO("RX CONFIG:\n");
-       iwl3945_print_hex_dump(IWL_DL_RADIO, (u8 *) rxon, sizeof(*rxon));
+       iwl_print_hex_dump(priv, IWL_DL_RADIO, (u8 *) rxon, sizeof(*rxon));
        IWL_DEBUG_RADIO("u16 channel: 0x%x\n", le16_to_cpu(rxon->channel));
        IWL_DEBUG_RADIO("u32 flags: 0x%08X\n", le32_to_cpu(rxon->flags));
        IWL_DEBUG_RADIO("u32 filter_flags: 0x%08x\n",
@@ -4189,10 +4112,10 @@ static void iwl3945_irq_handle_error(struct iwl3945_priv *priv)
        clear_bit(STATUS_HCMD_ACTIVE, &priv->status);
 
 #ifdef CONFIG_IWL3945_DEBUG
-       if (iwl3945_debug_level & IWL_DL_FW_ERRORS) {
+       if (priv->debug_level & IWL_DL_FW_ERRORS) {
                iwl3945_dump_nic_error_log(priv);
                iwl3945_dump_nic_event_log(priv);
-               iwl3945_print_rx_config_cmd(&priv->staging_rxon);
+               iwl3945_print_rx_config_cmd(priv, &priv->staging_rxon);
        }
 #endif
 
@@ -4256,7 +4179,7 @@ static void iwl3945_irq_tasklet(struct iwl3945_priv *priv)
        iwl3945_write32(priv, CSR_FH_INT_STATUS, inta_fh);
 
 #ifdef CONFIG_IWL3945_DEBUG
-       if (iwl3945_debug_level & IWL_DL_ISR) {
+       if (priv->debug_level & IWL_DL_ISR) {
                /* just for debug */
                inta_mask = iwl3945_read32(priv, CSR_INT_MASK);
                IWL_DEBUG_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n",
@@ -4290,7 +4213,7 @@ static void iwl3945_irq_tasklet(struct iwl3945_priv *priv)
        }
 
 #ifdef CONFIG_IWL3945_DEBUG
-       if (iwl3945_debug_level & (IWL_DL_ISR)) {
+       if (priv->debug_level & (IWL_DL_ISR)) {
                /* NIC fires this, but we don't use it, redundant with WAKEUP */
                if (inta & CSR_INT_BIT_SCD)
                        IWL_DEBUG_ISR("Scheduler finished to transmit "
@@ -4339,9 +4262,8 @@ static void iwl3945_irq_tasklet(struct iwl3945_priv *priv)
 
                iwl3945_write32(priv, CSR_FH_INT_STATUS, (1 << 6));
                if (!iwl3945_grab_nic_access(priv)) {
-                       iwl3945_write_direct32(priv,
-                                            FH_TCSR_CREDIT
-                                            (ALM_FH_SRVC_CHNL), 0x0);
+                       iwl3945_write_direct32(priv, FH39_TCSR_CREDIT
+                                            (FH39_SRVC_CHNL), 0x0);
                        iwl3945_release_nic_access(priv);
                }
                handled |= CSR_INT_BIT_FH_TX;
@@ -4362,7 +4284,7 @@ static void iwl3945_irq_tasklet(struct iwl3945_priv *priv)
                iwl3945_enable_interrupts(priv);
 
 #ifdef CONFIG_IWL3945_DEBUG
-       if (iwl3945_debug_level & (IWL_DL_ISR)) {
+       if (priv->debug_level & (IWL_DL_ISR)) {
                inta = iwl3945_read32(priv, CSR_INT);
                inta_mask = iwl3945_read32(priv, CSR_INT_MASK);
                inta_fh = iwl3945_read32(priv, CSR_FH_INT_STATUS);
@@ -4485,7 +4407,7 @@ static const u8 iwl3945_eeprom_band_5[] = {       /* 5725-5825MHz */
 
 static void iwl3945_init_band_reference(const struct iwl3945_priv *priv, int band,
                                    int *eeprom_ch_count,
-                                   const struct iwl3945_eeprom_channel
+                                   const struct iwl_eeprom_channel
                                    **eeprom_ch_info,
                                    const u8 **eeprom_ch_index)
 {
@@ -4526,8 +4448,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,9 +4483,9 @@ static int iwl3945_init_channel_map(struct iwl3945_priv *priv)
 {
        int eeprom_ch_count = 0;
        const u8 *eeprom_ch_index = NULL;
-       const struct iwl3945_eeprom_channel *eeprom_ch_info = 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");
@@ -4586,7 +4509,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");
@@ -4748,7 +4671,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;
@@ -4845,7 +4768,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.
                         */
@@ -4860,7 +4783,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;
@@ -5020,7 +4943,8 @@ static int iwl3945_verify_inst_full(struct iwl3945_priv *priv, __le32 *image, u3
        if (rc)
                return rc;
 
-       iwl3945_write_direct32(priv, HBUS_TARG_MEM_RADDR, RTC_INST_LOWER_BOUND);
+       iwl3945_write_direct32(priv, HBUS_TARG_MEM_RADDR,
+                              IWL39_RTC_INST_LOWER_BOUND);
 
        errcnt = 0;
        for (; len > 0; len -= sizeof(u32), image++) {
@@ -5071,7 +4995,7 @@ static int iwl3945_verify_inst_sparse(struct iwl3945_priv *priv, __le32 *image,
                /* NOTE: Use the debugless read so we don't flood kernel log
                 * if IWL_DL_IO is set */
                iwl3945_write_direct32(priv, HBUS_TARG_MEM_RADDR,
-                       i + RTC_INST_LOWER_BOUND);
+                       i + IWL39_RTC_INST_LOWER_BOUND);
                val = _iwl3945_read_direct32(priv, HBUS_TARG_MEM_RDAT);
                if (val != le32_to_cpu(*image)) {
 #if 0 /* Enable this if you want to see details */
@@ -5221,7 +5145,7 @@ static int iwl3945_load_bsm(struct iwl3945_priv *priv)
        IWL_DEBUG_INFO("Begin load bsm\n");
 
        /* make sure bootstrap program is no larger than BSM's SRAM size */
-       if (len > IWL_MAX_BSM_SIZE)
+       if (len > IWL39_MAX_BSM_SIZE)
                return -EINVAL;
 
        /* Tell bootstrap uCode where to find the "Initialize" uCode
@@ -5259,7 +5183,7 @@ static int iwl3945_load_bsm(struct iwl3945_priv *priv)
        /* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */
        iwl3945_write_prph(priv, BSM_WR_MEM_SRC_REG, 0x0);
        iwl3945_write_prph(priv, BSM_WR_MEM_DST_REG,
-                                RTC_INST_LOWER_BOUND);
+                                IWL39_RTC_INST_LOWER_BOUND);
        iwl3945_write_prph(priv, BSM_WR_DWCOUNT_REG, len / sizeof(u32));
 
        /* Load bootstrap code into instruction SRAM now,
@@ -5403,32 +5327,32 @@ static int iwl3945_read_ucode(struct iwl3945_priv *priv)
        }
 
        /* Verify that uCode images will fit in card's SRAM */
-       if (inst_size > IWL_MAX_INST_SIZE) {
+       if (inst_size > IWL39_MAX_INST_SIZE) {
                IWL_DEBUG_INFO("uCode instr len %d too large to fit in\n",
                               inst_size);
                ret = -EINVAL;
                goto err_release;
        }
 
-       if (data_size > IWL_MAX_DATA_SIZE) {
+       if (data_size > IWL39_MAX_DATA_SIZE) {
                IWL_DEBUG_INFO("uCode data len %d too large to fit in\n",
                               data_size);
                ret = -EINVAL;
                goto err_release;
        }
-       if (init_size > IWL_MAX_INST_SIZE) {
+       if (init_size > IWL39_MAX_INST_SIZE) {
                IWL_DEBUG_INFO("uCode init instr len %d too large to fit in\n",
                                init_size);
                ret = -EINVAL;
                goto err_release;
        }
-       if (init_data_size > IWL_MAX_DATA_SIZE) {
+       if (init_data_size > IWL39_MAX_DATA_SIZE) {
                IWL_DEBUG_INFO("uCode init data len %d too large to fit in\n",
                                init_data_size);
                ret = -EINVAL;
                goto err_release;
        }
-       if (boot_size > IWL_MAX_BSM_SIZE) {
+       if (boot_size > IWL39_MAX_BSM_SIZE) {
                IWL_DEBUG_INFO("uCode boot instr len %d too large to fit in\n",
                                boot_size);
                ret = -EINVAL;
@@ -5837,7 +5761,7 @@ static void __iwl3945_down(struct iwl3945_priv *priv)
        iwl3945_hw_nic_reset(priv);
 
  exit:
-       memset(&priv->card_alive, 0, sizeof(struct iwl3945_alive_resp));
+       memset(&priv->card_alive, 0, sizeof(struct iwl_alive_resp));
 
        if (priv->ibss_beacon)
                dev_kfree_skb(priv->ibss_beacon);
@@ -6303,7 +6227,7 @@ static void iwl3945_post_associate(struct iwl3945_priv *priv)
        priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
        iwl3945_commit_rxon(priv);
 
-       memset(&priv->rxon_timing, 0, sizeof(struct iwl3945_rxon_time_cmd));
+       memset(&priv->rxon_timing, 0, sizeof(struct iwl_rxon_time_cmd));
        iwl3945_setup_rxon_timing(priv);
        rc = iwl3945_send_cmd_pdu(priv, REPLY_RXON_TIMING,
                              sizeof(priv->rxon_timing), &priv->rxon_timing);
@@ -6538,7 +6462,7 @@ static int iwl3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
                dev_kfree_skb_any(skb);
 
        IWL_DEBUG_MAC80211("leave\n");
-       return 0;
+       return NETDEV_TX_OK;
 }
 
 static int iwl3945_mac_add_interface(struct ieee80211_hw *hw,
@@ -6586,7 +6510,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;
@@ -6683,7 +6607,7 @@ static void iwl3945_config_ap(struct iwl3945_priv *priv)
                iwl3945_commit_rxon(priv);
 
                /* RXON Timing */
-               memset(&priv->rxon_timing, 0, sizeof(struct iwl3945_rxon_time_cmd));
+               memset(&priv->rxon_timing, 0, sizeof(struct iwl_rxon_time_cmd));
                iwl3945_setup_rxon_timing(priv);
                rc = iwl3945_send_cmd_pdu(priv, REPLY_RXON_TIMING,
                                sizeof(priv->rxon_timing), &priv->rxon_timing);
@@ -6931,9 +6855,7 @@ static void iwl3945_bss_info_changed(struct ieee80211_hw *hw,
                if (bss_conf->assoc) {
                        priv->assoc_id = bss_conf->aid;
                        priv->beacon_int = bss_conf->beacon_int;
-                       priv->timestamp0 = bss_conf->timestamp & 0xFFFFFFFF;
-                       priv->timestamp1 = (bss_conf->timestamp >> 32) &
-                                            0xFFFFFFFF;
+                       priv->timestamp = bss_conf->timestamp;
                        priv->assoc_capability = bss_conf->assoc_capability;
                        priv->next_scan_jiffies = jiffies +
                                        IWL_DELAY_NEXT_SCAN_AFTER_ASSOC;
@@ -7115,7 +7037,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");
@@ -7130,7 +7052,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;
@@ -7144,15 +7066,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)
-{
-       IWL_DEBUG_MAC80211("enter\n");
-       IWL_DEBUG_MAC80211("leave\n");
-
-       return 0;
-}
-
 static void iwl3945_mac_reset_tsf(struct ieee80211_hw *hw)
 {
        struct iwl3945_priv *priv = hw->priv;
@@ -7175,8 +7088,7 @@ static void iwl3945_mac_reset_tsf(struct ieee80211_hw *hw)
        priv->ibss_beacon = NULL;
 
        priv->beacon_int = priv->hw->conf.beacon_int;
-       priv->timestamp1 = 0;
-       priv->timestamp0 = 0;
+       priv->timestamp = 0;
        if ((priv->iw_mode == NL80211_IFTYPE_STATION))
                priv->beacon_int = 0;
 
@@ -7265,29 +7177,33 @@ static int iwl3945_mac_beacon_update(struct ieee80211_hw *hw, struct sk_buff *sk
  *
  * See the level definitions in iwl for details.
  */
-
-static ssize_t show_debug_level(struct device_driver *d, char *buf)
+static ssize_t show_debug_level(struct device *d,
+                               struct device_attribute *attr, char *buf)
 {
-       return sprintf(buf, "0x%08X\n", iwl3945_debug_level);
+       struct iwl3945_priv *priv = d->driver_data;
+
+       return sprintf(buf, "0x%08X\n", priv->debug_level);
 }
-static ssize_t store_debug_level(struct device_driver *d,
+static ssize_t store_debug_level(struct device *d,
+                               struct device_attribute *attr,
                                 const char *buf, size_t count)
 {
-       char *p = (char *)buf;
-       u32 val;
+       struct iwl3945_priv *priv = d->driver_data;
+       unsigned long val;
+       int ret;
 
-       val = simple_strtoul(p, &p, 0);
-       if (p == buf)
+       ret = strict_strtoul(buf, 0, &val);
+       if (ret)
                printk(KERN_INFO DRV_NAME
                       ": %s is not in hex or decimal form.\n", buf);
        else
-               iwl3945_debug_level = val;
+               priv->debug_level = val;
 
        return strnlen(buf, count);
 }
 
-static DRIVER_ATTR(debug_level, S_IWUSR | S_IRUGO,
-                  show_debug_level, store_debug_level);
+static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO,
+                       show_debug_level, store_debug_level);
 
 #endif /* CONFIG_IWL3945_DEBUG */
 
@@ -7408,7 +7324,7 @@ static ssize_t show_measurement(struct device *d,
                                struct device_attribute *attr, char *buf)
 {
        struct iwl3945_priv *priv = dev_get_drvdata(d);
-       struct iwl3945_spectrum_notification measure_report;
+       struct iwl_spectrum_notification measure_report;
        u32 size = sizeof(measure_report), len = 0, ofs = 0;
        u8 *data = (u8 *)&measure_report;
        unsigned long flags;
@@ -7514,8 +7430,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;
 
@@ -7563,10 +7480,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:
@@ -7768,7 +7685,9 @@ static struct attribute *iwl3945_sysfs_entries[] = {
        &dev_attr_status.attr,
        &dev_attr_temperature.attr,
        &dev_attr_tx_power.attr,
-
+#ifdef CONFIG_IWL3945_DEBUG
+       &dev_attr_debug_level.attr,
+#endif
        NULL
 };
 
@@ -7787,7 +7706,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,
@@ -7807,26 +7725,11 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
         * 1. Allocating HW data
         * ********************/
 
-       /* Disabling hardware scan means that mac80211 will perform scans
-        * "the hard way", rather than using device's scan. */
-       if (iwl3945_param_disable_hw_scan) {
-               IWL_DEBUG_INFO("Disabling hw_scan\n");
-               iwl3945_hw_ops.hw_scan = NULL;
-       }
-
-       if ((iwl3945_param_queues_num > IWL39_MAX_NUM_QUEUES) ||
-           (iwl3945_param_queues_num < IWL_MIN_NUM_QUEUES)) {
-               IWL_ERROR("invalid queues_num, should be between %d and %d\n",
-                         IWL_MIN_NUM_QUEUES, IWL39_MAX_NUM_QUEUES);
-               err = -EINVAL;
-               goto out;
-       }
-
        /* mac80211 allocates memory for this device instance, including
         *   space for this driver's private structure */
        hw = ieee80211_alloc_hw(sizeof(struct iwl3945_priv), &iwl3945_hw_ops);
        if (hw == NULL) {
-               IWL_ERROR("Can not allocate network device\n");
+               printk(KERN_ERR DRV_NAME "Can not allocate network device\n");
                err = -ENOMEM;
                goto out;
        }
@@ -7838,6 +7741,21 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
        priv->pci_dev = pdev;
        priv->cfg = cfg;
 
+       if ((iwl3945_param_queues_num > IWL39_MAX_NUM_QUEUES) ||
+           (iwl3945_param_queues_num < IWL_MIN_NUM_QUEUES)) {
+               IWL_ERROR("invalid queues_num, should be between %d and %d\n",
+                         IWL_MIN_NUM_QUEUES, IWL39_MAX_NUM_QUEUES);
+               err = -EINVAL;
+               goto out;
+       }
+
+       /* Disabling hardware scan means that mac80211 will perform scans
+        * "the hard way", rather than using device's scan. */
+       if (iwl3945_param_disable_hw_scan) {
+               IWL_DEBUG_INFO("Disabling hw_scan\n");
+               iwl3945_hw_ops.hw_scan = NULL;
+       }
+
        IWL_DEBUG_INFO("*** LOAD DRIVER ***\n");
        hw->rate_control_algorithm = "iwl-3945-rs";
        hw->sta_data_size = sizeof(struct iwl3945_sta_priv);
@@ -7845,7 +7763,7 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
        /* Select antenna (may be helpful if only one antenna is connected) */
        priv->antenna = (enum iwl3945_antenna)iwl3945_param_antenna;
 #ifdef CONFIG_IWL3945_DEBUG
-       iwl3945_debug_level = iwl3945_param_debug;
+       priv->debug_level = iwl3945_param_debug;
        atomic_set(&priv->restrict_refcnt, 0);
 #endif
 
@@ -7969,7 +7887,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);
@@ -8297,29 +8215,19 @@ static int __init iwl3945_init(void)
 
        ret = iwl3945_rate_control_register();
        if (ret) {
-               IWL_ERROR("Unable to register rate control algorithm: %d\n", ret);
+               printk(KERN_ERR DRV_NAME
+                      "Unable to register rate control algorithm: %d\n", ret);
                return ret;
        }
 
        ret = pci_register_driver(&iwl3945_driver);
        if (ret) {
-               IWL_ERROR("Unable to initialize PCI module\n");
+               printk(KERN_ERR DRV_NAME "Unable to initialize PCI module\n");
                goto error_register;
        }
-#ifdef CONFIG_IWL3945_DEBUG
-       ret = driver_create_file(&iwl3945_driver.driver, &driver_attr_debug_level);
-       if (ret) {
-               IWL_ERROR("Unable to create driver sysfs file\n");
-               goto error_debug;
-       }
-#endif
 
        return ret;
 
-#ifdef CONFIG_IWL3945_DEBUG
-error_debug:
-       pci_unregister_driver(&iwl3945_driver);
-#endif
 error_register:
        iwl3945_rate_control_unregister();
        return ret;
@@ -8327,9 +8235,6 @@ error_register:
 
 static void __exit iwl3945_exit(void)
 {
-#ifdef CONFIG_IWL3945_DEBUG
-       driver_remove_file(&iwl3945_driver.driver, &driver_attr_debug_level);
-#endif
        pci_unregister_driver(&iwl3945_driver);
        iwl3945_rate_control_unregister();
 }