]> nv-tegra.nvidia Code Review - linux-2.6.git/blobdiff - drivers/net/wireless/hostap/hostap_cs.c
pcmcia: use pcmica_{read,write}_config_byte
[linux-2.6.git] / drivers / net / wireless / hostap / hostap_cs.c
index 8bc0b528548f4b843b3f4c05f8336b3ff7053139..691293675a93bd3b92d95497a2af659bf6ec1535 100644 (file)
@@ -1,9 +1,9 @@
 #define PRISM2_PCCARD
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/if.h>
+#include <linux/slab.h>
 #include <linux/wait.h>
 #include <linux/timer.h>
 #include <linux/skbuff.h>
@@ -12,7 +12,6 @@
 #include <linux/wireless.h>
 #include <net/iw_handler.h>
 
-#include <pcmcia/cs_types.h>
 #include <pcmcia/cs.h>
 #include <pcmcia/cistpl.h>
 #include <pcmcia/cisreg.h>
 #include "hostap_wlan.h"
 
 
-static char *version = PRISM2_VERSION " (Jouni Malinen <jkmaline@cc.hut.fi>)";
-static dev_info_t dev_info = "hostap_cs";
+static char *dev_info = "hostap_cs";
 
 MODULE_AUTHOR("Jouni Malinen");
 MODULE_DESCRIPTION("Support for Intersil Prism2-based 802.11 wireless LAN "
                   "cards (PC Card).");
 MODULE_SUPPORTED_DEVICE("Intersil Prism2-based WLAN cards (PC Card)");
 MODULE_LICENSE("GPL");
-MODULE_VERSION(PRISM2_VERSION);
 
 
 static int ignore_cis_vcc;
@@ -41,8 +38,7 @@ MODULE_PARM_DESC(ignore_cis_vcc, "Ignore broken CIS VCC entry");
 
 /* struct local_info::hw_priv */
 struct hostap_cs_priv {
-       dev_node_t node;
-       dev_link_t *link;
+       struct pcmcia_device *link;
        int sandisk_connectplus;
 };
 
@@ -204,15 +200,13 @@ static int hfa384x_to_bap(struct net_device *dev, u16 bap, void *buf, int len)
 
 static void prism2_detach(struct pcmcia_device *p_dev);
 static void prism2_release(u_long arg);
-static int prism2_config(dev_link_t *link);
+static int prism2_config(struct pcmcia_device *link);
 
 
 static int prism2_pccard_card_present(local_info_t *local)
 {
        struct hostap_cs_priv *hw_priv = local->hw_priv;
-       if (hw_priv != NULL && hw_priv->link != NULL &&
-           ((hw_priv->link->state & (DEV_PRESENT | DEV_CONFIG)) ==
-            (DEV_PRESENT | DEV_CONFIG)))
+       if (hw_priv != NULL && hw_priv->link != NULL && pcmcia_dev_present(hw_priv->link))
                return 1;
        return 0;
 }
