Merge git://git.kernel.org/pub/scm/linux/kernel/git/brodo/pcmcia-2.6
[safe/jmp/linux-2.6] / drivers / net / wireless / wl3501_cs.c
index 0c81b3e..68789c6 100644 (file)
@@ -26,9 +26,7 @@
  * 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/config.h>
 #include <linux/delay.h>
 #include <linux/types.h>
 #include <linux/ethtool.h>
@@ -81,7 +79,7 @@ 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); }
+               printk(KERN_INFO "%s: " format "\n", __func__ , ##args); }
 #else
 #define dprintk(n, format, args...)
 #endif
@@ -103,8 +101,8 @@ module_param(pc_debug, int, 0);
  * release a socket, in response to card insertion and ejection events.  They
  * are invoked from the wl24 event handler.
  */
-static void wl3501_config(dev_link_t *link);
-static void wl3501_release(dev_link_t *link);
+static int wl3501_config(struct pcmcia_device *link);
+static void wl3501_release(struct pcmcia_device *link);
 
 /*
  * The dev_info variable is the "key" that is used to match up this
@@ -226,17 +224,6 @@ static void iw_copy_mgmt_info_element(struct iw_mgmt_info_element *to,
        iw_set_mgmt_info_element(from->id, to, from->data, from->len);
 }
 
-/*
- * A linked list of "instances" of the wl24 device.  Each actual PCMCIA card
- * corresponds to one device instance, and is described by one dev_link_t
- * structure (defined in ds.h).
- *
- * You may not want to use a linked list for this -- for example, the memory
- * card driver uses an array of dev_link_t pointers, where minor device numbers
- * are used to derive the corresponding array index.
- */
-static dev_link_t *wl3501_dev_list;
-
 static inline void wl3501_switch_page(struct wl3501_card *this, u8 page)
 {
        wl3501_outb(page, this->base_addr + WL3501_NIC_BSS);
@@ -483,7 +470,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;
@@ -872,12 +859,11 @@ 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);
+       DECLARE_MAC_BUF(mac);
 
-       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: %s\n",
+              dev->name, print_mac(mac, this->bssid));
        netif_wake_queue(dev);
 }
 
@@ -920,7 +906,7 @@ static int wl3501_mgmt_association(struct wl3501_card *this)
 
 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");
@@ -1024,7 +1010,7 @@ static inline void wl3501_md_ind_interrupt(struct net_device *dev,
        } 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);
@@ -1059,7 +1045,7 @@ 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");
@@ -1088,7 +1074,7 @@ 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");
 loop:
@@ -1157,7 +1143,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.
@@ -1166,27 +1151,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)
@@ -1221,7 +1199,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;
@@ -1272,24 +1250,19 @@ 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;
-       dev_link_t *link;
+       struct pcmcia_device *link;
+       link = this->p_dev;
 
        spin_lock_irqsave(&this->lock, flags);
-       /* Check if the device is in wl3501_dev_list */
-       for (link = wl3501_dev_list; link; link = link->next)
-               if (link->priv == dev)
-                       break;
-       if (!link)
-               goto out;
        link->open--;
 
        /* Stop wl3501_hard_start_xmit() from now on */
@@ -1301,7 +1274,6 @@ static int wl3501_close(struct net_device *dev)
 
        rc = 0;
        printk(KERN_INFO "%s: WL3501 closed\n", dev->name);
-out:
        spin_unlock_irqrestore(&this->lock, flags);
        return rc;
 }
@@ -1316,7 +1288,7 @@ out:
  */
 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);
@@ -1345,7 +1317,7 @@ out:
 
 static void wl3501_tx_timeout(struct net_device *dev)
 {
-       struct wl3501_card *this = dev->priv;
+       struct wl3501_card *this = netdev_priv(dev);
        struct net_device_stats *stats = &this->stats;
        unsigned long flags;
        int rc;
@@ -1371,7 +1343,7 @@ static void wl3501_tx_timeout(struct net_device *dev)
 static int 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);
@@ -1398,16 +1370,13 @@ static int wl3501_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
 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;
-       dev_link_t *link;
+       struct pcmcia_device *link;
+       link = this->p_dev;
 
        spin_lock_irqsave(&this->lock, flags);
