pcmcia: convert pcmcia_request_configuration to pcmcia_enable_device
[linux-2.6-block.git] / drivers / scsi / pcmcia / nsp_cs.c
index dd9b40306f3d28f0d355a2ed72903b5fa148530f..d0546c03f57cb3ae000568ef5bf7a07e8639871b 100644 (file)
@@ -47,7 +47,6 @@
 #include <scsi/scsi.h>
 #include <scsi/scsi_ioctl.h>
 
-#include <pcmcia/cs.h>
 #include <pcmcia/cistpl.h>
 #include <pcmcia/cisreg.h>
 #include <pcmcia/ds.h>
@@ -1562,8 +1561,7 @@ static int nsp_cs_probe(struct pcmcia_device *link)
        link->resource[0]->flags = IO_DATA_PATH_WIDTH_AUTO;
 
        /* General socket configuration */
-       link->conf.Attributes    = CONF_ENABLE_IRQ;
-       link->conf.IntType       = INT_MEMORY_AND_IO;
+       link->config_flags       |= CONF_ENABLE_IRQ;
 
        ret = nsp_cs_config(link);
 
@@ -1596,27 +1594,20 @@ static void nsp_cs_detach(struct pcmcia_device *link)
     ethernet device available to the system.
 ======================================================================*/
 
-struct nsp_cs_configdata {
-       nsp_hw_data             *data;
-       win_req_t               req;
-};
-
 static int nsp_cs_config_check(struct pcmcia_device *p_dev,
                               cistpl_cftable_entry_t *cfg,
                               cistpl_cftable_entry_t *dflt,
                               unsigned int vcc,
                               void *priv_data)
 {
-       struct nsp_cs_configdata *cfg_mem = priv_data;
+       nsp_hw_data             *data = priv_data;
 
        if (cfg->index == 0)
                return -ENODEV;
 
        /* 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;
-       }
+       if (cfg->flags & CISTPL_CFTABLE_AUDIO)
+               p_dev->config_flags |= CONF_ENABLE_SPKR;
 
        /* Use power settings for Vcc and Vpp if present */
        /*  Note that the CIS values need to be rescaled */
@@ -1629,15 +1620,15 @@ static int nsp_cs_config_check(struct pcmcia_device *p_dev,
                }
 
                if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) {
-                       p_dev->conf.Vpp =
+                       p_dev->vpp =
                                cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;
                } else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM)) {
-                       p_dev->conf.Vpp =
+                       p_dev->vpp =
                                dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000;
                }
 
                /* Do we need to allocate an interrupt? */
-               p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
+               p_dev->config_flags |= CONF_ENABLE_IRQ;
 
                /* IO window settings */
                p_dev->resource[0]->end = p_dev->resource[1]->end = 0;
@@ -1663,21 +1654,24 @@ static int nsp_cs_config_check(struct pcmcia_device *p_dev,
                if ((cfg->mem.nwin > 0) || (dflt->mem.nwin > 0)) {
                        cistpl_mem_t    *mem =
                                (cfg->mem.nwin) ? &cfg->mem : &dflt->mem;
-                       cfg_mem->req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM;
-                       cfg_mem->req.Attributes |= WIN_ENABLE;
-                       cfg_mem->req.Base = mem->win[0].host_addr;
-                       cfg_mem->req.Size = mem->win[0].len;
-                       if (cfg_mem->req.Size < 0x1000)
-                               cfg_mem->req.Size = 0x1000;
-                       cfg_mem->req.AccessSpeed = 0;
-                       if (pcmcia_request_window(p_dev, &cfg_mem->req, &p_dev->win) != 0)
+                       p_dev->resource[2]->flags |= (WIN_DATA_WIDTH_16 |
+                                               WIN_MEMORY_TYPE_CM |
+                                               WIN_ENABLE);
+                       p_dev->resource[2]->start = mem->win[0].host_addr;
+                       p_dev->resource[2]->end = mem->win[0].len;
+                       if (p_dev->resource[2]->end < 0x1000)
+                               p_dev->resource[2]->end = 0x1000;
+                       if (pcmcia_request_window(p_dev, p_dev->resource[2],
+                                                       0) != 0)
                                goto next_entry;
-                       if (pcmcia_map_mem_page(p_dev, p_dev->win,
+                       if (pcmcia_map_mem_page(p_dev, p_dev->resource[2],
                                        mem->win[0].card_addr) != 0)
                                goto next_entry;
 
-                       cfg_mem->data->MmioAddress = (unsigned long) ioremap_nocache(cfg_mem->req.Base, cfg_mem->req.Size);
-                       cfg_mem->data->MmioLength  = cfg_mem->req.Size;
+                       data->MmioAddress = (unsigned long)
+                               ioremap_nocache(p_dev->resource[2]->start,
+                                       resource_size(p_dev->resource[2]));
+                       data->MmioLength  = resource_size(p_dev->resource[2]);
                }
                /* If we got this far, we're cool! */
                return 0;
@@ -1693,25 +1687,19 @@ static int nsp_cs_config(struct pcmcia_device *link)
 {
        int               ret;
        scsi_info_t      *info   = link->priv;
-       struct nsp_cs_configdata *cfg_mem;
        struct Scsi_Host *host;
        nsp_hw_data      *data = &nsp_data_base;
 
        nsp_dbg(NSP_DEBUG_INIT, "in");
 
-       cfg_mem = kzalloc(sizeof(*cfg_mem), GFP_KERNEL);
-       if (!cfg_mem)
-               return -ENOMEM;
-       cfg_mem->data = data;
-
-       ret = pcmcia_loop_config(link, nsp_cs_config_check, cfg_mem);
+       ret = pcmcia_loop_config(link, nsp_cs_config_check, data);
        if (ret)
                goto cs_failed;
 
        if (pcmcia_request_irq(link, nspintr))
                goto cs_failed;
 
-       ret = pcmcia_request_configuration(link, &link->conf);
+       ret = pcmcia_enable_device(link);
        if (ret)
                goto cs_failed;
 
@@ -1756,29 +1744,24 @@ static int nsp_cs_config(struct pcmcia_device *link)
 
        /* Finally, report what we've done */
        printk(KERN_INFO "nsp_cs: index 0x%02x: ",
-              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);
+              link->config_index);
+       if (link->vpp) {
+               printk(", Vpp %d.%d", link->vpp/10, link->vpp%10);
        }
+       printk(", irq %d", link->irq);
        if (link->resource[0])
                printk(", io %pR", link->resource[0]);
        if (link->resource[1])
                printk(" & %pR", link->resource[1]);
-       if (link->win)
-               printk(", mem 0x%06lx-0x%06lx", cfg_mem->req.Base,
-                      cfg_mem->req.Base+cfg_mem->req.Size-1);
+       if (link->resource[2])
+               printk(", mem %pR", link->resource[2]);
        printk("\n");
 
-       kfree(cfg_mem);
        return 0;
 
  cs_failed:
        nsp_dbg(NSP_DEBUG_INIT, "config fail");
        nsp_cs_release(link);
-       kfree(cfg_mem);
 
        return -ENODEV;
 } /* nsp_cs_config */
@@ -1807,7 +1790,7 @@ static void nsp_cs_release(struct pcmcia_device *link)
                scsi_remove_host(info->host);
        }
 
-       if (link->win) {
+       if (resource_size(link->resource[2])) {
                if (data != NULL) {
                        iounmap((void *)(data->MmioAddress));
                }