include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / drivers / net / wireless / adm8211.c
index 4c43cdb..ab61d2b 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/init.h>
 #include <linux/if.h>
 #include <linux/skbuff.h>
+#include <linux/slab.h>
 #include <linux/etherdevice.h>
 #include <linux/pci.h>
 #include <linux/delay.h>
@@ -39,12 +40,7 @@ static unsigned int rx_ring_size __read_mostly = 16;
 module_param(tx_ring_size, uint, 0);
 module_param(rx_ring_size, uint, 0);
 
-static const char version[] = KERN_INFO "adm8211: "
-"Copyright 2003, Jouni Malinen <j@w1.fi>; "
-"Copyright 2004-2007, Michael Wu <flamingice@sourmilk.net>\n";
-
-
-static struct pci_device_id adm8211_pci_id_table[] __devinitdata = {
+static DEFINE_PCI_DEVICE_TABLE(adm8211_pci_id_table) = {
        /* ADMtek ADM8211 */
        { PCI_DEVICE(0x10B7, 0x6000) }, /* 3Com 3CRSHPW796 */
        { PCI_DEVICE(0x1200, 0x8201) }, /* ? */
@@ -53,6 +49,32 @@ static struct pci_device_id adm8211_pci_id_table[] __devinitdata = {
        { 0 }
 };
 
+static struct ieee80211_rate adm8211_rates[] = {
+       { .bitrate = 10, .flags = IEEE80211_RATE_SHORT_PREAMBLE },
+       { .bitrate = 20, .flags = IEEE80211_RATE_SHORT_PREAMBLE },
+       { .bitrate = 55, .flags = IEEE80211_RATE_SHORT_PREAMBLE },
+       { .bitrate = 110, .flags = IEEE80211_RATE_SHORT_PREAMBLE },
+       { .bitrate = 220, .flags = IEEE80211_RATE_SHORT_PREAMBLE }, /* XX ?? */
+};
+
+static const struct ieee80211_channel adm8211_channels[] = {
+       { .center_freq = 2412},
+       { .center_freq = 2417},
+       { .center_freq = 2422},
+       { .center_freq = 2427},
+       { .center_freq = 2432},
+       { .center_freq = 2437},
+       { .center_freq = 2442},
+       { .center_freq = 2447},
+       { .center_freq = 2452},
+       { .center_freq = 2457},
+       { .center_freq = 2462},
+       { .center_freq = 2467},
+       { .center_freq = 2472},
+       { .center_freq = 2484},
+};
+
+
 static void adm8211_eeprom_register_read(struct eeprom_93cx6 *eeprom)
 {
        struct adm8211_priv *priv = eeprom->data;
@@ -109,7 +131,7 @@ static int adm8211_read_eeprom(struct ieee80211_hw *dev)
        if (!priv->eeprom)
                return -ENOMEM;
 
-       eeprom_93cx6_multiread(&eeprom, 0, (__le16 __force *)priv->eeprom, words);
+       eeprom_93cx6_multiread(&eeprom, 0, (__le16 *)priv->eeprom, words);
 
        cr49 = le16_to_cpu(priv->eeprom->cr49);
        priv->rf_type = (cr49 >> 3) & 0x7;
@@ -122,7 +144,7 @@ static int adm8211_read_eeprom(struct ieee80211_hw *dev)
                break;
 
        default:
-               if (priv->revid < ADM8211_REV_CA)
+               if (priv->pdev->revision < ADM8211_REV_CA)
                        priv->rf_type = ADM8211_TYPE_RFMD;
                else
                        priv->rf_type = ADM8211_TYPE_AIROHA;
@@ -140,7 +162,7 @@ static int adm8211_read_eeprom(struct ieee80211_hw *dev)
        case ADM8211_TYPE_ADMTEK:
                break;
        default:
-               if (priv->revid < ADM8211_REV_CA)
+               if (priv->pdev->revision < ADM8211_REV_CA)
                        priv->bbp_type = ADM8211_TYPE_RFMD;
                else
                        priv->bbp_type = ADM8211_TYPE_ADMTEK;
@@ -160,17 +182,17 @@ static int adm8211_read_eeprom(struct ieee80211_hw *dev)
        printk(KERN_DEBUG "%s (adm8211): Channel range: %d - %d\n",
               pci_name(priv->pdev), (int)chan_range.min, (int)chan_range.max);
 
-       priv->modes[0].num_channels = chan_range.max - chan_range.min + 1;
-       priv->modes[0].channels = priv->channels;
+       BUILD_BUG_ON(sizeof(priv->channels) != sizeof(adm8211_channels));
 
-       memcpy(priv->channels, adm8211_channels, sizeof(adm8211_channels));
+       memcpy(priv->channels, adm8211_channels, sizeof(priv->channels));
+       priv->band.channels = priv->channels;
+       priv->band.n_channels = ARRAY_SIZE(adm8211_channels);
+       priv->band.bitrates = adm8211_rates;
+       priv->band.n_bitrates = ARRAY_SIZE(adm8211_rates);
 
        for (i = 1; i <= ARRAY_SIZE(adm8211_channels); i++)
-               if (i >= chan_range.min && i <= chan_range.max)
-                       priv->channels[i - 1].flag =
-                               IEEE80211_CHAN_W_SCAN |
-                               IEEE80211_CHAN_W_ACTIVE_SCAN |
-                               IEEE80211_CHAN_W_IBSS;
+               if (i < chan_range.min || i > chan_range.max)
+                       priv->channels[i - 1].flags |= IEEE80211_CHAN_DISABLED;
 
        switch (priv->eeprom->specific_bbptype) {
        case ADM8211_BBP_RFMD3000:
@@ -180,7 +202,7 @@ static int adm8211_read_eeprom(struct ieee80211_hw *dev)
                break;
 
        default:
-               if (priv->revid < ADM8211_REV_CA)
+               if (priv->pdev->revision < ADM8211_REV_CA)
                        priv->specific_bbptype = ADM8211_BBP_RFMD3000;
                else
                        priv->specific_bbptype = ADM8211_BBP_ADM8011;
@@ -199,11 +221,11 @@ static int adm8211_read_eeprom(struct ieee80211_hw *dev)
                break;
 
        default:
-               if (priv->revid == ADM8211_REV_BA)
+               if (priv->pdev->revision == ADM8211_REV_BA)
                        priv->transceiver_type = ADM8211_RFMD2958_RF3000_CONTROL_POWER;
-               else if (priv->revid == ADM8211_REV_CA)
+               else if (priv->pdev->revision == ADM8211_REV_CA)
                        priv->transceiver_type = ADM8211_AL2210L;
-               else if (priv->revid == ADM8211_REV_AB)
+               else if (priv->pdev->revision == ADM8211_REV_AB)
                        priv->transceiver_type = ADM8211_RFMD2948;
 
                printk(KERN_WARNING "%s (adm8211): Unknown transceiver: %d\n",
@@ -225,7 +247,7 @@ static inline void adm8211_write_sram(struct ieee80211_hw *dev,
        struct adm8211_priv *priv = dev->priv;
 
        ADM8211_CSR_WRITE(WEPCTL, addr | ADM8211_WEPCTL_TABLE_WR |
-                         (priv->revid < ADM8211_REV_BA ?
+                         (priv->pdev->revision < ADM8211_REV_BA ?
                           0 : ADM8211_WEPCTL_SEL_WEPTABLE ));
        ADM8211_CSR_READ(WEPCTL);
        msleep(1);
@@ -243,7 +265,7 @@ static void adm8211_write_sram_bytes(struct ieee80211_hw *dev,
        u32 reg = ADM8211_CSR_READ(WEPCTL);
        unsigned int i;
 
-       if (priv->revid < ADM8211_REV_BA) {
+       if (priv->pdev->revision < ADM8211_REV_BA) {
                for (i = 0; i < len; i += 2) {
                        u16 val = buf[i] | (buf[i + 1] << 8);
                        adm8211_write_sram(dev, addr + i / 2, val);
@@ -281,19 +303,6 @@ static int adm8211_get_stats(struct ieee80211_hw *dev,
        return 0;
 }
 
-static int adm8211_get_tx_stats(struct ieee80211_hw *dev,
-                               struct ieee80211_tx_queue_stats *stats)
-{
-       struct adm8211_priv *priv = dev->priv;
-       struct ieee80211_tx_queue_stats_data *data = &stats->data[0];
-
-       data->len = priv->cur_tx - priv->dirty_tx;
-       data->limit = priv->tx_ring_size - 2;
-       data->count = priv->dirty_tx;
-
-       return 0;
-}
-
 static void adm8211_interrupt_tci(struct ieee80211_hw *dev)
 {
        struct adm8211_priv *priv = dev->priv;
@@ -304,6 +313,7 @@ static void adm8211_interrupt_tci(struct ieee80211_hw *dev)
        for (dirty_tx = priv->dirty_tx; priv->cur_tx - dirty_tx; dirty_tx++) {
                unsigned int entry = dirty_tx % priv->tx_ring_size;
                u32 status = le32_to_cpu(priv->tx_ring[entry].status);
+               struct ieee80211_tx_info *txi;
                struct adm8211_tx_ring_info *info;
                struct sk_buff *skb;
 
@@ -313,27 +323,23 @@ static void adm8211_interrupt_tci(struct ieee80211_hw *dev)
 
                info = &priv->tx_buffers[entry];
                skb = info->skb;
+               txi = IEEE80211_SKB_CB(skb);
 
                /* TODO: check TDES0_STATUS_TUF and TDES0_STATUS_TRO */
 
                pci_unmap_single(priv->pdev, info->mapping,
                                 info->skb->len, PCI_DMA_TODEVICE);
 
-               if (info->tx_control.flags & IEEE80211_TXCTL_REQ_TX_STATUS) {
-                       struct ieee80211_tx_status tx_status = {{0}};
-                       struct ieee80211_hdr *hdr;
-                       size_t hdrlen = info->hdrlen;
-
-                       skb_pull(skb, sizeof(struct adm8211_tx_hdr));
-                       hdr = (struct ieee80211_hdr *)skb_push(skb, hdrlen);
-                       memcpy(hdr, skb->cb, hdrlen);
-                       memcpy(&tx_status.control, &info->tx_control,
-                              sizeof(tx_status.control));
-                       if (!(status & TDES0_STATUS_ES))
-                               tx_status.flags |= IEEE80211_TX_STATUS_ACK;
-                       ieee80211_tx_status_irqsafe(dev, skb, &tx_status);
-               } else
-                       dev_kfree_skb_irq(skb);
+               ieee80211_tx_info_clear_status(txi);
+
+               skb_pull(skb, sizeof(struct adm8211_tx_hdr));
+               memcpy(skb_push(skb, info->hdrlen), skb->cb, info->hdrlen);
+               if (!(txi->flags & IEEE80211_TX_CTL_NO_ACK) &&
+                   !(status & TDES0_STATUS_ES))
+                       txi->flags |= IEEE80211_TX_STAT_ACK;
+
+               ieee80211_tx_status_irqsafe(dev, skb);
+
                info->skb = NULL;
        }
 
@@ -353,7 +359,6 @@ static void adm8211_interrupt_rci(struct ieee80211_hw *dev)
        unsigned int pktlen;
        struct sk_buff *skb, *newskb;
        unsigned int limit = priv->rx_ring_size;
-       static const u8 rate_tbl[] = {10, 20, 55, 110, 220};
        u8 rssi, rate;
 
        while (!(priv->rx_ring[entry].status & cpu_to_le32(RDES0_STATUS_OWN))) {
@@ -426,19 +431,18 @@ static void adm8211_interrupt_rci(struct ieee80211_hw *dev)
                if (skb) {
                        struct ieee80211_rx_status rx_status = {0};
 
-                       if (priv->revid < ADM8211_REV_CA)
-                               rx_status.ssi = rssi;
+                       if (priv->pdev->revision < ADM8211_REV_CA)
+                               rx_status.signal = rssi;
                        else
-                               rx_status.ssi = 100 - rssi;
+                               rx_status.signal = 100 - rssi;
 
-                       if (rate <= 4)
-                               rx_status.rate = rate_tbl[rate];
+                       rx_status.rate_idx = rate;
 
-                       rx_status.channel = priv->channel;
-                       rx_status.freq = adm8211_channels[priv->channel - 1].freq;
-                       rx_status.phymode = MODE_IEEE80211B;
+                       rx_status.freq = adm8211_channels[priv->channel - 1].center_freq;
+                       rx_status.band = IEEE80211_BAND_2GHZ;
 
-                       ieee80211_rx_irqsafe(dev, skb, &rx_status);
+                       memcpy(IEEE80211_SKB_RXCB(skb), &rx_status, sizeof(rx_status));
+                       ieee80211_rx_irqsafe(dev, skb);
                }
 
                entry = (++priv->cur_rx) % priv->rx_ring_size;
@@ -471,9 +475,6 @@ do {                                                                           \
        if (stsr & ADM8211_STSR_TCI)
                adm8211_interrupt_tci(dev);
 
-       /*ADM8211_INT(LinkOn);*/
-       /*ADM8211_INT(LinkOff);*/
-
        ADM8211_INT(PCF);
        ADM8211_INT(BCNTC);
        ADM8211_INT(GPINT);
@@ -483,7 +484,6 @@ do {                                                                           \
        ADM8211_INT(SQL);
        ADM8211_INT(WEPTD);
        ADM8211_INT(ATIME);
-       /*ADM8211_INT(TBTT);*/
        ADM8211_INT(TEIS);
        ADM8211_INT(FBE);
        ADM8211_INT(REIS);
@@ -491,9 +491,6 @@ do {                                                                           \
        ADM8211_INT(RPS);
        ADM8211_INT(RDU);
        ADM8211_INT(TUF);
-       /*ADM8211_INT(TRT);*/
-       /*ADM8211_INT(TLT);*/
-       /*ADM8211_INT(TDU);*/
        ADM8211_INT(TPS);
 
        return IRQ_HANDLED;
@@ -708,7 +705,7 @@ static int adm8211_rf_set_channel(struct ieee80211_hw *dev, unsigned int chan)
                adm8211_rf_write_syn_rfmd2958(dev, 0x0A, reg);
                /* set TXRX TX_GAIN */
                adm8211_rf_write_syn_rfmd2958(dev, 0x09, 0x00050 |
-                       (priv->revid < ADM8211_REV_CA ? tx_power : 0));
+                       (priv->pdev->revision < ADM8211_REV_CA ? tx_power : 0));
        } else {
                reg = ADM8211_CSR_READ(PLCPHD);
                reg &= 0xff00ffff;
@@ -727,7 +724,7 @@ static int adm8211_rf_set_channel(struct ieee80211_hw *dev, unsigned int chan)
                                  tx_power<<2);
        adm8211_write_bbp(dev, RF3000_LOW_GAIN_CALIB, lpf_cutoff);
        adm8211_write_bbp(dev, RF3000_HIGH_GAIN_CALIB, lnags_thresh);
-       adm8211_write_bbp(dev, 0x1c, priv->revid == ADM8211_REV_BA ?
+       adm8211_write_bbp(dev, 0x1c, priv->pdev->revision == ADM8211_REV_BA ?
                                     priv->eeprom->cr28 : 0);
        adm8211_write_bbp(dev, 0x1d, priv->eeprom->cr29);
 
@@ -757,19 +754,19 @@ static void adm8211_update_mode(struct ieee80211_hw *dev)
 
        priv->soft_rx_crc = 0;
        switch (priv->mode) {
-       case IEEE80211_IF_TYPE_STA:
+       case NL80211_IFTYPE_STATION:
                priv->nar &= ~(ADM8211_NAR_PR | ADM8211_NAR_EA);
                priv->nar |= ADM8211_NAR_ST | ADM8211_NAR_SR;
                break;
-       case IEEE80211_IF_TYPE_IBSS:
+       case NL80211_IFTYPE_ADHOC:
                priv->nar &= ~ADM8211_NAR_PR;
                priv->nar |= ADM8211_NAR_EA | ADM8211_NAR_ST | ADM8211_NAR_SR;
 
                /* don't trust the error bits on rev 0x20 and up in adhoc */
-               if (priv->revid >= ADM8211_REV_BA)
+               if (priv->pdev->revision >= ADM8211_REV_BA)
                        priv->soft_rx_crc = 1;
                break;
-       case IEEE80211_IF_TYPE_MNTR:
+       case NL80211_IFTYPE_MONITOR:
                priv->nar &= ~(ADM8211_NAR_EA | ADM8211_NAR_ST);
                priv->nar |= ADM8211_NAR_PR | ADM8211_NAR_SR;
                break;
@@ -867,7 +864,7 @@ static int adm8211_hw_init_bbp(struct ieee80211_hw *dev)
                        break;
                }
 
-               switch (priv->revid) {
+               switch (priv->pdev->revision) {
                case ADM8211_REV_CA:
                        if (priv->transceiver_type == ADM8211_RFMD2958 ||
                            priv->transceiver_type == ADM8211_RFMD2958_RF3000_CONTROL_POWER ||
@@ -925,7 +922,7 @@ static int adm8211_hw_init_bbp(struct ieee80211_hw *dev)
                        adm8211_write_bbp(dev, 0x1c, 0x00);
                        adm8211_write_bbp(dev, 0x1d, 0x80);
                } else {
-                       if (priv->revid == ADM8211_REV_BA)
+                       if (priv->pdev->revision == ADM8211_REV_BA)
                                adm8211_write_bbp(dev, 0x1c, priv->eeprom->cr28);
                        else
                                adm8211_write_bbp(dev, 0x1c, 0x00);
@@ -1057,10 +1054,10 @@ static int adm8211_set_rate(struct ieee80211_hw *dev)
        u8 rate_buf[12] = {0};
 
        /* write supported rates */
-       if (priv->revid != ADM8211_REV_BA) {
+       if (priv->pdev->revision != ADM8211_REV_BA) {
                rate_buf[0] = ARRAY_SIZE(adm8211_rates);
                for (i = 0; i < ARRAY_SIZE(adm8211_rates); i++)
-                       rate_buf[i + 1] = (adm8211_rates[i].rate / 5) | 0x80;
+                       rate_buf[i + 1] = (adm8211_rates[i].bitrate / 5) | 0x80;
        } else {
                /* workaround for rev BA specific bug */
                rate_buf[0] = 0x04;
@@ -1092,7 +1089,7 @@ static void adm8211_hw_init(struct ieee80211_hw *dev)
        u32 reg;
        u8 cline;
 
-       reg = le32_to_cpu(ADM8211_CSR_READ(PAR));
+       reg = ADM8211_CSR_READ(PAR);
        reg |= ADM8211_PAR_MRLE | ADM8211_PAR_MRME;
        reg &= ~(ADM8211_PAR_BAR | ADM8211_PAR_CAL);
 
@@ -1141,7 +1138,7 @@ static void adm8211_hw_init(struct ieee80211_hw *dev)
         * PWR0PE2  = 13 us
         * PWR1PE2  = 1 us
         * PWR0TXPE = 8 or 6 */
-       if (priv->revid < ADM8211_REV_CA)
+       if (priv->pdev->revision < ADM8211_REV_CA)
                ADM8211_CSR_WRITE(TOFS2, 0x8815cd18);
        else
                ADM8211_CSR_WRITE(TOFS2, 0x8535cd16);
@@ -1170,7 +1167,7 @@ static void adm8211_hw_init(struct ieee80211_hw *dev)
 
        /* SLOT=20 us, SIFS=110 cycles of 22 MHz (5 us),
         * DIFS=50 us, EIFS=100 us */
-       if (priv->revid < ADM8211_REV_CA)
+       if (priv->pdev->revision < ADM8211_REV_CA)
                ADM8211_CSR_WRITE(IFST, (20 << 23) | (110 << 15) |
                                        (50 << 9)  | 100);
        else
@@ -1229,13 +1226,13 @@ static int adm8211_hw_reset(struct ieee80211_hw *dev)
 
        ADM8211_CSR_WRITE(PAR, tmp);
 
-       if (priv->revid == ADM8211_REV_BA &&
+       if (priv->pdev->revision == ADM8211_REV_BA &&
            (priv->transceiver_type == ADM8211_RFMD2958_RF3000_CONTROL_POWER ||
             priv->transceiver_type == ADM8211_RFMD2958)) {
                reg = ADM8211_CSR_READ(CSR_TEST1);
                reg |= (1 << 4) | (1 << 5);
                ADM8211_CSR_WRITE(CSR_TEST1, reg);
-       } else if (priv->revid == ADM8211_REV_CA) {
+       } else if (priv->pdev->revision == ADM8211_REV_CA) {
                reg = ADM8211_CSR_READ(CSR_TEST1);
                reg &= ~((1 << 4) | (1 << 5));
                ADM8211_CSR_WRITE(CSR_TEST1, reg);
@@ -1290,64 +1287,69 @@ static void adm8211_set_bssid(struct ieee80211_hw *dev, const u8 *bssid)
        ADM8211_CSR_WRITE(ABDA1, reg);
 }
 
-static int adm8211_set_ssid(struct ieee80211_hw *dev, u8 *ssid, size_t ssid_len)
+static int adm8211_config(struct ieee80211_hw *dev, u32 changed)
 {
        struct adm8211_priv *priv = dev->priv;
-       u8 buf[36];
-
-       if (ssid_len > 32)
-               return -EINVAL;
+       struct ieee80211_conf *conf = &dev->conf;
+       int channel = ieee80211_frequency_to_channel(conf->channel->center_freq);
 
-       memset(buf, 0, sizeof(buf));
-       buf[0] = ssid_len;
-       memcpy(buf + 1, ssid, ssid_len);
-       adm8211_write_sram_bytes(dev, ADM8211_SRAM_SSID, buf, 33);
-       /* TODO: configure beacon for adhoc? */
-       return 0;
-}
-
-static int adm8211_config(struct ieee80211_hw *dev, struct ieee80211_conf *conf)
-{
-       struct adm8211_priv *priv = dev->priv;
-
-       if (conf->channel != priv->channel) {
-               priv->channel = conf->channel;
+       if (channel != priv->channel) {
+               priv->channel = channel;
                adm8211_rf_set_channel(dev, priv->channel);
        }
 
        return 0;
 }
 
-static int adm8211_config_interface(struct ieee80211_hw *dev, int if_id,
-                                   struct ieee80211_if_conf *conf)
+static void adm8211_bss_info_changed(struct ieee80211_hw *dev,
+                                    struct ieee80211_vif *vif,
+                                    struct ieee80211_bss_conf *conf,
+                                    u32 changes)
 {
        struct adm8211_priv *priv = dev->priv;
 
+       if (!(changes & BSS_CHANGED_BSSID))
+               return;
+
        if (memcmp(conf->bssid, priv->bssid, ETH_ALEN)) {
                adm8211_set_bssid(dev, conf->bssid);
                memcpy(priv->bssid, conf->bssid, ETH_ALEN);
        }
+}
 
-       if (conf->ssid_len != priv->ssid_len ||
-           memcmp(conf->ssid, priv->ssid, conf->ssid_len)) {
-               adm8211_set_ssid(dev, conf->ssid, conf->ssid_len);
-               priv->ssid_len = conf->ssid_len;
-               memcpy(priv->ssid, conf->ssid, conf->ssid_len);
+static u64 adm8211_prepare_multicast(struct ieee80211_hw *hw,
+                                    int mc_count, struct dev_addr_list *mclist)
+{
+       unsigned int bit_nr, i;
+       u32 mc_filter[2];
+
+       mc_filter[1] = mc_filter[0] = 0;
+
+       for (i = 0; i < mc_count; i++) {
+               if (!mclist)
+                       break;
+               bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26;
+
+               bit_nr &= 0x3F;
+               mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31);
+               mclist = mclist->next;
        }
 
-       return 0;
+       return mc_filter[0] | ((u64)(mc_filter[1]) << 32);
 }
 
 static void adm8211_configure_filter(struct ieee80211_hw *dev,
                                     unsigned int changed_flags,
                                     unsigned int *total_flags,
-                                    int mc_count, struct dev_mc_list *mclist)
+                                    u64 multicast)
 {
        static const u8 bcast[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
        struct adm8211_priv *priv = dev->priv;
-       unsigned int bit_nr, new_flags;
+       unsigned int new_flags;
        u32 mc_filter[2];
-       int i;
+
+       mc_filter[0] = multicast;
+       mc_filter[1] = multicast >> 32;
 
        new_flags = 0;
 
@@ -1356,23 +1358,13 @@ static void adm8211_configure_filter(struct ieee80211_hw *dev,
                priv->nar |= ADM8211_NAR_PR;
                priv->nar &= ~ADM8211_NAR_MM;
                mc_filter[1] = mc_filter[0] = ~0;
-       } else if ((*total_flags & FIF_ALLMULTI) || (mc_count > 32)) {
+       } else if (*total_flags & FIF_ALLMULTI || multicast == ~(0ULL)) {
                new_flags |= FIF_ALLMULTI;
                priv->nar &= ~ADM8211_NAR_PR;
                priv->nar |= ADM8211_NAR_MM;
                mc_filter[1] = mc_filter[0] = ~0;
        } else {
                priv->nar &= ~(ADM8211_NAR_MM | ADM8211_NAR_PR);
-               mc_filter[1] = mc_filter[0] = 0;
-               for (i = 0; i < mc_count; i++) {
-                       if (!mclist)
-                               break;
-                       bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26;
-
-                       bit_nr &= 0x3F;
-                       mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31);
-                       mclist = mclist->next;
-               }
        }
 
        ADM8211_IDLE_RX();
@@ -1397,15 +1389,15 @@ static void adm8211_configure_filter(struct ieee80211_hw *dev,
 }
 
 static int adm8211_add_interface(struct ieee80211_hw *dev,
-                                struct ieee80211_if_init_conf *conf)
+                                struct ieee80211_vif *vif)
 {
        struct adm8211_priv *priv = dev->priv;
-       if (priv->mode != IEEE80211_IF_TYPE_MNTR)
+       if (priv->mode != NL80211_IFTYPE_MONITOR)
                return -EOPNOTSUPP;
 
-       switch (conf->type) {
-       case IEEE80211_IF_TYPE_STA:
-               priv->mode = conf->type;
+       switch (vif->type) {
+       case NL80211_IFTYPE_STATION:
+               priv->mode = vif->type;
                break;
        default:
                return -EOPNOTSUPP;
@@ -1413,8 +1405,8 @@ static int adm8211_add_interface(struct ieee80211_hw *dev,
 
        ADM8211_IDLE();
 
-       ADM8211_CSR_WRITE(PAR0, le32_to_cpu(*(__le32 *)conf->mac_addr));
-       ADM8211_CSR_WRITE(PAR1, le16_to_cpu(*(__le16 *)(conf->mac_addr + 4)));
+       ADM8211_CSR_WRITE(PAR0, le32_to_cpu(*(__le32 *)vif->addr));
+       ADM8211_CSR_WRITE(PAR1, le16_to_cpu(*(__le16 *)(vif->addr + 4)));
 
        adm8211_update_mode(dev);
 
@@ -1424,10 +1416,10 @@ static int adm8211_add_interface(struct ieee80211_hw *dev,
 }
 
 static void adm8211_remove_interface(struct ieee80211_hw *dev,
-                                    struct ieee80211_if_init_conf *conf)
+                                    struct ieee80211_vif *vif)
 {
        struct adm8211_priv *priv = dev->priv;
-       priv->mode = IEEE80211_IF_TYPE_MNTR;
+       priv->mode = NL80211_IFTYPE_MONITOR;
 }
 
 static int adm8211_init_rings(struct ieee80211_hw *dev)
@@ -1535,7 +1527,7 @@ static int adm8211_start(struct ieee80211_hw *dev)
        adm8211_hw_init(dev);
        adm8211_rf_set_channel(dev, priv->channel);
 
-       retval = request_irq(priv->pdev->irq, &adm8211_interrupt,
+       retval = request_irq(priv->pdev->irq, adm8211_interrupt,
                             IRQF_SHARED, "adm8211", dev);
        if (retval) {
                printk(KERN_ERR "%s: failed to register IRQ handler\n",
@@ -1546,6 +1538,7 @@ static int adm8211_start(struct ieee80211_hw *dev)
        ADM8211_CSR_WRITE(IER, ADM8211_IER_NIE | ADM8211_IER_AIE |
                               ADM8211_IER_RCIE | ADM8211_IER_TCIE |
                               ADM8211_IER_TDUIE | ADM8211_IER_GPTIE);
+       priv->mode = NL80211_IFTYPE_MONITOR;
        adm8211_update_mode(dev);
        ADM8211_CSR_WRITE(RDR, 0);
 
@@ -1560,6 +1553,7 @@ static void adm8211_stop(struct ieee80211_hw *dev)
 {
        struct adm8211_priv *priv = dev->priv;
 
+       priv->mode = NL80211_IFTYPE_UNSPECIFIED;
        priv->nar = 0;
        ADM8211_CSR_WRITE(NAR, 0);
        ADM8211_CSR_WRITE(IER, 0);
@@ -1625,7 +1619,6 @@ static void adm8211_calc_durations(int *dur, int *plcp, size_t payload_len, int
 /* Transmit skb w/adm8211_tx_hdr (802.11 header created by hardware) */
 static void adm8211_tx_raw(struct ieee80211_hw *dev, struct sk_buff *skb,
                           u16 plcp_signal,
-                          struct ieee80211_tx_control *control,
                           size_t hdrlen)
 {
        struct adm8211_priv *priv = dev->priv;
@@ -1651,7 +1644,6 @@ static void adm8211_tx_raw(struct ieee80211_hw *dev, struct sk_buff *skb,
 
        priv->tx_buffers[entry].skb = skb;
        priv->tx_buffers[entry].mapping = mapping;
-       memcpy(&priv->tx_buffers[entry].tx_control, control, sizeof(*control));
        priv->tx_buffers[entry].hdrlen = hdrlen;
        priv->tx_ring[entry].buffer1 = cpu_to_le32(mapping);
 
@@ -1672,26 +1664,22 @@ static void adm8211_tx_raw(struct ieee80211_hw *dev, struct sk_buff *skb,
 }
 
 /* Put adm8211_tx_hdr on skb and transmit */
-static int adm8211_tx(struct ieee80211_hw *dev, struct sk_buff *skb,
-                     struct ieee80211_tx_control *control)
+static int adm8211_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
 {
        struct adm8211_tx_hdr *txhdr;
-       u16 fc;
        size_t payload_len, hdrlen;
        int plcp, dur, len, plcp_signal, short_preamble;
        struct ieee80211_hdr *hdr;
+       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
+       struct ieee80211_rate *txrate = ieee80211_get_tx_rate(dev, info);
+       u8 rc_flags;
 
-       if (control->tx_rate < 0) {
-               short_preamble = 1;
-               plcp_signal = -control->tx_rate;
-       } else {
-               short_preamble = 0;
-               plcp_signal = control->tx_rate;
-       }
+       rc_flags = info->control.rates[0].flags;
+       short_preamble = !!(rc_flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE);
+       plcp_signal = txrate->bitrate;
 
        hdr = (struct ieee80211_hdr *)skb->data;
-       fc = le16_to_cpu(hdr->frame_control) & ~IEEE80211_FCTL_PROTECTED;
-       hdrlen = ieee80211_get_hdrlen(fc);
+       hdrlen = ieee80211_hdrlen(hdr->frame_control);
        memcpy(skb->cb, skb->data, hdrlen);
        hdr = (struct ieee80211_hdr *)skb->cb;
        skb_pull(skb, hdrlen);
@@ -1705,8 +1693,6 @@ static int adm8211_tx(struct ieee80211_hw *dev, struct sk_buff *skb,
        txhdr->frame_control = hdr->frame_control;
 
        len = hdrlen + payload_len + FCS_LEN;
-       if (fc & IEEE80211_FCTL_PROTECTED)
-               len += 8;
 
        txhdr->frag = cpu_to_le16(0x0FFF);
        adm8211_calc_durations(&dur, &plcp, payload_len,
@@ -1721,15 +1707,12 @@ static int adm8211_tx(struct ieee80211_hw *dev, struct sk_buff *skb,
        if (short_preamble)
                txhdr->header_control |= cpu_to_le16(ADM8211_TXHDRCTL_SHORT_PREAMBLE);
 
-       if (control->flags & IEEE80211_TXCTL_USE_RTS_CTS)
+       if (rc_flags & IEEE80211_TX_RC_USE_RTS_CTS)
                txhdr->header_control |= cpu_to_le16(ADM8211_TXHDRCTL_ENABLE_RTS);
 
-       if (fc & IEEE80211_FCTL_PROTECTED)
-               txhdr->header_control |= cpu_to_le16(ADM8211_TXHDRCTL_ENABLE_WEP_ENGINE);
-
-       txhdr->retry_limit = control->retry_limit;
+       txhdr->retry_limit = info->control.rates[0].count;
 
-       adm8211_tx_raw(dev, skb, plcp_signal, control, hdrlen);
+       adm8211_tx_raw(dev, skb, plcp_signal, hdrlen);
 
        return NETDEV_TX_OK;
 }
@@ -1775,10 +1758,10 @@ static const struct ieee80211_ops adm8211_ops = {
        .add_interface          = adm8211_add_interface,
        .remove_interface       = adm8211_remove_interface,
        .config                 = adm8211_config,
-       .config_interface       = adm8211_config_interface,
+       .bss_info_changed       = adm8211_bss_info_changed,
+       .prepare_multicast      = adm8211_prepare_multicast,
        .configure_filter       = adm8211_configure_filter,
        .get_stats              = adm8211_get_stats,
-       .get_tx_stats           = adm8211_get_tx_stats,
        .get_tsf                = adm8211_get_tsft
 };
 
@@ -1792,13 +1775,6 @@ static int __devinit adm8211_probe(struct pci_dev *pdev,
        int err;
        u32 reg;
        u8 perm_addr[ETH_ALEN];
-       DECLARE_MAC_BUF(mac);
-
-#ifndef MODULE
-       static unsigned int cardidx;
-       if (!cardidx++)
-               printk(version);
-#endif
 
        err = pci_enable_device(pdev);
        if (err) {
@@ -1833,8 +1809,8 @@ static int __devinit adm8211_probe(struct pci_dev *pdev,
                return err; /* someone else grabbed it? don't disable it */
        }
 
-       if (pci_set_dma_mask(pdev, DMA_32BIT_MASK) ||
-           pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK)) {
+       if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) ||
+           pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) {
                printk(KERN_ERR "%s (adm8211): No suitable DMA available\n",
                       pci_name(pdev));
                goto err_free_reg;
@@ -1877,11 +1853,9 @@ static int __devinit adm8211_probe(struct pci_dev *pdev,
                goto err_iounmap;
        }
 
-       pci_read_config_byte(pdev, PCI_CLASS_REVISION, &priv->revid);
-
-       *(u32 *)perm_addr = le32_to_cpu((__force __le32)ADM8211_CSR_READ(PAR0));
-       *(u16 *)&perm_addr[4] =
-               le16_to_cpu((__force __le16)ADM8211_CSR_READ(PAR1) & 0xFFFF);
+       *(__le32 *)perm_addr = cpu_to_le32(ADM8211_CSR_READ(PAR0));
+       *(__le16 *)&perm_addr[4] =
+               cpu_to_le16(ADM8211_CSR_READ(PAR1) & 0xFFFF);
 
        if (!is_valid_ether_addr(perm_addr)) {
                printk(KERN_WARNING "%s (adm8211): Invalid hwaddr in EEPROM!\n",
@@ -1891,17 +1865,12 @@ static int __devinit adm8211_probe(struct pci_dev *pdev,
        SET_IEEE80211_PERM_ADDR(dev, perm_addr);
 
        dev->extra_tx_headroom = sizeof(struct adm8211_tx_hdr);
-       dev->flags = IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED;
-       /* IEEE80211_HW_RX_INCLUDES_FCS in promisc mode */
+       /* dev->flags = IEEE80211_HW_RX_INCLUDES_FCS in promisc mode */
+       dev->flags = IEEE80211_HW_SIGNAL_UNSPEC;
+       dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
 
        dev->channel_change_time = 1000;
-       dev->max_rssi = 100;    /* FIXME: find better value */
-
-       priv->modes[0].mode = MODE_IEEE80211B;
-       /* channel info filled in by adm8211_read_eeprom */
-       memcpy(priv->rates, adm8211_rates, sizeof(adm8211_rates));
-       priv->modes[0].num_rates = ARRAY_SIZE(adm8211_rates);
-       priv->modes[0].rates = priv->rates;
+       dev->max_signal = 100;    /* FIXME: find better value */
 
        dev->queues = 1; /* ADM8211C supports more, maybe ADM8211B too */
 
@@ -1910,10 +1879,10 @@ static int __devinit adm8211_probe(struct pci_dev *pdev,
        priv->tx_power = 0x40;
        priv->lpf_cutoff = 0xFF;
        priv->lnags_threshold = 0xFF;
-       priv->mode = IEEE80211_IF_TYPE_MNTR;
+       priv->mode = NL80211_IFTYPE_UNSPECIFIED;
 
        /* Power-on issue. EEPROM won't read correctly without */
-       if (priv->revid >= ADM8211_REV_BA) {
+       if (pdev->revision >= ADM8211_REV_BA) {
                ADM8211_CSR_WRITE(FRCTL, 0);
                ADM8211_CSR_READ(FRCTL);
                ADM8211_CSR_WRITE(FRCTL, 1);
@@ -1928,14 +1897,9 @@ static int __devinit adm8211_probe(struct pci_dev *pdev,
                goto err_free_desc;
        }
 
-       priv->channel = priv->modes[0].channels[0].chan;
+       priv->channel = 1;
 
-       err = ieee80211_register_hwmode(dev, &priv->modes[0]);
-       if (err) {
-               printk(KERN_ERR "%s (adm8211): Can't register hwmode\n",
-                      pci_name(pdev));
-               goto err_free_desc;
-       }
+       dev->wiphy->bands[IEEE80211_BAND_2GHZ] = &priv->band;
 
        err = ieee80211_register_hw(dev);
        if (err) {
@@ -1944,9 +1908,9 @@ static int __devinit adm8211_probe(struct pci_dev *pdev,
                goto err_free_desc;
        }
 
-       printk(KERN_INFO "%s: hwaddr %s, Rev 0x%02x\n",
-              wiphy_name(dev->wiphy), print_mac(mac, dev->wiphy->perm_addr),
-              priv->revid);
+       printk(KERN_INFO "%s: hwaddr %pM, Rev 0x%02x\n",
+              wiphy_name(dev->wiphy), dev->wiphy->perm_addr,
+              pdev->revision);
 
        return 0;
 
@@ -2002,14 +1966,6 @@ static void __devexit adm8211_remove(struct pci_dev *pdev)
 #ifdef CONFIG_PM
 static int adm8211_suspend(struct pci_dev *pdev, pm_message_t state)
 {
-       struct ieee80211_hw *dev = pci_get_drvdata(pdev);
-       struct adm8211_priv *priv = dev->priv;
-
-       if (priv->mode != IEEE80211_IF_TYPE_MNTR) {
-               ieee80211_stop_queues(dev);
-               adm8211_stop(dev);
-       }
-
        pci_save_state(pdev);
        pci_set_power_state(pdev, pci_choose_state(pdev, state));
        return 0;
@@ -2017,17 +1973,8 @@ static int adm8211_suspend(struct pci_dev *pdev, pm_message_t state)
 
 static int adm8211_resume(struct pci_dev *pdev)
 {
-       struct ieee80211_hw *dev = pci_get_drvdata(pdev);
-       struct adm8211_priv *priv = dev->priv;
-
        pci_set_power_state(pdev, PCI_D0);
        pci_restore_state(pdev);
-
-       if (priv->mode != IEEE80211_IF_TYPE_MNTR) {
-               adm8211_start(dev);
-               ieee80211_start_queues(dev);
-       }
-
        return 0;
 }
 #endif /* CONFIG_PM */
@@ -2051,10 +1998,6 @@ static struct pci_driver adm8211_driver = {
 
 static int __init adm8211_init(void)
 {
-#ifdef MODULE
-       printk(version);
-#endif
-
        return pci_register_driver(&adm8211_driver);
 }