-       /* Check if the device is in wl3501_dev_list */
-       for (link = wl3501_dev_list; link; link = link->next)
-               if (link->priv == dev)
-                       break;
-       if (!DEV_OK(link))
+       if (!pcmcia_dev_present(link))
                goto out;
        netif_device_attach(dev);
        link->open++;
@@ -1440,14 +1409,14 @@ fail:
 
 static struct net_device_stats *wl3501_get_stats(struct net_device *dev)
 {
-       struct wl3501_card *this = dev->priv;
+       struct wl3501_card *this = netdev_priv(dev);
 
        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 */
 
@@ -1485,7 +1454,7 @@ static void wl3501_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *i
        strlcpy(info->driver, wl3501_dev_info, sizeof(info->driver));
 }
 
-static struct ethtool_ops ops = {
+static const struct ethtool_ops ops = {
        .get_drvinfo = wl3501_get_drvinfo
 };
 
@@ -1497,38 +1466,23 @@ static struct ethtool_ops ops = {
  * Services. If it has been released, all local data structures are freed.
  * Otherwise, the structures will be freed when the device is released.
  */
-static void wl3501_detach(struct pcmcia_device *p_dev)
+static void wl3501_detach(struct pcmcia_device *link)
 {
-       dev_link_t *link = dev_to_instance(p_dev);
-       dev_link_t **linkp;
        struct net_device *dev = link->priv;
 
-       /* Locate device structure */
-       for (linkp = &wl3501_dev_list; *linkp; linkp = &(*linkp)->next)
-               if (*linkp == link)
-                       break;
-       if (!*linkp)
-               goto out;
-
        /* If the device is currently configured and active, we won't actually
         * delete it yet.  Instead, it is marked so that when the release()
         * function is called, that will trigger a proper detach(). */
 
-       if (link->state & DEV_CONFIG) {
-               while (link->open > 0)
-                       wl3501_close(dev);
+       while (link->open > 0)
+               wl3501_close(dev);
 
-               netif_device_detach(dev);
-               wl3501_release(link);
-       }
-
-       /* Unlink device structure, free pieces */
-       *linkp = link->next;
+       netif_device_detach(dev);
+       wl3501_release(link);
 
        if (link->priv)
                free_netdev(link->priv);
-       kfree(link);
-out:
+
        return;
 }
 
@@ -1542,7 +1496,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;
 
@@ -1556,7 +1510,7 @@ 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.e = 1;
@@ -1571,7 +1525,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);
@@ -1582,7 +1536,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;
@@ -1591,7 +1545,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;
@@ -1622,7 +1576,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;
 
@@ -1642,7 +1596,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);
@@ -1661,7 +1615,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;
@@ -1670,25 +1624,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;
@@ -1697,7 +1651,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);
        }
@@ -1711,7 +1665,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,
@@ -1728,7 +1682,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);
@@ -1742,7 +1696,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;
@@ -1753,7 +1707,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);
@@ -1778,7 +1732,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) {
@@ -1794,7 +1748,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) {
@@ -1810,7 +1764,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));
@@ -1832,21 +1786,21 @@ 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));
        if (rc)
                goto out;
-       if (wrqu->retry.flags & IW_RETRY_MAX) {
-               wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
+       if (wrqu->retry.flags & IW_RETRY_LONG) {
+               wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
                goto set_value;
        }
        rc = wl3501_get_mib_value(this, WL3501_MIB_ATTR_SHORT_RETRY_LIMIT,
                                  &retry, sizeof(retry));
        if (rc)
                goto out;
-       wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MIN;
+       wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
 set_value:
        wrqu->retry.value = retry;
        wrqu->retry.disabled = 0;
@@ -1859,7 +1813,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));
@@ -1886,7 +1840,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;
@@ -1897,7 +1850,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));
@@ -1939,7 +1892,7 @@ static const iw_handler   wl3501_handler[] = {
 };
 
 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,
 };