@@ -230,28 +224,19 @@ static int prism2_pccard_card_present(local_info_t *local)
 static void sandisk_set_iobase(local_info_t *local)
 {
        int res;
-       conf_reg_t reg;
        struct hostap_cs_priv *hw_priv = local->hw_priv;
 
-       reg.Function = 0;
-       reg.Action = CS_WRITE;
-       reg.Offset = 0x10; /* 0x3f0 IO base 1 */
-       reg.Value = hw_priv->link->io.BasePort1 & 0x00ff;
-       res = pcmcia_access_configuration_register(hw_priv->link->handle,
-                                                  &reg);
-       if (res != CS_SUCCESS) {
+       res = pcmcia_write_config_byte(hw_priv->link, 0x10,
+                               hw_priv->link->io.BasePort1 & 0x00ff);
+       if (res != 0) {
                printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 0 -"
                       " res=%d\n", res);
        }
        udelay(10);
 
-       reg.Function = 0;
-       reg.Action = CS_WRITE;
-       reg.Offset = 0x12; /* 0x3f2 IO base 2 */
-       reg.Value = (hw_priv->link->io.BasePort1 & 0xff00) >> 8;
-       res = pcmcia_access_configuration_register(hw_priv->link->handle,
-                                                  &reg);
-       if (res != CS_SUCCESS) {
+       res = pcmcia_write_config_byte(hw_priv->link, 0x12,
+                               (hw_priv->link->io.BasePort1 >> 8) & 0x00ff);
+       if (res != 0) {
                printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 1 -"
                       " res=%d\n", res);
        }
@@ -276,12 +261,8 @@ static void sandisk_write_hcr(local_info_t *local, int hcr)
 static int sandisk_enable_wireless(struct net_device *dev)
 {
        int res, ret = 0;
-       conf_reg_t reg;
-       struct hostap_interface *iface = dev->priv;
+       struct hostap_interface *iface = netdev_priv(dev);
        local_info_t *local = iface->local;
-       tuple_t tuple;
-       cisparse_t *parse = NULL;
-       u_char buf[64];
        struct hostap_cs_priv *hw_priv = local->hw_priv;
 
        if (hw_priv->link->io.NumPorts1 < 0x42) {
@@ -290,31 +271,13 @@ static int sandisk_enable_wireless(struct net_device *dev)
                goto done;
        }
 
-       parse = kmalloc(sizeof(cisparse_t), GFP_KERNEL);
-       if (parse == NULL) {
-               ret = -ENOMEM;
-               goto done;
-       }
-
-       tuple.DesiredTuple = CISTPL_MANFID;
-       tuple.Attributes = TUPLE_RETURN_COMMON;
-       tuple.TupleData = buf;
-       tuple.TupleDataMax = sizeof(buf);
-       tuple.TupleOffset = 0;
-       if (pcmcia_get_first_tuple(hw_priv->link->handle, &tuple) ||
-           pcmcia_get_tuple_data(hw_priv->link->handle, &tuple) ||
-           pcmcia_parse_tuple(hw_priv->link->handle, &tuple, parse) ||
-           parse->manfid.manf != 0xd601 || parse->manfid.card != 0x0101) {
+       if (hw_priv->link->manf_id != 0xd601 || hw_priv->link->card_id != 0x0101) {
                /* No SanDisk manfid found */
                ret = -ENODEV;
                goto done;
        }
 
-       tuple.DesiredTuple = CISTPL_LONGLINK_MFC;
-       if (pcmcia_get_first_tuple(hw_priv->link->handle, &tuple) ||
-           pcmcia_get_tuple_data(hw_priv->link->handle, &tuple) ||
-           pcmcia_parse_tuple(hw_priv->link->handle, &tuple, parse) ||
-               parse->longlink_mfc.nfn < 2) {
+       if (hw_priv->link->socket->functions < 2) {
                /* No multi-function links found */
                ret = -ENODEV;
                goto done;
@@ -324,30 +287,23 @@ static int sandisk_enable_wireless(struct net_device *dev)
               " - using vendor-specific initialization\n", dev->name);
        hw_priv->sandisk_connectplus = 1;
 
-       reg.Function = 0;
-       reg.Action = CS_WRITE;
-       reg.Offset = CISREG_COR;
-       reg.Value = COR_SOFT_RESET;
-       res = pcmcia_access_configuration_register(hw_priv->link->handle,
-                                                  &reg);
-       if (res != CS_SUCCESS) {
+       res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR,
+                               COR_SOFT_RESET);
+       if (res != 0) {
                printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n",
                       dev->name, res);
                goto done;
        }
        mdelay(5);
 
-       reg.Function = 0;
-       reg.Action = CS_WRITE;
-       reg.Offset = CISREG_COR;
        /*
         * Do not enable interrupts here to avoid some bogus events. Interrupts
         * will be enabled during the first cor_sreset call.
         */
-       reg.Value = COR_LEVEL_REQ | 0x8 | COR_ADDR_DECODE | COR_FUNC_ENA;
-       res = pcmcia_access_configuration_register(hw_priv->link->handle,
-                                                  &reg);
-       if (res != CS_SUCCESS) {
+       res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR,
+                               (COR_LEVEL_REQ | 0x8 | COR_ADDR_DECODE |
+                                       COR_FUNC_ENA));
+       if (res != 0) {
                printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n",
                       dev->name, res);
                goto done;
@@ -362,7 +318,6 @@ static int sandisk_enable_wireless(struct net_device *dev)
        udelay(10);
 
 done:
-       kfree(parse);
        return ret;
 }
 
@@ -370,31 +325,24 @@ done:
 static void prism2_pccard_cor_sreset(local_info_t *local)
 {
        int res;
-       conf_reg_t reg;
+       u8 val;
        struct hostap_cs_priv *hw_priv = local->hw_priv;
 
        if (!prism2_pccard_card_present(local))
               return;
 
-       reg.Function = 0;
-       reg.Action = CS_READ;
-       reg.Offset = CISREG_COR;
-       reg.Value = 0;
-       res = pcmcia_access_configuration_register(hw_priv->link->handle,
-                                                  &reg);
-       if (res != CS_SUCCESS) {
+       res = pcmcia_read_config_byte(hw_priv->link, CISREG_COR, &val);
+       if (res != 0) {
                printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 1 (%d)\n",
                       res);
                return;
        }
        printk(KERN_DEBUG "prism2_pccard_cor_sreset: original COR %02x\n",
-              reg.Value);
+               val);
 
-       reg.Action = CS_WRITE;
-       reg.Value |= COR_SOFT_RESET;
-       res = pcmcia_access_configuration_register(hw_priv->link->handle,
-                                                  &reg);
-       if (res != CS_SUCCESS) {
+       val |= COR_SOFT_RESET;
+       res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR, val);
+       if (res != 0) {
                printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 2 (%d)\n",
                       res);
                return;
@@ -402,12 +350,11 @@ static void prism2_pccard_cor_sreset(local_info_t *local)
 
        mdelay(hw_priv->sandisk_connectplus ? 5 : 2);
 
-       reg.Value &= ~COR_SOFT_RESET;
+       val &= ~COR_SOFT_RESET;
        if (hw_priv->sandisk_connectplus)
-               reg.Value |= COR_IREQ_ENA;
-       res = pcmcia_access_configuration_register(hw_priv->link->handle,
-                                                  &reg);
-       if (res != CS_SUCCESS) {
+               val |= COR_IREQ_ENA;
+       res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR, val);
+       if (res != 0) {
                printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 3 (%d)\n",
                       res);
                return;
@@ -423,8 +370,7 @@ static void prism2_pccard_cor_sreset(local_info_t *local)
 static void prism2_pccard_genesis_reset(local_info_t *local, int hcr)
 {
        int res;
-       conf_reg_t reg;
-       int old_cor;
+       u8 old_cor;
        struct hostap_cs_priv *hw_priv = local->hw_priv;
 
        if (!prism2_pccard_card_present(local))
@@ -435,26 +381,18 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr)
                return;
        }
 
-       reg.Function = 0;
-       reg.Action = CS_READ;
-       reg.Offset = CISREG_COR;
-       reg.Value = 0;
-       res = pcmcia_access_configuration_register(hw_priv->link->handle,
-                                                  &reg);
-       if (res != CS_SUCCESS) {
+       res = pcmcia_read_config_byte(hw_priv->link, CISREG_COR, &old_cor);
+       if (res != 0) {
                printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 1 "
                       "(%d)\n", res);
                return;
        }
        printk(KERN_DEBUG "prism2_pccard_genesis_sreset: original COR %02x\n",
-              reg.Value);
-       old_cor = reg.Value;
-
-       reg.Action = CS_WRITE;
-       reg.Value |= COR_SOFT_RESET;
-       res = pcmcia_access_configuration_register(hw_priv->link->handle,
-                                                  &reg);
-       if (res != CS_SUCCESS) {
+               old_cor);
+
+       res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR,
+                               old_cor | COR_SOFT_RESET);
+       if (res != 0) {
                printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 2 "
                       "(%d)\n", res);
                return;
