]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/net/wireless/ipw2200.c
[PATCH] ipw2200: Do not continue loading the firmware if kmalloc fails
[karo-tx-linux.git] / drivers / net / wireless / ipw2200.c
index ed37141319ea9b8ecc64c8834b81b471198f0612..9591ee70f7368f63cb758daaa73dc8353c80ef52 100644 (file)
@@ -1,6 +1,6 @@
 /******************************************************************************
 
-  Copyright(c) 2003 - 2005 Intel Corporation. All rights reserved.
+  Copyright(c) 2003 - 2006 Intel Corporation. All rights reserved.
 
   802.11 status code portion of this file from ethereal-0.10.6:
     Copyright 2000, Axis Communications AB
@@ -33,9 +33,9 @@
 #include "ipw2200.h"
 #include <linux/version.h>
 
-#define IPW2200_VERSION "git-1.0.10"
+#define IPW2200_VERSION "git-1.1.1"
 #define DRV_DESCRIPTION        "Intel(R) PRO/Wireless 2200/2915 Network Driver"
-#define DRV_COPYRIGHT  "Copyright(c) 2003-2005 Intel Corporation"
+#define DRV_COPYRIGHT  "Copyright(c) 2003-2006 Intel Corporation"
 #define DRV_VERSION     IPW2200_VERSION
 
 #define ETH_P_80211_STATS (ETH_P_80211_RAW + 1)
@@ -46,7 +46,9 @@ MODULE_AUTHOR(DRV_COPYRIGHT);
 MODULE_LICENSE("GPL");
 
 static int cmdlog = 0;
+#ifdef CONFIG_IPW2200_DEBUG
 static int debug = 0;
+#endif
 static int channel = 0;
 static int mode = 0;
 
@@ -61,6 +63,7 @@ static int roaming = 1;
 static const char ipw_modes[] = {
        'a', 'b', 'g', '?'
 };
+static int antenna = CFG_SYS_ANTENNA_BOTH;
 
 #ifdef CONFIG_IPW_QOS
 static int qos_enable = 0;
@@ -153,12 +156,6 @@ static int init_supported_rates(struct ipw_priv *priv,
 static void ipw_set_hwcrypto_keys(struct ipw_priv *);
 static void ipw_send_wep_keys(struct ipw_priv *, int);
 
-static int ipw_is_valid_channel(struct ieee80211_device *, u8);
-static int ipw_channel_to_index(struct ieee80211_device *, u8);
-static u8 ipw_freq_to_channel(struct ieee80211_device *, u32);
-static int ipw_set_geo(struct ieee80211_device *, const struct ieee80211_geo *);
-static const struct ieee80211_geo *ipw_get_geo(struct ieee80211_device *);
-
 static int snprint_line(char *buf, size_t count,
                        const u8 * data, u32 len, u32 ofs)
 {
@@ -1654,7 +1651,7 @@ static ssize_t store_speed_scan(struct device *d, struct device_attribute *attr,
                        break;
                }
 
-               if (ipw_is_valid_channel(priv->ieee, channel))
+               if (ieee80211_is_valid_channel(priv->ieee, channel))
                        priv->speed_scan[pos++] = channel;
                else
                        IPW_WARNING("Skipping invalid channel request: %d\n",
@@ -1802,9 +1799,9 @@ static void ipw_irq_tasklet(struct ipw_priv *priv)
        }
 
        if (inta & IPW_INTA_BIT_FATAL_ERROR) {
-               IPW_ERROR("Firmware error detected.  Restarting.\n");
+               IPW_WARNING("Firmware error detected.  Restarting.\n");
                if (priv->error) {
-                       IPW_ERROR("Sysfs 'error' log already exists.\n");
+                       IPW_DEBUG_FW("Sysfs 'error' log already exists.\n");
 #ifdef CONFIG_IPW2200_DEBUG
                        if (ipw_debug_level & IPW_DL_FW_ERRORS) {
                                struct ipw_fw_error *error =
@@ -1817,10 +1814,10 @@ static void ipw_irq_tasklet(struct ipw_priv *priv)
                } else {
                        priv->error = ipw_alloc_error_log(priv);
                        if (priv->error)
-                               IPW_ERROR("Sysfs 'error' log captured.\n");
+                               IPW_DEBUG_FW("Sysfs 'error' log captured.\n");
                        else
-                               IPW_ERROR("Error allocating sysfs 'error' "
-                                         "log.\n");
+                               IPW_DEBUG_FW("Error allocating sysfs 'error' "
+                                            "log.\n");
 #ifdef CONFIG_IPW2200_DEBUG
                        if (ipw_debug_level & IPW_DL_FW_ERRORS)
                                ipw_dump_error_log(priv, priv->error);
@@ -2222,7 +2219,7 @@ static int ipw_send_tx_power(struct ipw_priv *priv, struct ipw_tx_power *power)
 
 static int ipw_set_tx_power(struct ipw_priv *priv)
 {
-       const struct ieee80211_geo *geo = ipw_get_geo(priv->ieee);
+       const struct ieee80211_geo *geo = ieee80211_get_geo(priv->ieee);
        struct ipw_tx_power tx_power;
        s8 max_power;
        int i;
@@ -2835,33 +2832,11 @@ static void ipw_arc_release(struct ipw_priv *priv)
        mdelay(5);
 }
 
-struct fw_header {
-       u32 version;
-       u32 mode;
-};
-
 struct fw_chunk {
        u32 address;
        u32 length;
 };
 
-#define IPW_FW_MAJOR_VERSION 2
-#define IPW_FW_MINOR_VERSION 4
-
-#define IPW_FW_MINOR(x) ((x & 0xff) >> 8)
-#define IPW_FW_MAJOR(x) (x & 0xff)
-
-#define IPW_FW_VERSION ((IPW_FW_MINOR_VERSION << 8) | IPW_FW_MAJOR_VERSION)
-
-#define IPW_FW_PREFIX "ipw-" __stringify(IPW_FW_MAJOR_VERSION) \
-"." __stringify(IPW_FW_MINOR_VERSION) "-"
-
-#if IPW_FW_MAJOR_VERSION >= 2 && IPW_FW_MINOR_VERSION > 0
-#define IPW_FW_NAME(x) IPW_FW_PREFIX "" x ".fw"
-#else
-#define IPW_FW_NAME(x) "ipw2200_" x ".fw"
-#endif
-
 static int ipw_load_ucode(struct ipw_priv *priv, u8 * data, size_t len)
 {
        int rc = 0, i, addr;
@@ -3130,33 +3105,47 @@ static int ipw_reset_nic(struct ipw_priv *priv)
        return rc;
 }
 
+
+struct ipw_fw {
+       u32 ver;
+       u32 boot_size;
+       u32 ucode_size;
+       u32 fw_size;
+       u8 data[0];
+};
+
 static int ipw_get_fw(struct ipw_priv *priv,
-                     const struct firmware **fw, const char *name)
+                     const struct firmware **raw, const char *name)
 {
-       struct fw_header *header;
+       struct ipw_fw *fw;
        int rc;
 
        /* ask firmware_class module to get the boot firmware off disk */