@@ -1953,33 +1906,25 @@ static const struct iw_handler_def wl3501_handler_def = {
  * The dev_link structure is initialized, but we don't actually configure the
  * card at this point -- we wait until we receive a card insertion event.
  */
-static int wl3501_attach(struct pcmcia_device *p_dev)
+static int wl3501_probe(struct pcmcia_device *p_dev)
 {
-       dev_link_t *link;
        struct net_device *dev;
        struct wl3501_card *this;
 
-       /* Initialize the dev_link_t structure */
-       link = kzalloc(sizeof(*link), GFP_KERNEL);
-       if (!link)
-               return -ENOMEM;
-
        /* The io structure describes IO port mapping */
-       link->io.NumPorts1      = 16;
-       link->io.Attributes1    = IO_DATA_PATH_WIDTH_8;
-       link->io.IOAddrLines    = 5;
+       p_dev->io.NumPorts1     = 16;
+       p_dev->io.Attributes1   = IO_DATA_PATH_WIDTH_8;
+       p_dev->io.IOAddrLines   = 5;
 
        /* Interrupt setup */
-       link->irq.Attributes    = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
-       link->irq.IRQInfo1      = IRQ_LEVEL_ID;
-       link->irq.Handler = wl3501_interrupt;
+       p_dev->irq.Attributes   = IRQ_TYPE_DYNAMIC_SHARING | IRQ_HANDLE_PRESENT;
+       p_dev->irq.IRQInfo1     = IRQ_LEVEL_ID;
+       p_dev->irq.Handler = wl3501_interrupt;
 
        /* General socket configuration */
-       link->conf.Attributes   = CONF_ENABLE_IRQ;
-       link->conf.Vcc          = 50;
-       link->conf.IntType      = INT_MEMORY_AND_IO;
-       link->conf.ConfigIndex  = 1;
-       link->conf.Present      = PRESENT_OPTION;
+       p_dev->conf.Attributes  = CONF_ENABLE_IRQ;
+       p_dev->conf.IntType     = INT_MEMORY_AND_IO;
+       p_dev->conf.ConfigIndex = 1;
 
        dev = alloc_etherdev(sizeof(struct wl3501_card));
        if (!dev)
@@ -1990,24 +1935,17 @@ static int wl3501_attach(struct pcmcia_device *p_dev)
        dev->tx_timeout         = wl3501_tx_timeout;
        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;
        SET_ETHTOOL_OPS(dev, &ops);
        netif_stop_queue(dev);
-       link->priv = link->irq.Instance = dev;
-
-       link->handle = p_dev;
-       p_dev->instance = link;
+       p_dev->priv = p_dev->irq.Instance = dev;
 
-       link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
-       wl3501_config(link);
-
-       return 0;
+       return wl3501_config(p_dev);
 out_link:
-       kfree(link);
-       link = NULL;
        return -ENOMEM;
 }
 
@@ -2022,30 +1960,12 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
  * received, to configure the PCMCIA socket, and to make the ethernet device
  * available to the system.
  */
-static void wl3501_config(dev_link_t *link)
+static int wl3501_config(struct pcmcia_device *link)
 {
-       tuple_t tuple;
-       cisparse_t parse;
-       client_handle_t handle = link->handle;
        struct net_device *dev = link->priv;
        int i = 0, j, last_fn, last_ret;
-       unsigned char bf[64];
        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(handle, &tuple));
-       tuple.TupleData         = bf;
-       tuple.TupleDataMax      = sizeof(bf);
-       tuple.TupleOffset       = 0;
-       CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
-       CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
-       link->conf.ConfigBase   = parse.config.base;
-       link->conf.Present      = parse.config.rmask[0];
-
-       /* Configure card */
-       link->state |= DEV_CONFIG;
+       DECLARE_MAC_BUF(mac);
 
        /* 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 --
@@ -2056,42 +1976,39 @@ static void wl3501_config(dev_link_t *link)
                 * 0x200-0x2ff, and so on, because this seems safer */
                link->io.BasePort1 = j;
                link->io.BasePort2 = link->io.BasePort1 + 0x10;
-               i = pcmcia_request_io(link->handle, &link->io);
-               if (i == CS_SUCCESS)
+               i = pcmcia_request_io(link, &link->io);
+               if (i == 0)
                        break;
        }
-       if (i != CS_SUCCESS) {
-               cs_error(link->handle, RequestIO, i);
+       if (i != 0) {
+               cs_error(link, RequestIO, i);
                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->handle, &link->irq));