@@ -463,24 +401,17 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr)
        mdelay(10);
 
        /* Setup Genesis mode */
-       reg.Action = CS_WRITE;
-       reg.Value = hcr;
-       reg.Offset = CISREG_CCSR;
-       res = pcmcia_access_configuration_register(hw_priv->link->handle,
-                                                  &reg);
-       if (res != CS_SUCCESS) {
+       res = pcmcia_write_config_byte(hw_priv->link, CISREG_CCSR, hcr);
+       if (res != 0) {
                printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 3 "
                       "(%d)\n", res);
                return;
        }
        mdelay(10);
 
-       reg.Action = CS_WRITE;
-       reg.Offset = CISREG_COR;
-       reg.Value = old_cor & ~COR_SOFT_RESET;
-       res = pcmcia_access_configuration_register(hw_priv->link->handle,
-                                                  &reg);
-       if (res != CS_SUCCESS) {
+       res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR,
+                               old_cor & ~COR_SOFT_RESET);
+       if (res != 0) {
                printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 4 "
                       "(%d)\n", res);
                return;
@@ -501,40 +432,27 @@ static struct prism2_helper_functions prism2_pccard_funcs =
 
 /* allocate local data and register with CardServices
  * initialize dev_link structure, but do not configure the card yet */
-static int prism2_attach(struct pcmcia_device *p_dev)
+static int hostap_cs_probe(struct pcmcia_device *p_dev)
 {
-       dev_link_t *link;
-
-       link = kmalloc(sizeof(dev_link_t), GFP_KERNEL);
-       if (link == NULL)
-               return -ENOMEM;
-
-       memset(link, 0, sizeof(dev_link_t));
+       int ret;
 
        PDEBUG(DEBUG_HW, "%s: setting Vcc=33 (constant)\n", dev_info);
-       link->conf.Vcc = 33;
-       link->conf.IntType = INT_MEMORY_AND_IO;
+       p_dev->conf.IntType = INT_MEMORY_AND_IO;
 
-       link->handle = p_dev;
-       p_dev->instance = link;
-
-       link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
-       if (prism2_config(link))
+       ret = prism2_config(p_dev);
+       if (ret) {
                PDEBUG(DEBUG_EXTRA, "prism2_config() failed\n");
+       }
 
-       return 0;
+       return ret;
 }
 
 