-       rc = request_firmware(fw, name, &priv->pci_dev->dev);
+       rc = request_firmware(raw, name, &priv->pci_dev->dev);
        if (rc < 0) {
-               IPW_ERROR("%s load failed: Reason %d\n", name, rc);
+               IPW_ERROR("%s request_firmware failed: Reason %d\n", name, rc);
                return rc;
        }
 
-       header = (struct fw_header *)(*fw)->data;
-       if (IPW_FW_MAJOR(le32_to_cpu(header->version)) != IPW_FW_MAJOR_VERSION) {
-               IPW_ERROR("'%s' firmware version not compatible (%d != %d)\n",
-                         name,
-                         IPW_FW_MAJOR(le32_to_cpu(header->version)),
-                         IPW_FW_MAJOR_VERSION);
+       if ((*raw)->size < sizeof(*fw)) {
+               IPW_ERROR("%s is too small (%zd)\n", name, (*raw)->size);
+               return -EINVAL;
+       }
+
+       fw = (void *)(*raw)->data;
+
+       if ((*raw)->size < sizeof(*fw) +
+           fw->boot_size + fw->ucode_size + fw->fw_size) {
+               IPW_ERROR("%s is too small or corrupt (%zd)\n",
+                         name, (*raw)->size);
                return -EINVAL;
        }
 
-       IPW_DEBUG_INFO("Loading firmware '%s' file v%d.%d (%zd bytes)\n",
+       IPW_DEBUG_INFO("Read firmware '%s' image v%d.%d (%zd bytes)\n",
                       name,
-                      IPW_FW_MAJOR(le32_to_cpu(header->version)),
-                      IPW_FW_MINOR(le32_to_cpu(header->version)),
-                      (*fw)->size - sizeof(struct fw_header));
+                      le32_to_cpu(fw->ver) >> 16,
+                      le32_to_cpu(fw->ver) & 0xff,
+                      (*raw)->size - sizeof(*fw));
        return 0;
 }
 
