iwlwifi: fix compiler warning
[safe/jmp/linux-2.6] / drivers / net / wireless / wl3501_cs.c
index e3ae5f6..65dd502 100644 (file)
@@ -26,7 +26,6 @@
  * Tested with Planet AP in 2.5.73-bk, 216 Kbytes/s in Infrastructure mode
  * with a SMP machine (dual pentium 100), using pktgen, 432 pps (pkt_size = 60)
  */
-#undef REALLY_SLOW_IO  /* most systems can safely undef this */
 
 #include <linux/delay.h>
 #include <linux/types.h>
@@ -45,6 +44,7 @@
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/wireless.h>
+#include <linux/ieee80211.h>
 
 #include <net/iw_handler.h>
 
 /* For rough constant delay */
 #define WL3501_NOPLOOP(n) { int x = 0; while (x++ < n) slow_down_io(); }
 
-/*
- * All the PCMCIA modules use PCMCIA_DEBUG to control debugging.  If you do not
- * define PCMCIA_DEBUG at all, all the debug code will be left out.  If you
- * compile with PCMCIA_DEBUG=0, the debug code will be present but disabled --
- * but it can then be enabled for specific modules at load time with a
- * 'pc_debug=#' option to insmod.
- */
-#define PCMCIA_DEBUG 0
-#ifdef PCMCIA_DEBUG
-static int pc_debug = PCMCIA_DEBUG;
-module_param(pc_debug, int, 0);
-#define dprintk(n, format, args...) \
-       { if (pc_debug > (n)) \
-               printk(KERN_INFO "%s: " format "\n", __FUNCTION__ , ##args); }
-#else
-#define dprintk(n, format, args...)
-#endif
+
 
 #define wl3501_outb(a, b) { outb(a, b); slow_down_io(); }
 #define wl3501_outb_p(a, b) { outb_p(a, b); slow_down_io(); }
@@ -112,12 +96,6 @@ static void wl3501_release(struct pcmcia_device *link);
  */
 static dev_info_t wl3501_dev_info = "wl3501_cs";
 
-static int wl3501_chan2freq[] = {
-       [0]  = 2412, [1]  = 2417, [2]  = 2422, [3]  = 2427, [4] = 2432,
-       [5]  = 2437, [6]  = 2442, [7]  = 2447, [8]  = 2452, [9] = 2457,
-       [10] = 2462, [11] = 2467, [12] = 2472, [13] = 2477,
-};
-
 static const struct {
        int reg_domain;
        int min, max, deflt;
@@ -387,7 +365,7 @@ static void wl3501_free_tx_buffer(struct wl3501_card *this, u16 ptr)
 
 static int wl3501_esbq_req_test(struct wl3501_card *this)
 {
-       u8 tmp;
+       u8 tmp = 0;
 
        wl3501_get_from_wla(this, this->esbq_req_head + 3, &tmp, sizeof(tmp));
        return tmp & 0x80;
@@ -471,7 +449,7 @@ static int wl3501_pwr_mgmt(struct wl3501_card *this, int suspend)
                        spin_unlock_irqrestore(&this->lock, flags);
                        rc = wait_event_interruptible(this->wait,
                                this->sig_pwr_mgmt_confirm.status != 255);
-                       printk(KERN_INFO "%s: %s status=%d\n", __FUNCTION__,
+                       printk(KERN_INFO "%s: %s status=%d\n", __func__,
                               suspend ? "suspend" : "resume",
                               this->sig_pwr_mgmt_confirm.status);
                        goto out;
@@ -690,10 +668,10 @@ static void wl3501_mgmt_scan_confirm(struct wl3501_card *this, u16 addr)
        int matchflag = 0;
        struct wl3501_scan_confirm sig;
 
-       dprintk(3, "entry");
+       pr_debug("entry");
        wl3501_get_from_wla(this, addr, &sig, sizeof(sig));
        if (sig.status == WL3501_STATUS_SUCCESS) {
-               dprintk(3, "success");
+               pr_debug("success");
                if ((this->net_type == IW_MODE_INFRA &&
                     (sig.cap_info & WL3501_MGMT_CAPABILITY_ESS)) ||
                    (this->net_type == IW_MODE_ADHOC &&
@@ -728,7 +706,7 @@ static void wl3501_mgmt_scan_confirm(struct wl3501_card *this, u16 addr)
                        }
                }
        } else if (sig.status == WL3501_STATUS_TIMEOUT) {
-               dprintk(3, "timeout");
+               pr_debug("timeout");
                this->join_sta_bss = 0;
                for (i = this->join_sta_bss; i < this->bss_cnt; i++)
                        if (!wl3501_mgmt_join(this, i))
@@ -860,12 +838,10 @@ static int wl3501_esbq_confirm(struct wl3501_card *this)
 
 static void wl3501_online(struct net_device *dev)
 {
-       struct wl3501_card *this = dev->priv;
+       struct wl3501_card *this = netdev_priv(dev);
 
-       printk(KERN_INFO "%s: Wireless LAN online. BSSID: "
-              "%02X %02X %02X %02X %02X %02X\n", dev->name,
-              this->bssid[0], this->bssid[1], this->bssid[2],
-              this->bssid[3], this->bssid[4], this->bssid[5]);
+       printk(KERN_INFO "%s: Wireless LAN online. BSSID: %pM\n",
+              dev->name, this->bssid);
        netif_wake_queue(dev);
 }
 
@@ -887,7 +863,7 @@ static int wl3501_mgmt_auth(struct wl3501_card *this)
                .timeout = 1000,
        };
 
-       dprintk(3, "entry");
+       pr_debug("entry");
        memcpy(sig.mac_addr, this->bssid, ETH_ALEN);
        return wl3501_esbq_exec(this, &sig, sizeof(sig));
 }
@@ -901,17 +877,17 @@ static int wl3501_mgmt_association(struct wl3501_card *this)
                .cap_info        = this->cap_info,
        };
 
-       dprintk(3, "entry");
+       pr_debug("entry");
        memcpy(sig.mac_addr, this->bssid, ETH_ALEN);
        return wl3501_esbq_exec(this, &sig, sizeof(sig));
 }
 
 static void wl3501_mgmt_join_confirm(struct net_device *dev, u16 addr)
 {
-       struct wl3501_card *this = dev->priv;
+       struct wl3501_card *this = netdev_priv(dev);
        struct wl3501_join_confirm sig;
 
-       dprintk(3, "entry");
+       pr_debug("entry");
        wl3501_get_from_wla(this, addr, &sig, sizeof(sig));
        if (sig.status == WL3501_STATUS_SUCCESS) {
                if (this->net_type == IW_MODE_INFRA) {
@@ -970,7 +946,7 @@ static inline void wl3501_md_confirm_interrupt(struct net_device *dev,
 {
        struct wl3501_md_confirm sig;
 
-       dprintk(3, "entry");
+       pr_debug("entry");
        wl3501_get_from_wla(this, addr, &sig, sizeof(sig));
        wl3501_free_tx_buffer(this, sig.data);
        if (netif_queue_stopped(dev))
@@ -1008,17 +984,16 @@ static inline void wl3501_md_ind_interrupt(struct net_device *dev,
        if (!skb) {
                printk(KERN_WARNING "%s: Can't alloc a sk_buff of size %d.\n",
                       dev->name, pkt_len);
-               this->stats.rx_dropped++;
+               dev->stats.rx_dropped++;
        } else {
                skb->dev = dev;
                skb_reserve(skb, 2); /* IP headers on 16 bytes boundaries */
-               eth_copy_and_sum(skb, (unsigned char *)&sig.daddr, 12, 0);
+               skb_copy_to_linear_data(skb, (unsigned char *)&sig.daddr, 12);
                wl3501_receive(this, skb->data, pkt_len);
                skb_put(skb, pkt_len);
                skb->protocol   = eth_type_trans(skb, dev);
-               dev->last_rx    = jiffies;
-               this->stats.rx_packets++;
-               this->stats.rx_bytes += skb->len;
+               dev->stats.rx_packets++;
+               dev->stats.rx_bytes += skb->len;
                netif_rx(skb);
        }
 }
@@ -1026,7 +1001,7 @@ static inline void wl3501_md_ind_interrupt(struct net_device *dev,
 static inline void wl3501_get_confirm_interrupt(struct wl3501_card *this,
                                                u16 addr, void *sig, int size)
 {
-       dprintk(3, "entry");
+       pr_debug("entry");
        wl3501_get_from_wla(this, addr, &this->sig_get_confirm,
                            sizeof(this->sig_get_confirm));
        wake_up(&this->wait);
@@ -1038,7 +1013,7 @@ static inline void wl3501_start_confirm_interrupt(struct net_device *dev,
 {
        struct wl3501_start_confirm sig;
 
-       dprintk(3, "entry");
+       pr_debug("entry");
        wl3501_get_from_wla(this, addr, &sig, sizeof(sig));
        if (sig.status == WL3501_STATUS_SUCCESS)
                netif_wake_queue(dev);
@@ -1047,10 +1022,10 @@ static inline void wl3501_start_confirm_interrupt(struct net_device *dev,
 static inline void wl3501_assoc_confirm_interrupt(struct net_device *dev,
                                                  u16 addr)
 {
-       struct wl3501_card *this = dev->priv;
+       struct wl3501_card *this = netdev_priv(dev);
        struct wl3501_assoc_confirm sig;
 
-       dprintk(3, "entry");
+       pr_debug("entry");
        wl3501_get_from_wla(this, addr, &sig, sizeof(sig));
 
        if (sig.status == WL3501_STATUS_SUCCESS)
@@ -1062,7 +1037,7 @@ static inline void wl3501_auth_confirm_interrupt(struct wl3501_card *this,
 {
        struct wl3501_auth_confirm sig;
 
-       dprintk(3, "entry");
+       pr_debug("entry");
        wl3501_get_from_wla(this, addr, &sig, sizeof(sig));
 
        if (sig.status == WL3501_STATUS_SUCCESS)
@@ -1076,9 +1051,9 @@ static inline void wl3501_rx_interrupt(struct net_device *dev)
        int morepkts;
        u16 addr;
        u8 sig_id;
-       struct wl3501_card *this = dev->priv;
+       struct wl3501_card *this = netdev_priv(dev);
 
-       dprintk(3, "entry");
+       pr_debug("entry");
 loop:
        morepkts = 0;
        if (!wl3501_esbq_confirm(this))
@@ -1145,7 +1120,6 @@ static inline void wl3501_ack_interrupt(struct wl3501_card *this)
  * wl3501_interrupt - Hardware interrupt from card.
  * @irq - Interrupt number
  * @dev_id - net_device
- * @regs - registers
  *
  * We must acknowledge the interrupt as soon as possible, and block the
  * interrupt from the same card immediately to prevent re-entry.
@@ -1154,27 +1128,20 @@ static inline void wl3501_ack_interrupt(struct wl3501_card *this)
  * On the other hand, to prevent SUTRO from malfunctioning, we must
  * unlock the SUTRO as soon as possible.
  */
-static irqreturn_t wl3501_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t wl3501_interrupt(int irq, void *dev_id)
 {
-       struct net_device *dev = (struct net_device *)dev_id;
+       struct net_device *dev = dev_id;
        struct wl3501_card *this;
-       int handled = 1;
 
-       if (!dev)
-               goto unknown;
-       this = dev->priv;
+       this = netdev_priv(dev);
        spin_lock(&this->lock);
        wl3501_ack_interrupt(this);
        wl3501_block_interrupt(this);
        wl3501_rx_interrupt(dev);
        wl3501_unblock_interrupt(this);
        spin_unlock(&this->lock);
-out:
-       return IRQ_RETVAL(handled);
-unknown:
-       handled = 0;
-       printk(KERN_ERR "%s: irq %d for unknown device.\n", __FUNCTION__, irq);
-       goto out;
+
+       return IRQ_HANDLED;
 }
 
 static int wl3501_reset_board(struct wl3501_card *this)
@@ -1209,7 +1176,7 @@ static int wl3501_reset_board(struct wl3501_card *this)
                }
                WL3501_NOPLOOP(10);
        }
-       printk(KERN_WARNING "%s: failed to reset the board!\n", __FUNCTION__);
+       printk(KERN_WARNING "%s: failed to reset the board!\n", __func__);
        rc = -ENODEV;
 out:
        return rc;
@@ -1260,13 +1227,13 @@ static int wl3501_init_firmware(struct wl3501_card *this)
 out:
        return rc;
 fail:
-       printk(KERN_WARNING "%s: failed!\n", __FUNCTION__);
+       printk(KERN_WARNING "%s: failed!\n", __func__);
        goto out;
 }
 
 static int wl3501_close(struct net_device *dev)
 {
-       struct wl3501_card *this = dev->priv;
+       struct wl3501_card *this = netdev_priv(dev);
        int rc = -ENODEV;
        unsigned long flags;
        struct pcmcia_device *link;
@@ -1298,7 +1265,7 @@ static int wl3501_close(struct net_device *dev)
  */
 static int wl3501_reset(struct net_device *dev)
 {
-       struct wl3501_card *this = dev->priv;
+       struct wl3501_card *this = netdev_priv(dev);
        int rc = -ENODEV;
 
        wl3501_block_interrupt(this);
@@ -1319,7 +1286,7 @@ static int wl3501_reset(struct net_device *dev)
        wl3501_ack_interrupt(this);
        wl3501_unblock_interrupt(this);
        wl3501_mgmt_scan(this, 100);
-       dprintk(1, "%s: device reset", dev->name);
+       pr_debug("%s: device reset", dev->name);
        rc = 0;
 out:
        return rc;
@@ -1327,8 +1294,8 @@ out:
 
 static void wl3501_tx_timeout(struct net_device *dev)
 {
-       struct wl3501_card *this = dev->priv;
-       struct net_device_stats *stats = &this->stats;
+       struct wl3501_card *this = netdev_priv(dev);
+       struct net_device_stats *stats = &dev->stats;
        unsigned long flags;
        int rc;
 
@@ -1350,10 +1317,11 @@ static void wl3501_tx_timeout(struct net_device *dev)
  *         1 - Could not transmit (dev_queue_xmit will queue it)
  *             and try to sent it later
  */
-static int wl3501_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t wl3501_hard_start_xmit(struct sk_buff *skb,
+                                               struct net_device *dev)
 {
        int enabled, rc;
-       struct wl3501_card *this = dev->priv;
+       struct wl3501_card *this = netdev_priv(dev);
        unsigned long flags;
 
        spin_lock_irqsave(&this->lock, flags);
@@ -1363,24 +1331,24 @@ static int wl3501_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
        if (enabled)
                wl3501_unblock_interrupt(this);
        if (rc) {
-               ++this->stats.tx_dropped;
+               ++dev->stats.tx_dropped;
                netif_stop_queue(dev);
        } else {
-               ++this->stats.tx_packets;
-               this->stats.tx_bytes += skb->len;
+               ++dev->stats.tx_packets;
+               dev->stats.tx_bytes += skb->len;
                kfree_skb(skb);
 
                if (this->tx_buffer_cnt < 2)
                        netif_stop_queue(dev);
        }
        spin_unlock_irqrestore(&this->lock, flags);
-       return rc;
+       return NETDEV_TX_OK;
 }
 
 static int wl3501_open(struct net_device *dev)
 {
        int rc = -ENODEV;
-       struct wl3501_card *this = dev->priv;
+       struct wl3501_card *this = netdev_priv(dev);
        unsigned long flags;
        struct pcmcia_device *link;
        link = this->p_dev;
@@ -1392,7 +1360,7 @@ static int wl3501_open(struct net_device *dev)
        link->open++;
 
        /* Initial WL3501 firmware */
-       dprintk(1, "%s: Initialize WL3501 firmware...", dev->name);
+       pr_debug("%s: Initialize WL3501 firmware...", dev->name);
        if (wl3501_init_firmware(this))
                goto fail;
        /* Initial device variables */
@@ -1404,7 +1372,7 @@ static int wl3501_open(struct net_device *dev)
        wl3501_unblock_interrupt(this);
        wl3501_mgmt_scan(this, 100);
        rc = 0;
-       dprintk(1, "%s: WL3501 opened", dev->name);
+       pr_debug("%s: WL3501 opened", dev->name);
        printk(KERN_INFO "%s: Card Name: %s\n"
                         "%s: Firmware Date: %s\n",
                         dev->name, this->card_name,
@@ -1417,16 +1385,9 @@ fail:
        goto out;
 }
 
-static struct net_device_stats *wl3501_get_stats(struct net_device *dev)
-{
-       struct wl3501_card *this = dev->priv;
-
-       return &this->stats;
-}
-
 static struct iw_statistics *wl3501_get_wireless_stats(struct net_device *dev)
 {
-       struct wl3501_card *this = dev->priv;
+       struct wl3501_card *this = netdev_priv(dev);
        struct iw_statistics *wstats = &this->wstats;
        u32 value; /* size checked: it is u32 */
 
@@ -1506,7 +1467,7 @@ static int wl3501_get_name(struct net_device *dev, struct iw_request_info *info,
 static int wl3501_set_freq(struct net_device *dev, struct iw_request_info *info,
                           union iwreq_data *wrqu, char *extra)
 {
-       struct wl3501_card *this = dev->priv;
+       struct wl3501_card *this = netdev_priv(dev);
        int channel = wrqu->freq.m;
        int rc = -EINVAL;
 
@@ -1520,9 +1481,9 @@ static int wl3501_set_freq(struct net_device *dev, struct iw_request_info *info,
 static int wl3501_get_freq(struct net_device *dev, struct iw_request_info *info,
                           union iwreq_data *wrqu, char *extra)
 {
-       struct wl3501_card *this = dev->priv;
+       struct wl3501_card *this = netdev_priv(dev);
 
-       wrqu->freq.m = wl3501_chan2freq[this->chan - 1] * 100000;
+       wrqu->freq.m = ieee80211_dsss_chan_to_freq(this->chan) * 100000;
        wrqu->freq.e = 1;
        return 0;
 }
@@ -1535,7 +1496,7 @@ static int wl3501_set_mode(struct net_device *dev, struct iw_request_info *info,
        if (wrqu->mode == IW_MODE_INFRA ||
            wrqu->mode == IW_MODE_ADHOC ||
            wrqu->mode == IW_MODE_AUTO) {
-               struct wl3501_card *this = dev->priv;
+               struct wl3501_card *this = netdev_priv(dev);
 
                this->net_type = wrqu->mode;
                rc = wl3501_reset(dev);
@@ -1546,7 +1507,7 @@ static int wl3501_set_mode(struct net_device *dev, struct iw_request_info *info,
 static int wl3501_get_mode(struct net_device *dev, struct iw_request_info *info,
                           union iwreq_data *wrqu, char *extra)
 {
-       struct wl3501_card *this = dev->priv;
+       struct wl3501_card *this = netdev_priv(dev);
 
        wrqu->mode = this->net_type;
        return 0;
@@ -1555,7 +1516,7 @@ static int wl3501_get_mode(struct net_device *dev, struct iw_request_info *info,
 static int wl3501_get_sens(struct net_device *dev, struct iw_request_info *info,
                           union iwreq_data *wrqu, char *extra)
 {
-       struct wl3501_card *this = dev->priv;
+       struct wl3501_card *this = netdev_priv(dev);
 
        wrqu->sens.value = this->rssi;
        wrqu->sens.disabled = !wrqu->sens.value;
@@ -1586,7 +1547,7 @@ static int wl3501_get_range(struct net_device *dev,
 static int wl3501_set_wap(struct net_device *dev, struct iw_request_info *info,
                          union iwreq_data *wrqu, char *extra)
 {
-       struct wl3501_card *this = dev->priv;
+       struct wl3501_card *this = netdev_priv(dev);
        static const u8 bcast[ETH_ALEN] = { 255, 255, 255, 255, 255, 255 };
        int rc = -EINVAL;
 
@@ -1606,7 +1567,7 @@ out:
 static int wl3501_get_wap(struct net_device *dev, struct iw_request_info *info,
                          union iwreq_data *wrqu, char *extra)
 {
-       struct wl3501_card *this = dev->priv;
+       struct wl3501_card *this = netdev_priv(dev);
 
        wrqu->ap_addr.sa_family = ARPHRD_ETHER;
        memcpy(wrqu->ap_addr.sa_data, this->bssid, ETH_ALEN);
@@ -1625,7 +1586,7 @@ static int wl3501_set_scan(struct net_device *dev, struct iw_request_info *info,
 static int wl3501_get_scan(struct net_device *dev, struct iw_request_info *info,
                           union iwreq_data *wrqu, char *extra)
 {
-       struct wl3501_card *this = dev->priv;
+       struct wl3501_card *this = netdev_priv(dev);
        int i;
        char *current_ev = extra;
        struct iw_event iwe;
@@ -1634,25 +1595,25 @@ static int wl3501_get_scan(struct net_device *dev, struct iw_request_info *info,
                iwe.cmd                 = SIOCGIWAP;
                iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
                memcpy(iwe.u.ap_addr.sa_data, this->bss_set[i].bssid, ETH_ALEN);
-               current_ev = iwe_stream_add_event(current_ev,
+               current_ev = iwe_stream_add_event(info, current_ev,
                                                  extra + IW_SCAN_MAX_DATA,
                                                  &iwe, IW_EV_ADDR_LEN);
                iwe.cmd           = SIOCGIWESSID;
                iwe.u.data.flags  = 1;
                iwe.u.data.length = this->bss_set[i].ssid.el.len;
-               current_ev = iwe_stream_add_point(current_ev,
+               current_ev = iwe_stream_add_point(info, current_ev,
                                                  extra + IW_SCAN_MAX_DATA,
                                                  &iwe,
                                                  this->bss_set[i].ssid.essid);
                iwe.cmd    = SIOCGIWMODE;
                iwe.u.mode = this->bss_set[i].bss_type;
-               current_ev = iwe_stream_add_event(current_ev,
+               current_ev = iwe_stream_add_event(info, current_ev,
                                                  extra + IW_SCAN_MAX_DATA,
                                                  &iwe, IW_EV_UINT_LEN);
                iwe.cmd = SIOCGIWFREQ;
                iwe.u.freq.m = this->bss_set[i].ds_pset.chan;
                iwe.u.freq.e = 0;
-               current_ev = iwe_stream_add_event(current_ev,
+               current_ev = iwe_stream_add_event(info, current_ev,
                                                  extra + IW_SCAN_MAX_DATA,
                                                  &iwe, IW_EV_FREQ_LEN);
                iwe.cmd = SIOCGIWENCODE;
@@ -1661,7 +1622,7 @@ static int wl3501_get_scan(struct net_device *dev, struct iw_request_info *info,
                else
                        iwe.u.data.flags = IW_ENCODE_DISABLED;
                iwe.u.data.length = 0;
-               current_ev = iwe_stream_add_point(current_ev,
+               current_ev = iwe_stream_add_point(info, current_ev,
                                                  extra + IW_SCAN_MAX_DATA,
                                                  &iwe, NULL);
        }
@@ -1675,7 +1636,7 @@ static int wl3501_set_essid(struct net_device *dev,
                            struct iw_request_info *info,
                            union iwreq_data *wrqu, char *extra)
 {
-       struct wl3501_card *this = dev->priv;
+       struct wl3501_card *this = netdev_priv(dev);
 
        if (wrqu->data.flags) {
                iw_set_mgmt_info_element(IW_MGMT_INFO_ELEMENT_SSID,
@@ -1692,7 +1653,7 @@ static int wl3501_get_essid(struct net_device *dev,
                            struct iw_request_info *info,
                            union iwreq_data *wrqu, char *extra)
 {
-       struct wl3501_card *this = dev->priv;
+       struct wl3501_card *this = netdev_priv(dev);
        unsigned long flags;
 
        spin_lock_irqsave(&this->lock, flags);
@@ -1706,7 +1667,7 @@ static int wl3501_get_essid(struct net_device *dev,
 static int wl3501_set_nick(struct net_device *dev, struct iw_request_info *info,
                           union iwreq_data *wrqu, char *extra)
 {
-       struct wl3501_card *this = dev->priv;
+       struct wl3501_card *this = netdev_priv(dev);
 
        if (wrqu->data.length > sizeof(this->nick))
                return -E2BIG;
@@ -1717,7 +1678,7 @@ static int wl3501_set_nick(struct net_device *dev, struct iw_request_info *info,
 static int wl3501_get_nick(struct net_device *dev, struct iw_request_info *info,
                           union iwreq_data *wrqu, char *extra)
 {
-       struct wl3501_card *this = dev->priv;
+       struct wl3501_card *this = netdev_priv(dev);
 
        strlcpy(extra, this->nick, 32);
        wrqu->data.length = strlen(extra);
@@ -1742,7 +1703,7 @@ static int wl3501_get_rts_threshold(struct net_device *dev,
                                    union iwreq_data *wrqu, char *extra)
 {
        u16 threshold; /* size checked: it is u16 */
-       struct wl3501_card *this = dev->priv;
+       struct wl3501_card *this = netdev_priv(dev);
        int rc = wl3501_get_mib_value(this, WL3501_MIB_ATTR_RTS_THRESHOLD,
                                      &threshold, sizeof(threshold));
        if (!rc) {
@@ -1758,7 +1719,7 @@ static int wl3501_get_frag_threshold(struct net_device *dev,
                                     union iwreq_data *wrqu, char *extra)
 {
        u16 threshold; /* size checked: it is u16 */
-       struct wl3501_card *this = dev->priv;
+       struct wl3501_card *this = netdev_priv(dev);
        int rc = wl3501_get_mib_value(this, WL3501_MIB_ATTR_FRAG_THRESHOLD,
                                      &threshold, sizeof(threshold));
        if (!rc) {
@@ -1774,7 +1735,7 @@ static int wl3501_get_txpow(struct net_device *dev,
                            union iwreq_data *wrqu, char *extra)
 {
        u16 txpow;
-       struct wl3501_card *this = dev->priv;
+       struct wl3501_card *this = netdev_priv(dev);
        int rc = wl3501_get_mib_value(this,
                                      WL3501_MIB_ATTR_CURRENT_TX_PWR_LEVEL,
                                      &txpow, sizeof(txpow));
@@ -1796,7 +1757,7 @@ static int wl3501_get_retry(struct net_device *dev,
                            union iwreq_data *wrqu, char *extra)
 {
        u8 retry; /* size checked: it is u8 */
-       struct wl3501_card *this = dev->priv;
+       struct wl3501_card *this = netdev_priv(dev);
        int rc = wl3501_get_mib_value(this,
                                      WL3501_MIB_ATTR_LONG_RETRY_LIMIT,
                                      &retry, sizeof(retry));
@@ -1823,7 +1784,7 @@ static int wl3501_get_encode(struct net_device *dev,
                             union iwreq_data *wrqu, char *extra)
 {
        u8 implemented, restricted, keys[100], len_keys, tocopy;
-       struct wl3501_card *this = dev->priv;
+       struct wl3501_card *this = netdev_priv(dev);
        int rc = wl3501_get_mib_value(this,
                                      WL3501_MIB_ATTR_PRIV_OPT_IMPLEMENTED,
                                      &implemented, sizeof(implemented));
@@ -1850,7 +1811,6 @@ static int wl3501_get_encode(struct net_device *dev,
        tocopy = min_t(u8, len_keys, wrqu->encoding.length);
        tocopy = min_t(u8, tocopy, 100);
        wrqu->encoding.length = tocopy;
-       memset(extra, 0, tocopy);
        memcpy(extra, keys, tocopy);
 out:
        return rc;
@@ -1861,7 +1821,7 @@ static int wl3501_get_power(struct net_device *dev,
                            union iwreq_data *wrqu, char *extra)
 {
        u8 pwr_state;
-       struct wl3501_card *this = dev->priv;
+       struct wl3501_card *this = netdev_priv(dev);
        int rc = wl3501_get_mib_value(this,
                                      WL3501_MIB_ATTR_CURRENT_PWR_STATE,
                                      &pwr_state, sizeof(pwr_state));
@@ -1874,40 +1834,50 @@ out:
 }
 
 static const iw_handler        wl3501_handler[] = {
-       [SIOCGIWNAME    - SIOCIWFIRST] = wl3501_get_name,
-       [SIOCSIWFREQ    - SIOCIWFIRST] = wl3501_set_freq,
-       [SIOCGIWFREQ    - SIOCIWFIRST] = wl3501_get_freq,
-       [SIOCSIWMODE    - SIOCIWFIRST] = wl3501_set_mode,
-       [SIOCGIWMODE    - SIOCIWFIRST] = wl3501_get_mode,
-       [SIOCGIWSENS    - SIOCIWFIRST] = wl3501_get_sens,
-       [SIOCGIWRANGE   - SIOCIWFIRST] = wl3501_get_range,
-       [SIOCSIWSPY     - SIOCIWFIRST] = iw_handler_set_spy,
-       [SIOCGIWSPY     - SIOCIWFIRST] = iw_handler_get_spy,
-       [SIOCSIWTHRSPY  - SIOCIWFIRST] = iw_handler_set_thrspy,
-       [SIOCGIWTHRSPY  - SIOCIWFIRST] = iw_handler_get_thrspy,
-       [SIOCSIWAP      - SIOCIWFIRST] = wl3501_set_wap,
-       [SIOCGIWAP      - SIOCIWFIRST] = wl3501_get_wap,
-       [SIOCSIWSCAN    - SIOCIWFIRST] = wl3501_set_scan,
-       [SIOCGIWSCAN    - SIOCIWFIRST] = wl3501_get_scan,
-       [SIOCSIWESSID   - SIOCIWFIRST] = wl3501_set_essid,
-       [SIOCGIWESSID   - SIOCIWFIRST] = wl3501_get_essid,
-       [SIOCSIWNICKN   - SIOCIWFIRST] = wl3501_set_nick,
-       [SIOCGIWNICKN   - SIOCIWFIRST] = wl3501_get_nick,
-       [SIOCGIWRATE    - SIOCIWFIRST] = wl3501_get_rate,
-       [SIOCGIWRTS     - SIOCIWFIRST] = wl3501_get_rts_threshold,
-       [SIOCGIWFRAG    - SIOCIWFIRST] = wl3501_get_frag_threshold,
-       [SIOCGIWTXPOW   - SIOCIWFIRST] = wl3501_get_txpow,
-       [SIOCGIWRETRY   - SIOCIWFIRST] = wl3501_get_retry,
-       [SIOCGIWENCODE  - SIOCIWFIRST] = wl3501_get_encode,
-       [SIOCGIWPOWER   - SIOCIWFIRST] = wl3501_get_power,
+       IW_HANDLER(SIOCGIWNAME, wl3501_get_name),
+       IW_HANDLER(SIOCSIWFREQ, wl3501_set_freq),
+       IW_HANDLER(SIOCGIWFREQ, wl3501_get_freq),
+       IW_HANDLER(SIOCSIWMODE, wl3501_set_mode),
+       IW_HANDLER(SIOCGIWMODE, wl3501_get_mode),
+       IW_HANDLER(SIOCGIWSENS, wl3501_get_sens),
+       IW_HANDLER(SIOCGIWRANGE, wl3501_get_range),
+       IW_HANDLER(SIOCSIWSPY, iw_handler_set_spy),
+       IW_HANDLER(SIOCGIWSPY, iw_handler_get_spy),
+       IW_HANDLER(SIOCSIWTHRSPY, iw_handler_set_thrspy),
+       IW_HANDLER(SIOCGIWTHRSPY, iw_handler_get_thrspy),
+       IW_HANDLER(SIOCSIWAP, wl3501_set_wap),
+       IW_HANDLER(SIOCGIWAP, wl3501_get_wap),
+       IW_HANDLER(SIOCSIWSCAN, wl3501_set_scan),
+       IW_HANDLER(SIOCGIWSCAN, wl3501_get_scan),
+       IW_HANDLER(SIOCSIWESSID, wl3501_set_essid),
+       IW_HANDLER(SIOCGIWESSID, wl3501_get_essid),
+       IW_HANDLER(SIOCSIWNICKN, wl3501_set_nick),
+       IW_HANDLER(SIOCGIWNICKN, wl3501_get_nick),
+       IW_HANDLER(SIOCGIWRATE, wl3501_get_rate),
+       IW_HANDLER(SIOCGIWRTS, wl3501_get_rts_threshold),
+       IW_HANDLER(SIOCGIWFRAG, wl3501_get_frag_threshold),
+       IW_HANDLER(SIOCGIWTXPOW, wl3501_get_txpow),
+       IW_HANDLER(SIOCGIWRETRY, wl3501_get_retry),
+       IW_HANDLER(SIOCGIWENCODE, wl3501_get_encode),
+       IW_HANDLER(SIOCGIWPOWER, wl3501_get_power),
 };
 
 static const struct iw_handler_def wl3501_handler_def = {
-       .num_standard   = sizeof(wl3501_handler) / sizeof(iw_handler),
+       .num_standard   = ARRAY_SIZE(wl3501_handler),
        .standard       = (iw_handler *)wl3501_handler,
        .get_wireless_stats = wl3501_get_wireless_stats,
 };
 
+static const struct net_device_ops wl3501_netdev_ops = {
+       .ndo_open               = wl3501_open,
+       .ndo_stop               = wl3501_close,
+       .ndo_start_xmit         = wl3501_hard_start_xmit,
+       .ndo_tx_timeout         = wl3501_tx_timeout,
+       .ndo_change_mtu         = eth_change_mtu,
+       .ndo_set_mac_address    = eth_mac_addr,
+       .ndo_validate_addr      = eth_validate_addr,
+};
+
 /**
  * wl3501_attach - creates an "instance" of the driver
  *
@@ -1928,42 +1898,36 @@ static int wl3501_probe(struct pcmcia_device *p_dev)
        p_dev->io.IOAddrLines   = 5;
 
        /* Interrupt setup */
-       p_dev->irq.Attributes   = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
-       p_dev->irq.IRQInfo1     = IRQ_LEVEL_ID;
+       p_dev->irq.Attributes   = IRQ_TYPE_DYNAMIC_SHARING;
        p_dev->irq.Handler = wl3501_interrupt;
 
        /* General socket configuration */
        p_dev->conf.Attributes  = CONF_ENABLE_IRQ;
        p_dev->conf.IntType     = INT_MEMORY_AND_IO;
        p_dev->conf.ConfigIndex = 1;
-       p_dev->conf.Present     = PRESENT_OPTION;
 
        dev = alloc_etherdev(sizeof(struct wl3501_card));
        if (!dev)
                goto out_link;
-       dev->open               = wl3501_open;
-       dev->stop               = wl3501_close;
-       dev->hard_start_xmit    = wl3501_hard_start_xmit;
-       dev->tx_timeout         = wl3501_tx_timeout;
+
+
+       dev->netdev_ops         = &wl3501_netdev_ops;
        dev->watchdog_timeo     = 5 * HZ;
-       dev->get_stats          = wl3501_get_stats;
-       this = dev->priv;
+
+       this = netdev_priv(dev);
        this->wireless_data.spy_data = &this->spy_data;
        this->p_dev = p_dev;
        dev->wireless_data      = &this->wireless_data;
-       dev->wireless_handlers  = (struct iw_handler_def *)&wl3501_handler_def;
+       dev->wireless_handlers  = &wl3501_handler_def;
        SET_ETHTOOL_OPS(dev, &ops);
        netif_stop_queue(dev);
-       p_dev->priv = p_dev->irq.Instance = dev;
+       p_dev->priv = dev;
 
        return wl3501_config(p_dev);
 out_link:
        return -ENOMEM;
 }
 
-#define CS_CHECK(fn, ret) \
-do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
-
 /**
  * wl3501_config - configure the PCMCIA socket and make eth device available
  * @link - FILL_IN
@@ -1974,25 +1938,10 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
  */
 static int wl3501_config(struct pcmcia_device *link)
 {
-       tuple_t tuple;
-       cisparse_t parse;
        struct net_device *dev = link->priv;
-       int i = 0, j, last_fn, last_ret;
-       unsigned char bf[64];
+       int i = 0, j, ret;
        struct wl3501_card *this;
 
-       /* This reads the card's CONFIG tuple to find its config registers. */
-       tuple.Attributes        = 0;
-       tuple.DesiredTuple      = CISTPL_CONFIG;
-       CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
-       tuple.TupleData         = bf;
-       tuple.TupleDataMax      = sizeof(bf);
-       tuple.TupleOffset       = 0;
-       CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
-       CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
-       link->conf.ConfigBase   = parse.config.base;
-       link->conf.Present      = parse.config.rmask[0];
-
        /* Try allocating IO ports.  This tries a few fixed addresses.  If you
         * want, you can also read the card's config table to pick addresses --
         * see the serial driver for an example. */
@@ -2003,35 +1952,35 @@ static int wl3501_config(struct pcmcia_device *link)
                link->io.BasePort1 = j;
                link->io.BasePort2 = link->io.BasePort1 + 0x10;
                i = pcmcia_request_io(link, &link->io);
-               if (i == CS_SUCCESS)
+               if (i == 0)
                        break;
        }
-       if (i != CS_SUCCESS) {
-               cs_error(link, RequestIO, i);
+       if (i != 0)
                goto failed;
-       }
 
        /* Now allocate an interrupt line. Note that this does not actually
         * assign a handler to the interrupt. */
 
-       CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
+       ret = pcmcia_request_irq(link, &link->irq);
+       if (ret)
+               goto failed;
 
        /* This actually configures the PCMCIA socket -- setting up the I/O
         * windows and the interrupt mapping.  */
 
-       CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
+       ret = pcmcia_request_configuration(link, &link->conf);
+       if (ret)
+               goto failed;
 
        dev->irq = link->irq.AssignedIRQ;
        dev->base_addr = link->io.BasePort1;
-       SET_NETDEV_DEV(dev, &handle_to_dev(link));
+       SET_NETDEV_DEV(dev, &link->dev);
        if (register_netdev(dev)) {
                printk(KERN_NOTICE "wl3501_cs: register_netdev() failed\n");
                goto failed;
        }
 
-       SET_MODULE_OWNER(dev);
-
-       this = dev->priv;
+       this = netdev_priv(dev);
        /*
         * At this point, the dev_node_t structure(s) should be initialized and
         * arranged in a linked list at link->dev_node.
@@ -2047,14 +1996,14 @@ static int wl3501_config(struct pcmcia_device *link)
        }
        strcpy(this->node.dev_name, dev->name);
 
-       /* print probe information */
-       printk(KERN_INFO "%s: wl3501 @ 0x%3.3x, IRQ %d, MAC addr in flash ROM:",
-              dev->name, this->base_addr, (int)dev->irq);
-       for (i = 0; i < 6; i++) {
+       for (i = 0; i < 6; i++)
                dev->dev_addr[i] = ((char *)&this->mac_addr)[i];
-               printk("%c%02x", i ? ':' : ' ', dev->dev_addr[i]);
-       }
-       printk("\n");
+
+       /* print probe information */
+       printk(KERN_INFO "%s: wl3501 @ 0x%3.3x, IRQ %d, "
+              "MAC addr in flash ROM:%pM\n",
+              dev->name, this->base_addr, (int)dev->irq,
+              dev->dev_addr);
        /*
         * Initialize card parameters - added by jss
         */
@@ -2074,8 +2023,6 @@ static int wl3501_config(struct pcmcia_device *link)
        netif_start_queue(dev);
        return 0;
 
-cs_failed:
-       cs_error(link, last_fn, last_ret);
 failed:
        wl3501_release(link);
        return -ENODEV;
@@ -2104,7 +2051,7 @@ static int wl3501_suspend(struct pcmcia_device *link)
 {
        struct net_device *dev = link->priv;
 
-       wl3501_pwr_mgmt(dev->priv, WL3501_SUSPEND);
+       wl3501_pwr_mgmt(netdev_priv(dev), WL3501_SUSPEND);
        if (link->open)
                netif_device_detach(dev);
 
@@ -2115,7 +2062,7 @@ static int wl3501_resume(struct pcmcia_device *link)
 {
        struct net_device *dev = link->priv;
 
-       wl3501_pwr_mgmt(dev->priv, WL3501_RESUME);
+       wl3501_pwr_mgmt(netdev_priv(dev), WL3501_RESUME);
        if (link->open) {
                wl3501_reset(dev);
                netif_device_attach(dev);