-static void prism2_detach(struct pcmcia_device *p_dev)
+static void prism2_detach(struct pcmcia_device *link)
 {
-       dev_link_t *link = dev_to_instance(p_dev);
-
        PDEBUG(DEBUG_FLOW, "prism2_detach\n");
 
-       if (link->state & DEV_CONFIG) {
-               prism2_release((u_long)link);
-       }
+       prism2_release((u_long)link);
 
        /* release net devices */
        if (link->priv) {
@@ -547,169 +465,116 @@ static void prism2_detach(struct pcmcia_device *p_dev)
                prism2_free_local_data(dev);
                kfree(hw_priv);
        }
-       kfree(link);
 }
 
 
-#define CS_CHECK(fn, ret) \
-do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
+/* run after a CARD_INSERTION event is received to configure the PCMCIA
+ * socket and make the device available to the system */
 
-#define CFG_CHECK2(fn, retf) \
-do { int ret = (retf); \
-if (ret != 0) { \
-       PDEBUG(DEBUG_EXTRA, "CardServices(" #fn ") returned %d\n", ret); \
-       cs_error(link->handle, fn, ret); \
-       goto next_entry; \
-} \
-} while (0)
+static int prism2_config_check(struct pcmcia_device *p_dev,
+                              cistpl_cftable_entry_t *cfg,
+                              cistpl_cftable_entry_t *dflt,
+                              unsigned int vcc,
+                              void *priv_data)
+{
+       if (cfg->index == 0)
+               return -ENODEV;
 
+       PDEBUG(DEBUG_EXTRA, "Checking CFTABLE_ENTRY 0x%02X "
+              "(default 0x%02X)\n", cfg->index, dflt->index);
 
-/* run after a CARD_INSERTION event is received to configure the PCMCIA
- * socket and make the device available to the system */
-static int prism2_config(dev_link_t *link)
+       /* Does this card need audio output? */
+       if (cfg->flags & CISTPL_CFTABLE_AUDIO) {
+               p_dev->conf.Attributes |= CONF_ENABLE_SPKR;
+               p_dev->conf.Status = CCSR_AUDIO_ENA;
+       }
+
+       /* Use power settings for Vcc and Vpp if present */
+       /*  Note that the CIS values need to be rescaled */
+       if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) {
+               if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] /
+                   10000 && !ignore_cis_vcc) {
+                       PDEBUG(DEBUG_EXTRA, "  Vcc mismatch - skipping"
+                              " this entry\n");
+                       return -ENODEV;
+               }
+       } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) {
+               if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] /
+                   10000 && !ignore_cis_vcc) {
+                       PDEBUG(DEBUG_EXTRA, "  Vcc (default) mismatch "
+                              "- skipping this entry\n");
+                       return -ENODEV;
+               }
+       }
+
+       if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM))
+               p_dev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;
+       else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM))
+               p_dev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000;
+
+       /* Do we need to allocate an interrupt? */
+       p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
+
+       /* IO window settings */
+       PDEBUG(DEBUG_EXTRA, "IO window settings: cfg->io.nwin=%d "
+              "dflt->io.nwin=%d\n",
+              cfg->io.nwin, dflt->io.nwin);
+       p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0;
+       if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
+               cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
+               p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
+               PDEBUG(DEBUG_EXTRA, "io->flags = 0x%04X, "
+                      "io.base=0x%04x, len=%d\n", io->flags,
+                      io->win[0].base, io->win[0].len);
+               if (!(io->flags & CISTPL_IO_8BIT))
+                       p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16;
+               if (!(io->flags & CISTPL_IO_16BIT))
+                       p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
+               p_dev->io.IOAddrLines = io->flags &
+                       CISTPL_IO_LINES_MASK;
+               p_dev->io.BasePort1 = io->win[0].base;
+               p_dev->io.NumPorts1 = io->win[0].len;
+               if (io->nwin > 1) {
+                       p_dev->io.Attributes2 = p_dev->io.Attributes1;
+                       p_dev->io.BasePort2 = io->win[1].base;
+                       p_dev->io.NumPorts2 = io->win[1].len;
+               }
+       }
+
+       /* This reserves IO space but doesn't actually enable it */
+       return pcmcia_request_io(p_dev, &p_dev->io);
+}
+
+static int prism2_config(struct pcmcia_device *link)
 {
        struct net_device *dev;
        struct hostap_interface *iface;
        local_info_t *local;
        int ret = 1;
-       tuple_t tuple;
-       cisparse_t *parse;
-       int last_fn, last_ret;
-       u_char buf[64];
-       config_info_t conf;
-       cistpl_cftable_entry_t dflt = { 0 };
        struct hostap_cs_priv *hw_priv;
+       unsigned long flags;
 
        PDEBUG(DEBUG_FLOW, "prism2_config()\n");
 
-       parse = kmalloc(sizeof(cisparse_t), GFP_KERNEL);
-       hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL);
-       if (parse == NULL || hw_priv == NULL) {
-               kfree(parse);
-               kfree(hw_priv);
+       hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL);
+       if (hw_priv == NULL) {
                ret = -ENOMEM;
                goto failed;
        }