+       CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
 
        /* This actually configures the PCMCIA socket -- setting up the I/O
         * windows and the interrupt mapping.  */
 
-       CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf));
+       CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
 
        dev->irq = link->irq.AssignedIRQ;
        dev->base_addr = link->io.BasePort1;
-       SET_NETDEV_DEV(dev, &handle_to_dev(handle));
+       SET_NETDEV_DEV(dev, &handle_to_dev(link));
        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.
+        * arranged in a linked list at link->dev_node.
         */
-       link->dev = &this->node;
-       link->state &= ~DEV_CONFIG_PENDING;
+       link->dev_node = &this->node;
 
        this->base_addr = dev->base_addr;
 
@@ -2102,14 +2019,14 @@ static void wl3501_config(dev_link_t *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:%s\n",
+              dev->name, this->base_addr, (int)dev->irq,
+              print_mac(mac, dev->dev_addr));
        /*
         * Initialize card parameters - added by jss
         */
@@ -2127,13 +2044,13 @@ static void wl3501_config(dev_link_t *link)
        spin_lock_init(&this->lock);
        init_waitqueue_head(&this->wait);
        netif_start_queue(dev);
-       goto out;
+       return 0;
+
 cs_failed:
-       cs_error(link->handle, last_fn, last_ret);
+       cs_error(link, last_fn, last_ret);
 failed:
        wl3501_release(link);
-out:
-       return;
+       return -ENODEV;
 }
 
 /**
@@ -2144,46 +2061,36 @@ out:
  * and release the PCMCIA configuration.  If the device is still open, this
  * will be postponed until it is closed.
  */
-static void wl3501_release(dev_link_t *link)
+static void wl3501_release(struct pcmcia_device *link)
 {
        struct net_device *dev = link->priv;
 
        /* Unlink the device chain */
-       if (link->dev)
+       if (link->dev_node)
                unregister_netdev(dev);
 
-       pcmcia_disable_device(link->handle);
+       pcmcia_disable_device(link);
 }
 
-static int wl3501_suspend(struct pcmcia_device *p_dev)
+static int wl3501_suspend(struct pcmcia_device *link)
 {
-       dev_link_t *link = dev_to_instance(p_dev);
        struct net_device *dev = link->priv;
 
-       link->state |= DEV_SUSPEND;
-
-       wl3501_pwr_mgmt(dev->priv, WL3501_SUSPEND);
-       if (link->state & DEV_CONFIG) {
-               if (link->open)
-                       netif_device_detach(dev);
-               pcmcia_release_configuration(link->handle);
-       }
+       wl3501_pwr_mgmt(netdev_priv(dev), WL3501_SUSPEND);
+       if (link->open)
+               netif_device_detach(dev);
 
        return 0;
 }
 
-static int wl3501_resume(struct pcmcia_device *p_dev)
+static int wl3501_resume(struct pcmcia_device *link)
 {
-       dev_link_t *link = dev_to_instance(p_dev);
        struct net_device *dev = link->priv;
 
-       wl3501_pwr_mgmt(dev->priv, WL3501_RESUME);
-       if (link->state & DEV_CONFIG) {
-               pcmcia_request_configuration(link->handle, &link->conf);
-               if (link->open) {
-                       wl3501_reset(dev);
-                       netif_device_attach(dev);
-               }
+       wl3501_pwr_mgmt(netdev_priv(dev), WL3501_RESUME);
+       if (link->open) {
+               wl3501_reset(dev);
+               netif_device_attach(dev);
        }
 
        return 0;
@@ -2201,7 +2108,7 @@ static struct pcmcia_driver wl3501_driver = {
        .drv            = {
                .name   = "wl3501_cs",
        },
-       .probe          = wl3501_attach,
+       .probe          = wl3501_probe,
        .remove         = wl3501_detach,
        .id_table       = wl3501_ids,
        .suspend        = wl3501_suspend,
@@ -2215,9 +2122,7 @@ static int __init wl3501_init_module(void)
 
 static void __exit wl3501_exit_module(void)
 {
-       dprintk(0, ": unloading");
        pcmcia_unregister_driver(&wl3501_driver);
-       BUG_ON(wl3501_dev_list != NULL);
 }
 
 module_init(wl3501_init_module);