@@ -3196,17 +3185,13 @@ static void ipw_rx_queue_reset(struct ipw_priv *priv,
 
 #ifdef CONFIG_PM
 static int fw_loaded = 0;
-static const struct firmware *bootfw = NULL;
-static const struct firmware *firmware = NULL;
-static const struct firmware *ucode = NULL;
+static const struct firmware *raw = NULL;
 
 static void free_firmware(void)
 {
        if (fw_loaded) {
-               release_firmware(bootfw);
-               release_firmware(ucode);
-               release_firmware(firmware);
-               bootfw = ucode = firmware = NULL;
+               release_firmware(raw);
+               raw = NULL;
                fw_loaded = 0;
        }
 }
@@ -3217,32 +3202,46 @@ static void free_firmware(void)
 static int ipw_load(struct ipw_priv *priv)
 {
 #ifndef CONFIG_PM
-       const struct firmware *bootfw = NULL;
-       const struct firmware *firmware = NULL;
-       const struct firmware *ucode = NULL;
+       const struct firmware *raw = NULL;
 #endif
-       char *ucode_name;
-       char *fw_name;
+       struct ipw_fw *fw;
+       u8 *boot_img, *ucode_img, *fw_img;
+       u8 *name = NULL;
        int rc = 0, retries = 3;
 
        switch (priv->ieee->iw_mode) {
        case IW_MODE_ADHOC:
-               ucode_name = IPW_FW_NAME("ibss_ucode");
-               fw_name = IPW_FW_NAME("ibss");
+               name = "ipw2200-ibss.fw";
                break;
 #ifdef CONFIG_IPW2200_MONITOR
        case IW_MODE_MONITOR:
-               ucode_name = IPW_FW_NAME("sniffer_ucode");
-               fw_name = IPW_FW_NAME("sniffer");
+               name = "ipw2200-sniffer.fw";
                break;
 #endif
        case IW_MODE_INFRA:
-               ucode_name = IPW_FW_NAME("bss_ucode");
-               fw_name = IPW_FW_NAME("bss");
+               name = "ipw2200-bss.fw";
                break;
-       default:
+       }
+
+       if (!name) {
                rc = -EINVAL;
+               goto error;
+       }
+
+#ifdef CONFIG_PM
+       if (!fw_loaded) {
+#endif
+               rc = ipw_get_fw(priv, &raw, name);
+               if (rc < 0)
+                       goto error;
+#ifdef CONFIG_PM
        }
+#endif
+
+       fw = (void *)raw->data;
+       boot_img = &fw->data[0];
+       ucode_img = &fw->data[fw->boot_size];
+       fw_img = &fw->data[fw->boot_size + fw->ucode_size];
 
        if (rc < 0)
                goto error;
@@ -3275,18 +3274,8 @@ static int ipw_load(struct ipw_priv *priv)
        ipw_zero_memory(priv, IPW_NIC_SRAM_LOWER_BOUND,
                        IPW_NIC_SRAM_UPPER_BOUND - IPW_NIC_SRAM_LOWER_BOUND);
 
-#ifdef CONFIG_PM
-       if (!fw_loaded) {
-#endif
-               rc = ipw_get_fw(priv, &bootfw, IPW_FW_NAME("boot"));
-               if (rc < 0)
-                       goto error;
-#ifdef CONFIG_PM
-       }
-#endif
        /* DMA the initial boot firmware into the device */
-       rc = ipw_load_firmware(priv, bootfw->data + sizeof(struct fw_header),
-                              bootfw->size - sizeof(struct fw_header));
+       rc = ipw_load_firmware(priv, boot_img, fw->boot_size);
        if (rc < 0) {
                IPW_ERROR("Unable to load boot firmware: %d\n", rc);
                goto error;
@@ -3307,19 +3296,8 @@ static int ipw_load(struct ipw_priv *priv)
        /* ack fw init done interrupt */
        ipw_write32(priv, IPW_INTA_RW, IPW_INTA_BIT_FW_INITIALIZATION_DONE);
 
-#ifdef CONFIG_PM
-       if (!fw_loaded) {
-#endif
-               rc = ipw_get_fw(priv, &ucode, ucode_name);
-               if (rc < 0)
-                       goto error;
-#ifdef CONFIG_PM
-       }
-#endif
-
        /* DMA the ucode into the device */
-       rc = ipw_load_ucode(priv, ucode->data + sizeof(struct fw_header),
-                           ucode->size - sizeof(struct fw_header));
+       rc = ipw_load_ucode(priv, ucode_img, fw->ucode_size);
        if (rc < 0) {
                IPW_ERROR("Unable to load ucode: %d\n", rc);
                goto error;
@@ -3328,20 +3306,8 @@ static int ipw_load(struct ipw_priv *priv)
        /* stop nic */
        ipw_stop_nic(priv);
 
-#ifdef CONFIG_PM
-       if (!fw_loaded) {
-#endif
-               rc = ipw_get_fw(priv, &firmware, fw_name);
-               if (rc < 0)
-                       goto error;
-#ifdef CONFIG_PM
-       }
-#endif
-
        /* DMA bss firmware into the device */
-       rc = ipw_load_firmware(priv, firmware->data +
-                              sizeof(struct fw_header),
-                              firmware->size - sizeof(struct fw_header));
+       rc = ipw_load_firmware(priv, fw_img, fw->fw_size);
        if (rc < 0) {
                IPW_ERROR("Unable to load firmware: %d\n", rc);
                goto error;
@@ -3406,9 +3372,7 @@ static int ipw_load(struct ipw_priv *priv)
        ipw_write32(priv, IPW_INTA_RW, IPW_INTA_MASK_ALL);
 
 #ifndef CONFIG_PM
-       release_firmware(bootfw);
-       release_firmware(ucode);
-       release_firmware(firmware);
+       release_firmware(raw);
 #endif
        return 0;
 
@@ -3418,15 +3382,11 @@ static int ipw_load(struct ipw_priv *priv)
                priv->rxq = NULL;
        }
        ipw_tx_queue_free(priv);
-       if (bootfw)
-               release_firmware(bootfw);
-       if (ucode)
-               release_firmware(ucode);
-       if (firmware)
-               release_firmware(firmware);
+       if (raw)
+               release_firmware(raw);
 #ifdef CONFIG_PM
        fw_loaded = 0;
-       bootfw = ucode = firmware = NULL;
+       raw = NULL;
 #endif
 
        return rc;
@@ -3814,6 +3774,13 @@ static void inline average_init(struct average *avg)
        memset(avg, 0, sizeof(*avg));
 }
 
+#define DEPTH_RSSI 8
+#define DEPTH_NOISE 16
+static s16 exponential_average(s16 prev_avg, s16 val, u8 depth)
+{
+       return ((depth-1)*prev_avg +  val)/depth;
+}
+
 static void average_add(struct average *avg, s16 val)
 {
        avg->sum -= avg->entries[avg->pos];
@@ -3843,8 +3810,8 @@ static void ipw_reset_stats(struct ipw_priv *priv)
        priv->quality = 0;
 
        average_init(&priv->average_missed_beacons);
-       average_init(&priv->average_rssi);
-       average_init(&priv->average_noise);
+       priv->exp_avg_rssi = -60;
+       priv->exp_avg_noise = -85 + 0x100;
 
        priv->last_rate = 0;
        priv->last_missed_beacons = 0;
@@ -4051,7 +4018,7 @@ static void ipw_gather_stats(struct ipw_priv *priv)
        IPW_DEBUG_STATS("Tx quality   : %3d%% (%u errors, %u packets)\n",
                        tx_quality, tx_failures_delta, tx_packets_delta);
 
-       rssi = average_value(&priv->average_rssi);
+       rssi = priv->exp_avg_rssi;
        signal_quality =
            (100 *
             (priv->ieee->perfect_rssi - priv->ieee->worst_rssi) *
@@ -4066,7 +4033,7 @@ static void ipw_gather_stats(struct ipw_priv *priv)
        else if (signal_quality < 1)
                signal_quality = 0;
 
-       IPW_DEBUG_STATS("Signal level : %3d%% (%d dBm)\n",
+       IPW_ERROR("Signal level : %3d%% (%d dBm)\n",
                        signal_quality, rssi);
 
        quality = min(beacon_quality,
@@ -4525,6 +4492,24 @@ static void ipw_rx_notification(struct ipw_priv *priv,
                                 && priv->status & STATUS_ASSOCIATED)
                                queue_delayed_work(priv->workqueue,
                                                   &priv->request_scan, HZ);
+
+                       /* Send an empty event to user space.
+                        * We don't send the received data on the event because
+                        * it would require us to do complex transcoding, and
+                        * we want to minimise the work done in the irq handler
+                        * Use a request to extract the data.
+                        * Also, we generate this even for any scan, regardless
+                        * on how the scan was initiated. User space can just
+                        * sync on periodic scan to get fresh data...
+                        * Jean II */
+                       if (x->status == SCAN_COMPLETED_STATUS_COMPLETE) {
+                               union iwreq_data wrqu;
+
+                               wrqu.data.length = 0;
+                               wrqu.data.flags = 0;
+                               wireless_send_event(priv->net_dev, SIOCGIWSCAN,
+                                                   &wrqu, NULL);
+                       }
                        break;
                }
 
@@ -4547,10 +4532,9 @@ static void ipw_rx_notification(struct ipw_priv *priv,
 
                        if (notif->size == sizeof(*x)) {
                                IPW_DEBUG(IPW_DL_NOTIF | IPW_DL_STATE,
-                                         "link deterioration: '%s' " MAC_FMT
-                                         " \n", escape_essid(priv->essid,
-                                                             priv->essid_len),
-                                         MAC_ARG(priv->bssid));
+                                       "link deterioration: type %d, cnt %d\n",
+                                       x->silence_notification_type,
+                                       x->silence_count);
                                memcpy(&priv->last_link_deterioration, x,
                                       sizeof(*x));
                        } else {
@@ -4621,11 +4605,10 @@ static void ipw_rx_notification(struct ipw_priv *priv,
 
        case HOST_NOTIFICATION_NOISE_STATS:{
                        if (notif->size == sizeof(u32)) {
-                               priv->last_noise =
-                                   (u8) (le32_to_cpu(notif->u.noise.value) &
-                                         0xff);
-                               average_add(&priv->average_noise,
-                                           priv->last_noise);
+                               priv->exp_avg_noise =
+                                   exponential_average(priv->exp_avg_noise,
+                                   (u8) (le32_to_cpu(notif->u.noise.value) & 0xff),
+                                   DEPTH_NOISE);
                                break;
                        }
 
@@ -5533,15 +5516,6 @@ static int ipw_best_network(struct ipw_priv *priv,
                return 0;
        }
 
-       if (priv->ieee->wpa_enabled &&
-           network->wpa_ie_len == 0 && network->rsn_ie_len == 0) {
-               IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT ")' excluded "
-                               "because of WPA capability mismatch.\n",
-                               escape_essid(network->ssid, network->ssid_len),
-                               MAC_ARG(network->bssid));
-               return 0;
-       }
-
        if ((priv->config & CFG_STATIC_BSSID) &&
            memcmp(network->bssid, priv->bssid, ETH_ALEN)) {
                IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT ")' excluded "
@@ -5562,7 +5536,7 @@ static int ipw_best_network(struct ipw_priv *priv,
        }
 
        /* Filter out invalid channel in current GEO */
-       if (!ipw_is_valid_channel(priv->ieee, network->channel)) {
+       if (!ieee80211_is_valid_channel(priv->ieee, network->channel)) {
                IPW_DEBUG_ASSOC("Network '%s (" MAC_FMT ")' excluded "
                                "because of invalid channel in current GEO\n",
                                escape_essid(network->ssid, network->ssid_len),
@@ -5607,7 +5581,7 @@ static int ipw_best_network(struct ipw_priv *priv,
 static void ipw_adhoc_create(struct ipw_priv *priv,
                             struct ieee80211_network *network)
 {
-       const struct ieee80211_geo *geo = ipw_get_geo(priv->ieee);
+       const struct ieee80211_geo *geo = ieee80211_get_geo(priv->ieee);
        int i;
 
        /*
@@ -5622,12 +5596,11 @@ static void ipw_adhoc_create(struct ipw_priv *priv,
         * FW fatal error.
         *
         */
-       switch (ipw_is_valid_channel(priv->ieee, priv->channel)) {
+       switch (ieee80211_is_valid_channel(priv->ieee, priv->channel)) {
        case IEEE80211_52GHZ_BAND:
                network->mode = IEEE_A;
-               i = ipw_channel_to_index(priv->ieee, priv->channel);
-               if (i == -1)
-                       BUG();
+               i = ieee80211_channel_to_index(priv->ieee, priv->channel);
+               BUG_ON(i == -1);
                if (geo->a[i].flags & IEEE80211_CH_PASSIVE_ONLY) {
                        IPW_WARNING("Overriding invalid channel\n");
                        priv->channel = geo->a[0].channel;
@@ -5639,9 +5612,8 @@ static void ipw_adhoc_create(struct ipw_priv *priv,
                        network->mode = IEEE_G;
                else
                        network->mode = IEEE_B;
-               i = ipw_channel_to_index(priv->ieee, priv->channel);
-               if (i == -1)
-                       BUG();
+               i = ieee80211_channel_to_index(priv->ieee, priv->channel);
+               BUG_ON(i == -1);
                if (geo->bg[i].flags & IEEE80211_CH_PASSIVE_ONLY) {
                        IPW_WARNING("Overriding invalid channel\n");
                        priv->channel = geo->bg[0].channel;
@@ -5963,7 +5935,7 @@ static void ipw_add_scan_channels(struct ipw_priv *priv,
        const struct ieee80211_geo *geo;
        int i;
 
-       geo = ipw_get_geo(priv->ieee);
+       geo = ieee80211_get_geo(priv->ieee);
 
        if (priv->ieee->freq_band & IEEE80211_52GHZ_BAND) {
                int start = channel_index;
@@ -6023,7 +5995,7 @@ static void ipw_add_scan_channels(struct ipw_priv *priv,
                                channel_index++;
                                scan->channels_list[channel_index] = channel;
                                index =
-                                   ipw_channel_to_index(priv->ieee, channel);
+                                   ieee80211_channel_to_index(priv->ieee, channel);
                                ipw_set_scan_type(scan, channel_index,
                                                  geo->bg[index].
                                                  flags &
@@ -6105,7 +6077,7 @@ static int ipw_request_scan(struct ipw_priv *priv)
                u8 channel;
                u8 band = 0;
 
-               switch (ipw_is_valid_channel(priv->ieee, priv->channel)) {
+               switch (ieee80211_is_valid_channel(priv->ieee, priv->channel)) {
                case IEEE80211_52GHZ_BAND:
                        band = (u8) (IPW_A_MODE << 6) | 1;
                        channel = priv->channel;
@@ -6568,7 +6540,7 @@ static int ipw_wx_set_mlme(struct net_device *dev,
 * get the modulation type of the current network or
 * the card current mode
 */
-u8 ipw_qos_current_mode(struct ipw_priv * priv)
+static u8 ipw_qos_current_mode(struct ipw_priv * priv)
 {
        u8 mode = 0;
 
@@ -6768,8 +6740,7 @@ static int ipw_qos_association(struct ipw_priv *priv,
 
        switch (priv->ieee->iw_mode) {
        case IW_MODE_ADHOC:
-               if (!(network->capability & WLAN_CAPABILITY_IBSS))
-                       BUG();
+               BUG_ON(!(network->capability & WLAN_CAPABILITY_IBSS));
 
                qos_data = &ibss_data;
                break;
@@ -6909,61 +6880,55 @@ static int ipw_get_tx_queue_number(struct ipw_priv *priv, u16 priority)
        return from_priority_to_tx_queue[priority] - 1;
 }
 
-/*
-* add QoS parameter to the TX command
-*/
-static int ipw_qos_set_tx_queue_command(struct ipw_priv *priv,
-                                       u16 priority,
-                                       struct tfd_data *tfd, u8 unicast)
+static int ipw_is_qos_active(struct net_device *dev,
+                            struct sk_buff *skb)
 {
-       int ret = 0;
-       int tx_queue_id = 0;
+       struct ipw_priv *priv = ieee80211_priv(dev);
        struct ieee80211_qos_data *qos_data = NULL;
        int active, supported;
-       unsigned long flags;
+       u8 *daddr = skb->data + ETH_ALEN;
+       int unicast = !is_multicast_ether_addr(daddr);
 
        if (!(priv->status & STATUS_ASSOCIATED))
                return 0;
 
        qos_data = &priv->assoc_network->qos_data;
 
-       spin_lock_irqsave(&priv->ieee->lock, flags);
-
        if (priv->ieee->iw_mode == IW_MODE_ADHOC) {
                if (unicast == 0)
                        qos_data->active = 0;
                else
                        qos_data->active = qos_data->supported;
        }
-
        active = qos_data->active;
        supported = qos_data->supported;
-
-       spin_unlock_irqrestore(&priv->ieee->lock, flags);
-
        IPW_DEBUG_QOS("QoS  %d network is QoS active %d  supported %d  "
                      "unicast %d\n",
                      priv->qos_data.qos_enable, active, supported, unicast);
-       if (active && priv->qos_data.qos_enable) {
-               ret = from_priority_to_tx_queue[priority];
-               tx_queue_id = ret - 1;
-               IPW_DEBUG_QOS("QoS packet priority is %d \n", priority);
-               if (priority <= 7) {
-                       tfd->tx_flags_ext |= DCT_FLAG_EXT_QOS_ENABLED;
-                       tfd->tfd.tfd_26.mchdr.qos_ctrl = priority;
-                       tfd->tfd.tfd_26.mchdr.frame_ctl |=
-                           IEEE80211_STYPE_QOS_DATA;
-
-                       if (priv->qos_data.qos_no_ack_mask &
-                           (1UL << tx_queue_id)) {
-                               tfd->tx_flags &= ~DCT_FLAG_ACK_REQD;
-                               tfd->tfd.tfd_26.mchdr.qos_ctrl |=
-                                   CTRL_QOS_NO_ACK;
-                       }
-               }
-       }
+       if (active && priv->qos_data.qos_enable)
+               return 1;
 
-       return ret;
+       return 0;
+
+}
+/*
+* add QoS parameter to the TX command
+*/
+static int ipw_qos_set_tx_queue_command(struct ipw_priv *priv,
+                                       u16 priority,
+                                       struct tfd_data *tfd)
+{
+       int tx_queue_id = 0;
+
+
+       tx_queue_id = from_priority_to_tx_queue[priority] - 1;
+       tfd->tx_flags_ext |= DCT_FLAG_EXT_QOS_ENABLED;
+
+       if (priv->qos_data.qos_no_ack_mask & (1UL << tx_queue_id)) {
+               tfd->tx_flags &= ~DCT_FLAG_ACK_REQD;
+               tfd->tfd.tfd_26.mchdr.qos_ctrl |= CTRL_QOS_NO_ACK;
+       }
+       return 0;
 }
 
 /*
@@ -7815,12 +7780,10 @@ static void ipw_rx(struct ipw_priv *priv)
 
        while (i != r) {
                rxb = priv->rxq->queue[i];
-#ifdef CONFIG_IPW2200_DEBUG
                if (unlikely(rxb == NULL)) {
                        printk(KERN_CRIT "Queue not allocated!\n");
                        break;
                }
-#endif
                priv->rxq->queue[i] = NULL;
 
                pci_dma_sync_single_for_cpu(priv->pci_dev, rxb->dma_addr,
@@ -7839,7 +7802,8 @@ static void ipw_rx(struct ipw_priv *priv)
                                            le16_to_cpu(pkt->u.frame.rssi_dbm) -
                                            IPW_RSSI_TO_DBM,
                                        .signal =
-                                           le16_to_cpu(pkt->u.frame.signal),
+                                           le16_to_cpu(pkt->u.frame.rssi_dbm) -
+                                           IPW_RSSI_TO_DBM + 0x100,
                                        .noise =
                                            le16_to_cpu(pkt->u.frame.noise),
                                        .rate = pkt->u.frame.rate,
@@ -7894,16 +7858,17 @@ static void ipw_rx(struct ipw_priv *priv)
                                if (network_packet && priv->assoc_network) {
                                        priv->assoc_network->stats.rssi =
                                            stats.rssi;
-                                       average_add(&priv->average_rssi,
-                                                   stats.rssi);
-                                       priv->last_rx_rssi = stats.rssi;
+                                       priv->exp_avg_rssi =
+                                           exponential_average(priv->exp_avg_rssi,
+                                           stats.rssi, DEPTH_RSSI);
                                }
 
                                IPW_DEBUG_RX("Frame: len=%u\n",
                                             le16_to_cpu(pkt->u.frame.length));
 
                                if (le16_to_cpu(pkt->u.frame.length) <
-                                   frame_hdr_len(header)) {
+                                   ieee80211_get_hdrlen(le16_to_cpu(
+                                                   header->frame_ctl))) {
                                        IPW_DEBUG_DROP
                                            ("Received packet is too small. "
                                             "Dropping.\n");
@@ -7993,7 +7958,14 @@ static void ipw_rx(struct ipw_priv *priv)
 #define        DEFAULT_SHORT_RETRY_LIMIT 7U
 #define        DEFAULT_LONG_RETRY_LIMIT  4U
 
-static int ipw_sw_reset(struct ipw_priv *priv, int init)
+/**
+ * ipw_sw_reset
+ * @option: options to control different reset behaviour
+ *         0 = reset everything except the 'disable' module_param
+ *         1 = reset everything and print out driver info (for probe only)
+ *         2 = reset everything
+ */
+static int ipw_sw_reset(struct ipw_priv *priv, int option)
 {
        int band, modulation;
        int old_mode = priv->ieee->iw_mode;
@@ -8020,7 +7992,7 @@ static int ipw_sw_reset(struct ipw_priv *priv, int init)
        priv->essid_len = 0;
        memset(priv->essid, 0, IW_ESSID_MAX_SIZE);
 
-       if (disable) {
+       if (disable && option) {
                priv->status |= STATUS_RF_KILL_SW;
                IPW_DEBUG_INFO("Radio disabled.\n");
        }
@@ -8072,7 +8044,7 @@ static int ipw_sw_reset(struct ipw_priv *priv, int init)
 
        if ((priv->pci_dev->device == 0x4223) ||
            (priv->pci_dev->device == 0x4224)) {
-               if (init)
+               if (option == 1)
                        printk(KERN_INFO DRV_NAME
                               ": Detected Intel PRO/Wireless 2915ABG Network "
                               "Connection\n");
@@ -8083,7 +8055,7 @@ static int ipw_sw_reset(struct ipw_priv *priv, int init)
                priv->adapter = IPW_2915ABG;
                priv->ieee->mode = IEEE_A | IEEE_G | IEEE_B;
        } else {
-               if (init)
+               if (option == 1)
                        printk(KERN_INFO DRV_NAME
                               ": Detected Intel PRO/Wireless 2200BG Network "
                               "Connection\n");
@@ -8200,7 +8172,7 @@ static int ipw_wx_set_freq(struct net_device *dev,
                           union iwreq_data *wrqu, char *extra)
 {
        struct ipw_priv *priv = ieee80211_priv(dev);
-       const struct ieee80211_geo *geo = ipw_get_geo(priv->ieee);
+       const struct ieee80211_geo *geo = ieee80211_get_geo(priv->ieee);
        struct iw_freq *fwrq = &wrqu->freq;
        int ret = 0, i;
        u8 channel, flags;
@@ -8215,17 +8187,17 @@ static int ipw_wx_set_freq(struct net_device *dev,
        }
        /* if setting by freq convert to channel */
        if (fwrq->e == 1) {
-               channel = ipw_freq_to_channel(priv->ieee, fwrq->m);
+               channel = ieee80211_freq_to_channel(priv->ieee, fwrq->m);
                if (channel == 0)
                        return -EINVAL;
        } else
                channel = fwrq->m;
 
-       if (!(band = ipw_is_valid_channel(priv->ieee, channel)))
+       if (!(band = ieee80211_is_valid_channel(priv->ieee, channel)))
                return -EINVAL;
 
        if (priv->ieee->iw_mode == IW_MODE_ADHOC) {
-               i = ipw_channel_to_index(priv->ieee, channel);
+               i = ieee80211_channel_to_index(priv->ieee, channel);
                if (i == -1)
                        return -EINVAL;
 
@@ -8353,7 +8325,7 @@ static int ipw_wx_get_range(struct net_device *dev,
 {
        struct ipw_priv *priv = ieee80211_priv(dev);
        struct iw_range *range = (struct iw_range *)extra;
-       const struct ieee80211_geo *geo = ipw_get_geo(priv->ieee);
+       const struct ieee80211_geo *geo = ieee80211_get_geo(priv->ieee);
        int i = 0, j;
 
        wrqu->data.length = sizeof(*range);
@@ -8365,7 +8337,7 @@ static int ipw_wx_get_range(struct net_device *dev,
        range->max_qual.qual = 100;
        /* TODO: Find real max RSSI and stick here */
        range->max_qual.level = 0;
-       range->max_qual.noise = priv->ieee->worst_rssi + 0x100;
+       range->max_qual.noise = 0;
        range->max_qual.updated = 7;    /* Updated all three */
 
        range->avg_qual.qual = 70;
@@ -8395,20 +8367,28 @@ static int ipw_wx_get_range(struct net_device *dev,
 
        i = 0;
        if (priv->ieee->mode & (IEEE_B | IEEE_G)) {
-               for (j = 0; j < geo->bg_channels && i < IW_MAX_FREQUENCIES;
-                    i++, j++) {
+               for (j = 0; j < geo->bg_channels && i < IW_MAX_FREQUENCIES; j++) {
+                       if ((priv->ieee->iw_mode == IW_MODE_ADHOC) &&
+                           (geo->bg[j].flags & IEEE80211_CH_PASSIVE_ONLY))
+                               continue;
+
                        range->freq[i].i = geo->bg[j].channel;
                        range->freq[i].m = geo->bg[j].freq * 100000;
                        range->freq[i].e = 1;
+                       i++;
                }
        }
 
        if (priv->ieee->mode & IEEE_A) {
-               for (j = 0; j < geo->a_channels && i < IW_MAX_FREQUENCIES;
-                    i++, j++) {
+               for (j = 0; j < geo->a_channels && i < IW_MAX_FREQUENCIES; j++) {
+                       if ((priv->ieee->iw_mode == IW_MODE_ADHOC) &&
+                           (geo->a[j].flags & IEEE80211_CH_PASSIVE_ONLY))
+                               continue;
+
                        range->freq[i].i = geo->a[j].channel;
                        range->freq[i].m = geo->a[j].freq * 100000;
                        range->freq[i].e = 1;
+                       i++;
                }
        }
 
@@ -8420,7 +8400,8 @@ static int ipw_wx_get_range(struct net_device *dev,
        /* Event capability (kernel + driver) */
        range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
                                IW_EVENT_CAPA_MASK(SIOCGIWTHRSPY) |
-                               IW_EVENT_CAPA_MASK(SIOCGIWAP));
+                               IW_EVENT_CAPA_MASK(SIOCGIWAP) |
+                               IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
        range->event_capa[1] = IW_EVENT_CAPA_K_1;
 
        range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
@@ -8609,6 +8590,52 @@ static int ipw_wx_get_nick(struct net_device *dev,
        return 0;
 }
 
+static int ipw_wx_set_sens(struct net_device *dev,
+                           struct iw_request_info *info,
+                           union iwreq_data *wrqu, char *extra)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+       int err = 0;
+
+       IPW_DEBUG_WX("Setting roaming threshold to %d\n", wrqu->sens.value);
+       IPW_DEBUG_WX("Setting disassociate threshold to %d\n", 3*wrqu->sens.value);
+       mutex_lock(&priv->mutex);
+
+       if (wrqu->sens.fixed == 0)
+       {
+               priv->roaming_threshold = IPW_MB_ROAMING_THRESHOLD_DEFAULT;
+               priv->disassociate_threshold = IPW_MB_DISASSOCIATE_THRESHOLD_DEFAULT;
+               goto out;
+       }
+       if ((wrqu->sens.value > IPW_MB_ROAMING_THRESHOLD_MAX) ||
+           (wrqu->sens.value < IPW_MB_ROAMING_THRESHOLD_MIN)) {
+               err = -EINVAL;
+               goto out;
+       }
+
+       priv->roaming_threshold = wrqu->sens.value;
+       priv->disassociate_threshold = 3*wrqu->sens.value;
+      out:
+       mutex_unlock(&priv->mutex);
+       return err;
+}
+
+static int ipw_wx_get_sens(struct net_device *dev,
+                           struct iw_request_info *info,
+                           union iwreq_data *wrqu, char *extra)
+{
+       struct ipw_priv *priv = ieee80211_priv(dev);
+       mutex_lock(&priv->mutex);
+       wrqu->sens.fixed = 1;
+       wrqu->sens.value = priv->roaming_threshold;
+       mutex_unlock(&priv->mutex);
+
+       IPW_DEBUG_WX("GET roaming threshold -> %s %d \n",
+                    wrqu->power.disabled ? "OFF" : "ON", wrqu->power.value);
+
+       return 0;
+}
+
 static int ipw_wx_set_rate(struct net_device *dev,
                           struct iw_request_info *info,
                           union iwreq_data *wrqu, char *extra)
@@ -9395,7 +9422,7 @@ static int ipw_wx_sw_reset(struct net_device *dev,
 
        mutex_lock(&priv->mutex);
 
-       ret = ipw_sw_reset(priv, 0);
+       ret = ipw_sw_reset(priv, 2);
        if (!ret) {
                free_firmware();
                ipw_adapter_restart(priv);
@@ -9430,6 +9457,8 @@ static iw_handler ipw_wx_handlers[] = {
        IW_IOCTL(SIOCGIWFREQ) = ipw_wx_get_freq,
        IW_IOCTL(SIOCSIWMODE) = ipw_wx_set_mode,
        IW_IOCTL(SIOCGIWMODE) = ipw_wx_get_mode,
+       IW_IOCTL(SIOCSIWSENS) = ipw_wx_set_sens,
+       IW_IOCTL(SIOCGIWSENS) = ipw_wx_get_sens,
        IW_IOCTL(SIOCGIWRANGE) = ipw_wx_get_range,
        IW_IOCTL(SIOCSIWAP) = ipw_wx_set_wap,
        IW_IOCTL(SIOCGIWAP) = ipw_wx_get_wap,
@@ -9572,10 +9601,10 @@ static struct iw_statistics *ipw_get_wireless_stats(struct net_device *dev)
        }
 
        wstats->qual.qual = priv->quality;
-       wstats->qual.level = average_value(&priv->average_rssi);
-       wstats->qual.noise = average_value(&priv->average_noise);
+       wstats->qual.level = priv->exp_avg_rssi;
+       wstats->qual.noise = priv->exp_avg_noise;
        wstats->qual.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED |
-           IW_QUAL_NOISE_UPDATED;
+           IW_QUAL_NOISE_UPDATED | IW_QUAL_DBM;
 
        wstats->miss.beacon = average_value(&priv->average_missed_beacons);
        wstats->discard.retries = priv->last_tx_failures;
@@ -9601,12 +9630,15 @@ static  void init_sys_config(struct ipw_sys_config *sys_config)
        sys_config->disable_unicast_decryption = 1;
        sys_config->exclude_multicast_unencrypted = 0;
        sys_config->disable_multicast_decryption = 1;
-       sys_config->antenna_diversity = CFG_SYS_ANTENNA_BOTH;
+       if (antenna < CFG_SYS_ANTENNA_BOTH || antenna > CFG_SYS_ANTENNA_B)
+               antenna = CFG_SYS_ANTENNA_BOTH;
+       sys_config->antenna_diversity = antenna;
        sys_config->pass_crc_to_host = 0;       /* TODO: See if 1 gives us FCS */
        sys_config->dot11g_auto_detection = 0;
        sys_config->enable_cts_to_self = 0;
        sys_config->bt_coexist_collision_thr = 0;
        sys_config->pass_noise_stats_to_host = 1;       //1 -- fix for 256
+       sys_config->silence_threshold = 0x1e;
 }
 
 static int ipw_net_open(struct net_device *dev)
@@ -9639,7 +9671,7 @@ we need to heavily modify the ieee80211_skb_to_txb.
 static int ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb,
                             int pri)
 {
-       struct ieee80211_hdr_3addr *hdr = (struct ieee80211_hdr_3addr *)
+       struct ieee80211_hdr_3addrqos *hdr = (struct ieee80211_hdr_3addrqos *)
            txb->fragments[0]->data;
        int i = 0;
        struct tfd_frame *tfd;
@@ -9654,14 +9686,9 @@ static int ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb,
        u16 remaining_bytes;
        int fc;
 
-       /* If there isn't room in the queue, we return busy and let the
-        * network stack requeue the packet for us */
-       if (ipw_queue_space(q) < q->high_mark)
-               return NETDEV_TX_BUSY;
-
+       hdr_len = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
        switch (priv->ieee->iw_mode) {
        case IW_MODE_ADHOC:
-               hdr_len = IEEE80211_3ADDR_LEN;
                unicast = !is_multicast_ether_addr(hdr->addr1);
                id = ipw_find_station(priv, hdr->addr1);
                if (id == IPW_INVALID_STATION) {
@@ -9678,7 +9705,6 @@ static int ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb,
        case IW_MODE_INFRA:
        default:
                unicast = !is_multicast_ether_addr(hdr->addr3);
-               hdr_len = IEEE80211_3ADDR_LEN;
                id = 0;
                break;
        }
@@ -9757,7 +9783,8 @@ static int ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb,
                tfd->u.data.tx_flags |= DCT_FLAG_NO_WEP;
 
 #ifdef CONFIG_IPW_QOS
-       ipw_qos_set_tx_queue_command(priv, pri, &(tfd->u.data), unicast);
+       if (fc & IEEE80211_STYPE_QOS_DATA)
+               ipw_qos_set_tx_queue_command(priv, pri, &(tfd->u.data));
 #endif                         /* CONFIG_IPW_QOS */
 
        /* payload */
@@ -9824,6 +9851,9 @@ static int ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb,
        q->first_empty = ipw_queue_inc_wrap(q->first_empty, q->n_bd);
        ipw_write32(priv, q->reg_w, q->first_empty);
 
+       if (ipw_queue_space(q) < q->high_mark)
+               netif_stop_queue(priv->net_dev);
+
        return NETDEV_TX_OK;
 
       drop:
@@ -9963,9 +9993,8 @@ static int ipw_ethtool_set_eeprom(struct net_device *dev,
                return -EINVAL;
        mutex_lock(&p->mutex);
        memcpy(&p->eeprom[eeprom->offset], bytes, eeprom->len);
-       for (i = IPW_EEPROM_DATA;
-            i < IPW_EEPROM_DATA + IPW_EEPROM_IMAGE_SIZE; i++)
-               ipw_write8(p, i, p->eeprom[i]);
+       for (i = 0; i < IPW_EEPROM_IMAGE_SIZE; i++)
+               ipw_write8(p, i + IPW_EEPROM_DATA, p->eeprom[i]);
        mutex_unlock(&p->mutex);
        return 0;
 }
@@ -10370,6 +10399,9 @@ static int ipw_config(struct ipw_priv *priv)
  * not intended for resale of the above mentioned Intel adapters has
  * not been tested.
  *
+ * Remember to update the table in README.ipw2200 when changing this
+ * table.
+ *
  */
 static const struct ieee80211_geo ipw_geos[] = {
        {                       /* Restricted */
@@ -10617,96 +10649,6 @@ static const struct ieee80211_geo ipw_geos[] = {
         }
 };
 
-/* GEO code borrowed from ieee80211_geo.c */
-static int ipw_is_valid_channel(struct ieee80211_device *ieee, u8 channel)
-{
-       int i;
-
-       /* Driver needs to initialize the geography map before using
-        * these helper functions */
-       BUG_ON(ieee->geo.bg_channels == 0 && ieee->geo.a_channels == 0);
-
-       if (ieee->freq_band & IEEE80211_24GHZ_BAND)
-               for (i = 0; i < ieee->geo.bg_channels; i++)
-                       /* NOTE: If G mode is currently supported but
-                        * this is a B only channel, we don't see it
-                        * as valid. */
-                       if ((ieee->geo.bg[i].channel == channel) &&
-                           (!(ieee->mode & IEEE_G) ||
-                            !(ieee->geo.bg[i].flags & IEEE80211_CH_B_ONLY)))
-                               return IEEE80211_24GHZ_BAND;
-
-       if (ieee->freq_band & IEEE80211_52GHZ_BAND)
-               for (i = 0; i < ieee->geo.a_channels; i++)
-                       if (ieee->geo.a[i].channel == channel)
-                               return IEEE80211_52GHZ_BAND;
-
-       return 0;
-}
-
-static int ipw_channel_to_index(struct ieee80211_device *ieee, u8 channel)
-{
-       int i;
-
-       /* Driver needs to initialize the geography map before using
-        * these helper functions */
-       BUG_ON(ieee->geo.bg_channels == 0 && ieee->geo.a_channels == 0);
-
-       if (ieee->freq_band & IEEE80211_24GHZ_BAND)
-               for (i = 0; i < ieee->geo.bg_channels; i++)
-                       if (ieee->geo.bg[i].channel == channel)
-                               return i;
-
-       if (ieee->freq_band & IEEE80211_52GHZ_BAND)
-               for (i = 0; i < ieee->geo.a_channels; i++)
-                       if (ieee->geo.a[i].channel == channel)
-                               return i;
-
-       return -1;
-}
-
-static u8 ipw_freq_to_channel(struct ieee80211_device *ieee, u32 freq)
-{
-       int i;
-
-       /* Driver needs to initialize the geography map before using
-        * these helper functions */
-       BUG_ON(ieee->geo.bg_channels == 0 && ieee->geo.a_channels == 0);
-
-       freq /= 100000;
-
-       if (ieee->freq_band & IEEE80211_24GHZ_BAND)
-               for (i = 0; i < ieee->geo.bg_channels; i++)
-                       if (ieee->geo.bg[i].freq == freq)
-                               return ieee->geo.bg[i].channel;
-
-       if (ieee->freq_band & IEEE80211_52GHZ_BAND)
-               for (i = 0; i < ieee->geo.a_channels; i++)
-                       if (ieee->geo.a[i].freq == freq)
-                               return ieee->geo.a[i].channel;
-
-       return 0;
-}
-
-static int ipw_set_geo(struct ieee80211_device *ieee,
-                      const struct ieee80211_geo *geo)
-{
-       memcpy(ieee->geo.name, geo->name, 3);
-       ieee->geo.name[3] = '\0';
-       ieee->geo.bg_channels = geo->bg_channels;
-       ieee->geo.a_channels = geo->a_channels;
-       memcpy(ieee->geo.bg, geo->bg, geo->bg_channels *
-              sizeof(struct ieee80211_channel));
-       memcpy(ieee->geo.a, geo->a, ieee->geo.a_channels *
-              sizeof(struct ieee80211_channel));
-       return 0;
-}
-
-static const struct ieee80211_geo *ipw_get_geo(struct ieee80211_device *ieee)
-{
-       return &ieee->geo;
-}
-
 #define MAX_HW_RESTARTS 5
 static int ipw_up(struct ipw_priv *priv)
 {
@@ -10721,6 +10663,7 @@ static int ipw_up(struct ipw_priv *priv)
                if (priv->cmdlog == NULL) {
                        IPW_ERROR("Error allocating %d command log entries.\n",
                                  cmdlog);
+                       return -ENOMEM;
                } else {
                        memset(priv->cmdlog, 0, sizeof(*priv->cmdlog) * cmdlog);
                        priv->cmdlog_len = cmdlog;
@@ -10753,14 +10696,11 @@ static int ipw_up(struct ipw_priv *priv)
                                    priv->eeprom[EEPROM_COUNTRY_CODE + 2]);
                        j = 0;
                }
-               if (ipw_set_geo(priv->ieee, &ipw_geos[j])) {
+               if (ieee80211_set_geo(priv->ieee, &ipw_geos[j])) {
                        IPW_WARNING("Could not set geography.");
                        return 0;
                }
 
-               IPW_DEBUG_INFO("Geography %03d [%s] detected.\n",
-                              j, priv->ieee->geo.name);
-
                if (priv->status & STATUS_RF_KILL_SW) {
                        IPW_WARNING("Radio disabled by module parameter.\n");
                        return 0;
@@ -11045,6 +10985,7 @@ static int ipw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        priv->ieee->is_queue_full = ipw_net_is_queue_full;
 
 #ifdef CONFIG_IPW_QOS
+       priv->ieee->is_qos_active = ipw_is_qos_active;
        priv->ieee->handle_probe_response = ipw_handle_beacon;
        priv->ieee->handle_beacon = ipw_handle_probe_response;
        priv->ieee->handle_assoc_response = ipw_handle_assoc_response;
@@ -11081,6 +11022,12 @@ static int ipw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                IPW_ERROR("failed to register network device\n");
                goto out_remove_sysfs;
        }
+
+       printk(KERN_INFO DRV_NAME ": Detected geography %s (%d 802.11bg "
+              "channels, %d 802.11a channels)\n",
+              priv->ieee->geo.name, priv->ieee->geo.bg_channels,
+              priv->ieee->geo.a_channels);
+
        return 0;
 
       out_remove_sysfs:
@@ -11271,8 +11218,10 @@ MODULE_PARM_DESC(auto_create, "auto create adhoc network (default on)");
 module_param(led, int, 0444);
 MODULE_PARM_DESC(led, "enable led control on some systems (default 0 off)\n");
 
+#ifdef CONFIG_IPW2200_DEBUG
 module_param(debug, int, 0444);
 MODULE_PARM_DESC(debug, "debug output mask");
+#endif
 
 module_param(channel, int, 0444);
 MODULE_PARM_DESC(channel, "channel to limit associate to (default 0 [ANY])");
@@ -11315,5 +11264,8 @@ MODULE_PARM_DESC(cmdlog,
 module_param(roaming, int, 0444);
 MODULE_PARM_DESC(roaming, "enable roaming support (default on)");
 
+module_param(antenna, int, 0444);
+MODULE_PARM_DESC(antenna, "select antenna 1=Main, 3=Aux, default 0 [both], 2=slow_diversity (choose the one with lower background noise)");
+
 module_exit(ipw_exit);
 module_init(ipw_init);