-       memset(hw_priv, 0, sizeof(*hw_priv));
-
-       tuple.DesiredTuple = CISTPL_CONFIG;
-       tuple.Attributes = 0;
-       tuple.TupleData = buf;
-       tuple.TupleDataMax = sizeof(buf);
-       tuple.TupleOffset = 0;
-       CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link->handle, &tuple));
-       CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link->handle, &tuple));
-       CS_CHECK(ParseTuple, pcmcia_parse_tuple(link->handle, &tuple, parse));
-       link->conf.ConfigBase = parse->config.base;
-       link->conf.Present = parse->config.rmask[0];
-
-       CS_CHECK(GetConfigurationInfo,
-                pcmcia_get_configuration_info(link->handle, &conf));
-       PDEBUG(DEBUG_HW, "%s: %s Vcc=%d (from config)\n", dev_info,
-              ignore_cis_vcc ? "ignoring" : "setting", conf.Vcc);
-       link->conf.Vcc = conf.Vcc;
 
        /* Look for an appropriate configuration table entry in the CIS */
-       tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
-       CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link->handle, &tuple));
-       for (;;) {
-               cistpl_cftable_entry_t *cfg = &(parse->cftable_entry);
-               CFG_CHECK2(GetTupleData,
-                          pcmcia_get_tuple_data(link->handle, &tuple));
-               CFG_CHECK2(ParseTuple,
-                          pcmcia_parse_tuple(link->handle, &tuple, parse));
-
-               if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
-                       dflt = *cfg;
-               if (cfg->index == 0)
-                       goto next_entry;
-               link->conf.ConfigIndex = cfg->index;
-               PDEBUG(DEBUG_EXTRA, "Checking CFTABLE_ENTRY 0x%02X "
-                      "(default 0x%02X)\n", cfg->index, dflt.index);
-
-               /* Does this card need audio output? */
-               if (cfg->flags & CISTPL_CFTABLE_AUDIO) {
-                       link->conf.Attributes |= CONF_ENABLE_SPKR;
-                       link->conf.Status = CCSR_AUDIO_ENA;
-               }
-
-               /* Use power settings for Vcc and Vpp if present */
-               /*  Note that the CIS values need to be rescaled */
-               if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) {
-                       if (conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] /
-                           10000 && !ignore_cis_vcc) {
-                               PDEBUG(DEBUG_EXTRA, "  Vcc mismatch - skipping"
-                                      " this entry\n");
-                               goto next_entry;
-                       }
-               } else if (dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) {
-                       if (conf.Vcc != dflt.vcc.param[CISTPL_POWER_VNOM] /
-                           10000 && !ignore_cis_vcc) {
-                               PDEBUG(DEBUG_EXTRA, "  Vcc (default) mismatch "
-                                      "- skipping this entry\n");
-                               goto next_entry;
-                       }
-               }
-
-               if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM))
-                       link->conf.Vpp1 = link->conf.Vpp2 =
-                               cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;
-               else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM))
-                       link->conf.Vpp1 = link->conf.Vpp2 =
-                               dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000;
-
-               /* Do we need to allocate an interrupt? */
-               if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1)
-                       link->conf.Attributes |= CONF_ENABLE_IRQ;
-               else if (!(link->conf.Attributes & CONF_ENABLE_IRQ)) {
-                       /* At least Compaq WL200 does not have IRQInfo1 set,
-                        * but it does not work without interrupts.. */
-                       printk("Config has no IRQ info, but trying to enable "
-                              "IRQ anyway..\n");
-                       link->conf.Attributes |= CONF_ENABLE_IRQ;
-               }
-
-               /* IO window settings */
-               PDEBUG(DEBUG_EXTRA, "IO window settings: cfg->io.nwin=%d "
-                      "dflt.io.nwin=%d\n",
-                      cfg->io.nwin, dflt.io.nwin);
-               link->io.NumPorts1 = link->io.NumPorts2 = 0;
-               if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) {
-                       cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io;
-                       link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
-                       PDEBUG(DEBUG_EXTRA, "io->flags = 0x%04X, "
-                              "io.base=0x%04x, len=%d\n", io->flags,
-                              io->win[0].base, io->win[0].len);
-                       if (!(io->flags & CISTPL_IO_8BIT))
-                               link->io.Attributes1 = IO_DATA_PATH_WIDTH_16;
-                       if (!(io->flags & CISTPL_IO_16BIT))
-                               link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
-                       link->io.IOAddrLines = io->flags &
-                               CISTPL_IO_LINES_MASK;
-                       link->io.BasePort1 = io->win[0].base;
-                       link->io.NumPorts1 = io->win[0].len;
-                       if (io->nwin > 1) {
-                               link->io.Attributes2 = link->io.Attributes1;
-                               link->io.BasePort2 = io->win[1].base;
-                               link->io.NumPorts2 = io->win[1].len;
-                       }
-               }
-
-               /* This reserves IO space but doesn't actually enable it */
-               CFG_CHECK2(RequestIO,
-                          pcmcia_request_io(link->handle, &link->io));
-
-               /* This configuration table entry is OK */
-               break;
-
-       next_entry:
-               CS_CHECK(GetNextTuple,
-                        pcmcia_get_next_tuple(link->handle, &tuple));
+       ret = pcmcia_loop_config(link, prism2_config_check, NULL);
+       if (ret) {
+               if (!ignore_cis_vcc)
+                       printk(KERN_ERR "GetNextTuple(): No matching "
+                              "CIS configuration.  Maybe you need the "
+                              "ignore_cis_vcc=1 parameter.\n");
+               goto failed;
        }
 
        /* Need to allocate net_device before requesting IRQ handler */
        dev = prism2_init_local_data(&prism2_pccard_funcs, 0,
-                                    &handle_to_dev(link->handle));
+                                    &link->dev);
        if (dev == NULL)
                goto failed;
        link->priv = dev;
@@ -718,43 +583,39 @@ static int prism2_config(dev_link_t *link)
        local = iface->local;
        local->hw_priv = hw_priv;
        hw_priv->link = link;
-       strcpy(hw_priv->node.dev_name, dev->name);
-       link->dev = &hw_priv->node;
 
        /*
-        * Allocate an interrupt line.  Note that this does not assign a
-        * handler to the interrupt, unless the 'Handler' member of the
-        * irq structure is initialized.
+        * Make sure the IRQ handler cannot proceed until at least
+        * dev->base_addr is initialized.
         */
-       if (link->conf.Attributes & CONF_ENABLE_IRQ) {
-               link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT;
-               link->irq.IRQInfo1 = IRQ_LEVEL_ID;
-               link->irq.Handler = prism2_interrupt;
-               link->irq.Instance = dev;
-               CS_CHECK(RequestIRQ,
-                        pcmcia_request_irq(link->handle, &link->irq));
-       }
+       spin_lock_irqsave(&local->irq_init_lock, flags);
+
+       ret = pcmcia_request_irq(link, prism2_interrupt);
+       if (ret)
+               goto failed_unlock;
 
        /*
         * This actually configures the PCMCIA socket -- setting up
         * the I/O windows and the interrupt mapping, and putting the
         * card and host interface into "Memory and IO" mode.
         */
-       CS_CHECK(RequestConfiguration,
-                pcmcia_request_configuration(link->handle, &link->conf));
+       ret = pcmcia_request_configuration(link, &link->conf);
+       if (ret)
+               goto failed_unlock;
 
-       dev->irq = link->irq.AssignedIRQ;
+       dev->irq = link->irq;
        dev->base_addr = link->io.BasePort1;
 
+       spin_unlock_irqrestore(&local->irq_init_lock, flags);
+
        /* Finally, report what we've done */
-       printk(KERN_INFO "%s: index 0x%02x: Vcc %d.%d",
-              dev_info, link->conf.ConfigIndex,
-              link->conf.Vcc / 10, link->conf.Vcc % 10);
-       if (link->conf.Vpp1)
-               printk(", Vpp %d.%d", link->conf.Vpp1 / 10,
-                      link->conf.Vpp1 % 10);
+       printk(KERN_INFO "%s: index 0x%02x: ",
+              dev_info, link->conf.ConfigIndex);
+       if (link->conf.Vpp)
+               printk(", Vpp %d.%d", link->conf.Vpp / 10,
+                      link->conf.Vpp % 10);
        if (link->conf.Attributes & CONF_ENABLE_IRQ)
-               printk(", irq %d", link->irq.AssignedIRQ);
+               printk(", irq %d", link->irq);
        if (link->io.NumPorts1)
                printk(", io 0x%04x-0x%04x", link->io.BasePort1,
                       link->io.BasePort1+link->io.NumPorts1-1);
@@ -763,27 +624,19 @@ static int prism2_config(dev_link_t *link)
                       link->io.BasePort2+link->io.NumPorts2-1);
        printk("\n");
 
-       link->state |= DEV_CONFIG;
-       link->state &= ~DEV_CONFIG_PENDING;
-
        local->shutdown = 0;
 
        sandisk_enable_wireless(dev);
 
        ret = prism2_hw_config(dev, 1);
-       if (!ret) {
+       if (!ret)
                ret = hostap_hw_ready(dev);
-               if (ret == 0 && local->ddev)
-                       strcpy(hw_priv->node.dev_name, local->ddev->name);
-       }
-       kfree(parse);
-       return ret;
 
- cs_failed:
-       cs_error(link->handle, last_fn, last_ret);
+       return ret;
 
+ failed_unlock:
+        spin_unlock_irqrestore(&local->irq_init_lock, flags);
  failed:
-       kfree(parse);
        kfree(hw_priv);
        prism2_release((u_long)link);
        return ret;
@@ -792,7 +645,7 @@ static int prism2_config(dev_link_t *link)
 
 static void prism2_release(u_long arg)
 {
-       dev_link_t *link = (dev_link_t *)arg;
+       struct pcmcia_device *link = (struct pcmcia_device *)arg;
 
        PDEBUG(DEBUG_FLOW, "prism2_release\n");
 
@@ -801,71 +654,58 @@ static void prism2_release(u_long arg)
                struct hostap_interface *iface;
 
                iface = netdev_priv(dev);
-               if (link->state & DEV_CONFIG)
-                       prism2_hw_shutdown(dev, 0);
+               prism2_hw_shutdown(dev, 0);
                iface->local->shutdown = 1;
        }
 
-       if (link->win)
-               pcmcia_release_window(link->win);
-       pcmcia_release_configuration(link->handle);
-       if (link->io.NumPorts1)
-               pcmcia_release_io(link->handle, &link->io);
-       if (link->irq.AssignedIRQ)
-               pcmcia_release_irq(link->handle, &link->irq);
-
-       link->state &= ~DEV_CONFIG;
-
+       pcmcia_disable_device(link);
        PDEBUG(DEBUG_FLOW, "release - done\n");
 }
 
-static int hostap_cs_suspend(struct pcmcia_device *p_dev)
+static int hostap_cs_suspend(struct pcmcia_device *link)
 {
-       dev_link_t *link = dev_to_instance(p_dev);
        struct net_device *dev = (struct net_device *) link->priv;
        int dev_open = 0;
+       struct hostap_interface *iface = NULL;
 
-       PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_SUSPEND\n", dev_info);
+       if (!dev)
+               return -ENODEV;
 
-       link->state |= DEV_SUSPEND;
+       iface = netdev_priv(dev);
 
-       if (link->state & DEV_CONFIG) {
-               struct hostap_interface *iface = netdev_priv(dev);
-               if (iface && iface->local)
-                       dev_open = iface->local->num_dev_open > 0;
-               if (dev_open) {
-                       netif_stop_queue(dev);
-                       netif_device_detach(dev);
-               }
-               prism2_suspend(dev);
-               pcmcia_release_configuration(link->handle);
+       PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_SUSPEND\n", dev_info);
+       if (iface && iface->local)
+               dev_open = iface->local->num_dev_open > 0;
+       if (dev_open) {
+               netif_stop_queue(dev);
+               netif_device_detach(dev);
        }
+       prism2_suspend(dev);
 
        return 0;
 }
 
-static int hostap_cs_resume(struct pcmcia_device *p_dev)
+static int hostap_cs_resume(struct pcmcia_device *link)
 {
-       dev_link_t *link = dev_to_instance(p_dev);
        struct net_device *dev = (struct net_device *) link->priv;
        int dev_open = 0;
+       struct hostap_interface *iface = NULL;
 
-       PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_RESUME\n", dev_info);
+       if (!dev)
+               return -ENODEV;
 
-       link->state &= ~DEV_SUSPEND;
-       if (link->state & DEV_CONFIG) {
-               struct hostap_interface *iface = netdev_priv(dev);
-               if (iface && iface->local)
-                       dev_open = iface->local->num_dev_open > 0;
+       iface = netdev_priv(dev);
+
+       PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_RESUME\n", dev_info);
 
-               pcmcia_request_configuration(link->handle, &link->conf);
+       if (iface && iface->local)
+               dev_open = iface->local->num_dev_open > 0;
 
-               prism2_hw_shutdown(dev, 1);
-               prism2_hw_config(dev, dev_open ? 0 : 1);
-               if (dev_open) {
-                       netif_device_attach(dev);
-                       netif_start_queue(dev);
-               }
+       prism2_hw_shutdown(dev, 1);
+       prism2_hw_config(dev, dev_open ? 0 : 1);
+       if (dev_open) {
+               netif_device_attach(dev);
+               netif_start_queue(dev);
        }
 
        return 0;
@@ -877,7 +717,7 @@ static struct pcmcia_device_id hostap_cs_ids[] = {
        PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0777),
        PCMCIA_DEVICE_MANF_CARD(0x0126, 0x8000),
        PCMCIA_DEVICE_MANF_CARD(0x0138, 0x0002),
-       PCMCIA_DEVICE_MANF_CARD(0x0156, 0x0002),
+       PCMCIA_DEVICE_MANF_CARD(0x01bf, 0x3301),
        PCMCIA_DEVICE_MANF_CARD(0x0250, 0x0002),
        PCMCIA_DEVICE_MANF_CARD(0x026f, 0x030b),
        PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1612),
@@ -887,16 +727,20 @@ static struct pcmcia_device_id hostap_cs_ids[] = {
        PCMCIA_DEVICE_MANF_CARD(0x02d2, 0x0001),
        PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x0001),
        PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x7300),
-       PCMCIA_DEVICE_MANF_CARD(0xc00f, 0x0000),
+/*     PCMCIA_DEVICE_MANF_CARD(0xc00f, 0x0000),    conflict with pcnet_cs */
+       PCMCIA_DEVICE_MANF_CARD(0xc250, 0x0002),
        PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0002),
        PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0005),
        PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0010),
+       PCMCIA_DEVICE_MANF_CARD(0x0126, 0x0002),
+       PCMCIA_DEVICE_MANF_CARD_PROD_ID1(0xd601, 0x0005, "ADLINK 345 CF",
+                                        0x2d858104),
+       PCMCIA_DEVICE_MANF_CARD_PROD_ID1(0x0156, 0x0002, "INTERSIL",
+                                        0x74c5e40d),
+       PCMCIA_DEVICE_MANF_CARD_PROD_ID1(0x0156, 0x0002, "Intersil",
+                                        0x4b801a17),
        PCMCIA_MFC_DEVICE_PROD_ID12(0, "SanDisk", "ConnectPlus",
                                    0x7a954bd9, 0x74be00c6),
-       PCMCIA_DEVICE_PROD_ID1234(
-               "Intersil", "PRISM 2_5 PCMCIA ADAPTER", "ISL37300P",
-               "Eval-RevA",
-               0x4b801a17, 0x6345a0bf, 0xc9049a39, 0xc23adc0e),
        PCMCIA_DEVICE_PROD_ID123(
                "Addtron", "AWP-100 Wireless PCMCIA", "Version 01.02",
                0xe6ec52ce, 0x08649af2, 0x4b74baa0),
@@ -920,6 +764,23 @@ static struct pcmcia_device_id hostap_cs_ids[] = {
        PCMCIA_DEVICE_PROD_ID12(
                "ZoomAir 11Mbps High", "Rate wireless Networking",
                0x273fe3db, 0x32a1eaee),
+       PCMCIA_DEVICE_PROD_ID123(
+               "Pretec", "CompactWLAN Card 802.11b", "2.5",
+               0x1cadd3e5, 0xe697636c, 0x7a5bfcf1),
+       PCMCIA_DEVICE_PROD_ID123(
+               "U.S. Robotics", "IEEE 802.11b PC-CARD", "Version 01.02",
+               0xc7b8df9d, 0x1700d087, 0x4b74baa0),
+       PCMCIA_DEVICE_PROD_ID123(
+               "Allied Telesyn", "AT-WCL452 Wireless PCMCIA Radio",
+               "Ver. 1.00",
+               0x5cd01705, 0x4271660f, 0x9d08ee12),
+       PCMCIA_DEVICE_PROD_ID123(
+               "Wireless LAN" , "11Mbps PC Card", "Version 01.02",
+               0x4b8870ff, 0x70e946d1, 0x4b74baa0),
+       PCMCIA_DEVICE_PROD_ID3("HFA3863", 0x355cb092),
+       PCMCIA_DEVICE_PROD_ID3("ISL37100P", 0x630d52b2),
+       PCMCIA_DEVICE_PROD_ID3("ISL37101P-10", 0xdd97a26b),
+       PCMCIA_DEVICE_PROD_ID3("ISL37300P", 0xc9049a39),
        PCMCIA_DEVICE_NULL
 };
 MODULE_DEVICE_TABLE(pcmcia, hostap_cs_ids);
@@ -929,7 +790,7 @@ static struct pcmcia_driver hostap_driver = {
        .drv            = {
                .name   = "hostap_cs",
        },
-       .probe          = prism2_attach,
+       .probe          = hostap_cs_probe,
        .remove         = prism2_detach,
        .owner          = THIS_MODULE,
        .id_table       = hostap_cs_ids,
@@ -939,14 +800,12 @@ static struct pcmcia_driver hostap_driver = {
 
 static int __init init_prism2_pccard(void)
 {
-       printk(KERN_INFO "%s: %s\n", dev_info, version);
        return pcmcia_register_driver(&hostap_driver);
 }
 
 static void __exit exit_prism2_pccard(void)
 {
        pcmcia_unregister_driver(&hostap_driver);
-       printk(KERN_INFO "%s: Driver unloaded\n", dev_info);
 }