fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / pcmcia / pcmcia_resource.c
index 89022ad..b9201c2 100644 (file)
@@ -14,7 +14,6 @@
  *
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/interrupt.h>
@@ -89,7 +88,6 @@ static int alloc_io_space(struct pcmcia_socket *s, u_int attr, ioaddr_t *base,
        }
        if ((s->features & SS_CAP_STATIC_MAP) && s->io_offset) {
                *base = s->io_offset | (*base & 0x0fff);
-               s->io[0].Attributes = attr;
                return 0;
        }
        /* Check for an already-allocated window that must conflict with
@@ -97,38 +95,36 @@ static int alloc_io_space(struct pcmcia_socket *s, u_int attr, ioaddr_t *base,
         * potential conflicts, just the most obvious ones.
         */
        for (i = 0; i < MAX_IO_WIN; i++)
-               if ((s->io[i].NumPorts != 0) &&
-                   ((s->io[i].BasePort & (align-1)) == *base))
+               if ((s->io[i].res) && *base &&
+                   ((s->io[i].res->start & (align-1)) == *base))
                        return 1;
        for (i = 0; i < MAX_IO_WIN; i++) {
-               if (s->io[i].NumPorts == 0) {
+               if (!s->io[i].res) {
                        s->io[i].res = pcmcia_find_io_region(*base, num, align, s);
                        if (s->io[i].res) {
-                               s->io[i].Attributes = attr;
-                               s->io[i].BasePort = *base = s->io[i].res->start;
-                               s->io[i].NumPorts = s->io[i].InUse = num;
+                               *base = s->io[i].res->start;
+                               s->io[i].res->flags = (s->io[i].res->flags & ~IORESOURCE_BITS) | (attr & IORESOURCE_BITS);
+                               s->io[i].InUse = num;
                                break;
                        } else
                                return 1;
-               } else if (s->io[i].Attributes != attr)
+               } else if ((s->io[i].res->flags & IORESOURCE_BITS) != (attr & IORESOURCE_BITS))
                        continue;
                /* Try to extend top of window */
-               try = s->io[i].BasePort + s->io[i].NumPorts;
+               try = s->io[i].res->end + 1;
                if ((*base == 0) || (*base == try))
                        if (pcmcia_adjust_io_region(s->io[i].res, s->io[i].res->start,
                                                    s->io[i].res->end + num, s) == 0) {
                                *base = try;
-                               s->io[i].NumPorts += num;
                                s->io[i].InUse += num;
                                break;
                        }
                /* Try to extend bottom of window */
-               try = s->io[i].BasePort - num;
+               try = s->io[i].res->start - num;
                if ((*base == 0) || (*base == try))
                        if (pcmcia_adjust_io_region(s->io[i].res, s->io[i].res->start - num,
                                                    s->io[i].res->end, s) == 0) {
-                               s->io[i].BasePort = *base = try;
-                               s->io[i].NumPorts += num;
+                               *base = try;
                                s->io[i].InUse += num;
                                break;
                        }
@@ -143,12 +139,13 @@ static void release_io_space(struct pcmcia_socket *s, ioaddr_t base,
        int i;
 
        for (i = 0; i < MAX_IO_WIN; i++) {
-               if ((s->io[i].BasePort <= base) &&
-                   (s->io[i].BasePort+s->io[i].NumPorts >= base+num)) {
+               if (!s->io[i].res)
+                       continue;
+               if ((s->io[i].res->start <= base) &&
+                   (s->io[i].res->end >= base+num-1)) {
                        s->io[i].InUse -= num;
                        /* Free the window if no one else is using it */
                        if (s->io[i].InUse == 0) {
-                               s->io[i].NumPorts = 0;
                                release_resource(s->io[i].res);
                                kfree(s->io[i].res);
                                s->io[i].res = NULL;
@@ -165,21 +162,19 @@ static void release_io_space(struct pcmcia_socket *s, ioaddr_t base,
  * this and the tuple reading services.
  */
 
-int pccard_access_configuration_register(struct pcmcia_socket *s,
-                                        unsigned int function,
+int pcmcia_access_configuration_register(struct pcmcia_device *p_dev,
                                         conf_reg_t *reg)
 {
+       struct pcmcia_socket *s;
        config_t *c;
        int addr;
        u_char val;
 
-       if (!s || !s->config)
+       if (!p_dev || !p_dev->function_config)
                return CS_NO_CARD;
 
-       c = &s->config[function];
-
-       if (c == NULL)
-               return CS_NO_CARD;
+       s = p_dev->socket;
+       c = p_dev->function_config;
 
        if (!(c->state & CONFIG_LOCKED))
                return CS_CONFIGURATION_LOCKED;
@@ -200,20 +195,12 @@ int pccard_access_configuration_register(struct pcmcia_socket *s,
                break;
        }
        return CS_SUCCESS;
-} /* pccard_access_configuration_register */
-
-int pcmcia_access_configuration_register(struct pcmcia_device *p_dev,
-                                        conf_reg_t *reg)
-{
-       return pccard_access_configuration_register(p_dev->socket,
-                                                   p_dev->func, reg);
-}
+} /* pcmcia_access_configuration_register */
 EXPORT_SYMBOL(pcmcia_access_configuration_register);
 
 
-
 int pccard_get_configuration_info(struct pcmcia_socket *s,
-                                 unsigned int function,
+                                 struct pcmcia_device *p_dev,
                                  config_info_t *config)
 {
        config_t *c;
@@ -221,7 +208,6 @@ int pccard_get_configuration_info(struct pcmcia_socket *s,
        if (!(s->state & SOCKET_PRESENT))
                return CS_NO_CARD;
 
-       config->Function = function;
 
 #ifdef CONFIG_CARDBUS
        if (s->state & SOCKET_CARDBUS) {
@@ -235,14 +221,22 @@ int pccard_get_configuration_info(struct pcmcia_socket *s,
                        config->AssignedIRQ = s->irq.AssignedIRQ;
                        if (config->AssignedIRQ)
                                config->Attributes |= CONF_ENABLE_IRQ;
-                       config->BasePort1 = s->io[0].BasePort;
-                       config->NumPorts1 = s->io[0].NumPorts;
+                       if (s->io[0].res) {
+                               config->BasePort1 = s->io[0].res->start;
+                               config->NumPorts1 = s->io[0].res->end - config->BasePort1 + 1;
+                       }
                }
                return CS_SUCCESS;
        }
 #endif
 
-       c = (s->config != NULL) ? &s->config[function] : NULL;
+       if (p_dev) {
+               c = p_dev->function_config;
+               config->Function = p_dev->func;
+       } else {
+               c = NULL;
+               config->Function = 0;
+       }
 
        if ((c == NULL) || !(c->state & CONFIG_LOCKED)) {
                config->Attributes = 0;
@@ -251,10 +245,17 @@ int pccard_get_configuration_info(struct pcmcia_socket *s,
                return CS_SUCCESS;
        }
 
-       /* !!! This is a hack !!! */
-       memcpy(&config->Attributes, &c->Attributes, sizeof(config_t));
-       config->Attributes |= CONF_VALID_CLIENT;
-       config->CardValues = c->CardValues;
+       config->Attributes = c->Attributes | CONF_VALID_CLIENT;
+       config->Vcc = s->socket.Vcc;
+       config->Vpp1 = config->Vpp2 = s->socket.Vpp;
+       config->IntType = c->IntType;
+       config->ConfigBase = c->ConfigBase;
+       config->Status = c->Status;
+       config->Pin = c->Pin;
+       config->Copy = c->Copy;
+       config->Option = c->Option;
+       config->ExtStatus = c->ExtStatus;
+       config->Present = config->CardValues = c->CardValues;
        config->IRQAttributes = c->irq.Attributes;
        config->AssignedIRQ = s->irq.AssignedIRQ;
        config->BasePort1 = c->io.BasePort1;
@@ -271,7 +272,7 @@ int pccard_get_configuration_info(struct pcmcia_socket *s,
 int pcmcia_get_configuration_info(struct pcmcia_device *p_dev,
                                  config_info_t *config)
 {
-       return pccard_get_configuration_info(p_dev->socket, p_dev->func,
+       return pccard_get_configuration_info(p_dev->socket, p_dev,
                                             config);
 }
 EXPORT_SYMBOL(pcmcia_get_configuration_info);
@@ -317,7 +318,7 @@ EXPORT_SYMBOL(pcmcia_get_window);
  * SocketState yet: I haven't seen any point for it.
  */
 
-int pccard_get_status(struct pcmcia_socket *s, unsigned int function,
+int pccard_get_status(struct pcmcia_socket *s, struct pcmcia_device *p_dev,
                      cs_status_t *status)
 {
        config_t *c;
@@ -334,11 +335,12 @@ int pccard_get_status(struct pcmcia_socket *s, unsigned int function,
        if (!(s->state & SOCKET_PRESENT))
                return CS_NO_CARD;
 
-       c = (s->config != NULL) ? &s->config[function] : NULL;
+       c = (p_dev) ? p_dev->function_config : NULL;
+
        if ((c != NULL) && (c->state & CONFIG_LOCKED) &&
            (c->IntType & (INT_MEMORY_AND_IO | INT_ZOOMED_VIDEO))) {
                u_char reg;
-               if (c->Present & PRESENT_PIN_REPLACE) {
+               if (c->CardValues & PRESENT_PIN_REPLACE) {
                        pcmcia_read_cis_mem(s, 1, (c->ConfigBase+CISREG_PRR)>>1, 1, &reg);
                        status->CardState |=
                                (reg & PRR_WP_STATUS) ? CS_EVENT_WRITE_PROTECT : 0;
@@ -352,7 +354,7 @@ int pccard_get_status(struct pcmcia_socket *s, unsigned int function,
                        /* No PRR?  Then assume we're always ready */
                        status->CardState |= CS_EVENT_READY_CHANGE;
                }
-               if (c->Present & PRESENT_EXT_STATUS) {
+               if (c->CardValues & PRESENT_EXT_STATUS) {
                        pcmcia_read_cis_mem(s, 1, (c->ConfigBase+CISREG_ESR)>>1, 1, &reg);
                        status->CardState |=
                                (reg & ESR_REQ_ATTN) ? CS_EVENT_REQUEST_ATTENTION : 0;
@@ -370,11 +372,9 @@ int pccard_get_status(struct pcmcia_socket *s, unsigned int function,
        return CS_SUCCESS;
 } /* pccard_get_status */
 
-int pcmcia_get_status(client_handle_t handle, cs_status_t *status)
+int pcmcia_get_status(struct pcmcia_device *p_dev, cs_status_t *status)
 {
-       struct pcmcia_socket *s;
-       s = SOCKET(handle);
-       return pccard_get_status(s, handle->func, status);
+       return pccard_get_status(p_dev->socket, p_dev, status);
 }
 EXPORT_SYMBOL(pcmcia_get_status);
 
@@ -422,7 +422,8 @@ int pcmcia_modify_configuration(struct pcmcia_device *p_dev,
        config_t *c;
 
        s = p_dev->socket;
-       c = CONFIG(p_dev);
+       c = p_dev->function_config;
+
        if (!(s->state & SOCKET_PRESENT))
                return CS_NO_CARD;
        if (!(c->state & CONFIG_LOCKED))
@@ -454,6 +455,28 @@ int pcmcia_modify_configuration(struct pcmcia_device *p_dev,
                   (mod->Attributes & CONF_VPP2_CHANGE_VALID))
                return CS_BAD_VPP;
 
+       if (mod->Attributes & CONF_IO_CHANGE_WIDTH) {
+               pccard_io_map io_off = { 0, 0, 0, 0, 1 };
+               pccard_io_map io_on;
+               int i;
+
+               io_on.speed = io_speed;
+               for (i = 0; i < MAX_IO_WIN; i++) {
+                       if (!s->io[i].res)
+                               continue;
+                       io_off.map = i;
+                       io_on.map = i;
+
+                       io_on.flags = MAP_ACTIVE | IO_DATA_PATH_WIDTH_8;
+                       io_on.start = s->io[i].res->start;
+                       io_on.stop = s->io[i].res->end;
+
+                       s->ops->set_io_map(s, &io_off);
+                       mdelay(40);
+                       s->ops->set_io_map(s, &io_on);
+               }
+       }
+
        return CS_SUCCESS;
 } /* modify_configuration */
 EXPORT_SYMBOL(pcmcia_modify_configuration);
@@ -463,23 +486,23 @@ int pcmcia_release_configuration(struct pcmcia_device *p_dev)
 {
        pccard_io_map io = { 0, 0, 0, 0, 1 };
        struct pcmcia_socket *s = p_dev->socket;
+       config_t *c = p_dev->function_config;
        int i;
 
-       if (!(p_dev->state & CLIENT_CONFIG_LOCKED))
-               return CS_BAD_HANDLE;
-       p_dev->state &= ~CLIENT_CONFIG_LOCKED;
-
-       if (!(p_dev->state & CLIENT_STALE)) {
-               config_t *c = CONFIG(p_dev);
+       if (p_dev->_locked) {
+               p_dev->_locked = 0;
                if (--(s->lock_count) == 0) {
                        s->socket.flags = SS_OUTPUT_ENA;   /* Is this correct? */
                        s->socket.Vpp = 0;
                        s->socket.io_irq = 0;
                        s->ops->set_socket(s, &s->socket);
                }
+       }
+       if (c->state & CONFIG_LOCKED) {
+               c->state &= ~CONFIG_LOCKED;
                if (c->state & CONFIG_IO_REQ)
                        for (i = 0; i < MAX_IO_WIN; i++) {
-                               if (s->io[i].NumPorts == 0)
+                               if (!s->io[i].res)
                                        continue;
                                s->io[i].Config--;
                                if (s->io[i].Config != 0)
@@ -487,12 +510,10 @@ int pcmcia_release_configuration(struct pcmcia_device *p_dev)
                                io.map = i;
                                s->ops->set_io_map(s, &io);
                        }
-               c->state &= ~CONFIG_LOCKED;
        }
 
        return CS_SUCCESS;
 } /* pcmcia_release_configuration */
-EXPORT_SYMBOL(pcmcia_release_configuration);
 
 
 /** pcmcia_release_io
@@ -503,25 +524,23 @@ EXPORT_SYMBOL(pcmcia_release_configuration);
  * don't bother checking the port ranges against the current socket
  * values.
  */
-int pcmcia_release_io(struct pcmcia_device *p_dev, io_req_t *req)
+static int pcmcia_release_io(struct pcmcia_device *p_dev, io_req_t *req)
 {
        struct pcmcia_socket *s = p_dev->socket;
+       config_t *c = p_dev->function_config;
 
-       if (!(p_dev->state & CLIENT_IO_REQ))
+       if (!p_dev->_io )
                return CS_BAD_HANDLE;
-       p_dev->state &= ~CLIENT_IO_REQ;
 
-       if (!(p_dev->state & CLIENT_STALE)) {
-               config_t *c = CONFIG(p_dev);
-               if (c->state & CONFIG_LOCKED)
-                       return CS_CONFIGURATION_LOCKED;
-               if ((c->io.BasePort1 != req->BasePort1) ||
-                   (c->io.NumPorts1 != req->NumPorts1) ||
-                   (c->io.BasePort2 != req->BasePort2) ||
-                   (c->io.NumPorts2 != req->NumPorts2))
-                       return CS_BAD_ARGS;
-               c->state &= ~CONFIG_IO_REQ;
-       }
+       p_dev->_io = 0;
+
+       if ((c->io.BasePort1 != req->BasePort1) ||
+           (c->io.NumPorts1 != req->NumPorts1) ||
+           (c->io.BasePort2 != req->BasePort2) ||
+           (c->io.NumPorts2 != req->NumPorts2))
+               return CS_BAD_ARGS;
+
+       c->state &= ~CONFIG_IO_REQ;
 
        release_io_space(s, req->BasePort1, req->NumPorts1);
        if (req->NumPorts2)
@@ -529,28 +548,26 @@ int pcmcia_release_io(struct pcmcia_device *p_dev, io_req_t *req)
 
        return CS_SUCCESS;
 } /* pcmcia_release_io */
-EXPORT_SYMBOL(pcmcia_release_io);
 
 
-int pcmcia_release_irq(struct pcmcia_device *p_dev, irq_req_t *req)
+static int pcmcia_release_irq(struct pcmcia_device *p_dev, irq_req_t *req)
 {
        struct pcmcia_socket *s = p_dev->socket;
-       if (!(p_dev->state & CLIENT_IRQ_REQ))
+       config_t *c= p_dev->function_config;
+
+       if (!p_dev->_irq)
                return CS_BAD_HANDLE;
-       p_dev->state &= ~CLIENT_IRQ_REQ;
-
-       if (!(p_dev->state & CLIENT_STALE)) {
-               config_t *c = CONFIG(p_dev);
-               if (c->state & CONFIG_LOCKED)
-                       return CS_CONFIGURATION_LOCKED;
-               if (c->irq.Attributes != req->Attributes)
-                       return CS_BAD_ATTRIBUTE;
-               if (s->irq.AssignedIRQ != req->AssignedIRQ)
-                       return CS_BAD_IRQ;
-               if (--s->irq.Config == 0) {
-                       c->state &= ~CONFIG_IRQ_REQ;
-                       s->irq.AssignedIRQ = 0;
-               }
+       p_dev->_irq = 0;
+
+       if (c->state & CONFIG_LOCKED)
+               return CS_CONFIGURATION_LOCKED;
+       if (c->irq.Attributes != req->Attributes)
+               return CS_BAD_ATTRIBUTE;
+       if (s->irq.AssignedIRQ != req->AssignedIRQ)
+               return CS_BAD_IRQ;
+       if (--s->irq.Config == 0) {
+               c->state &= ~CONFIG_IRQ_REQ;
+               s->irq.AssignedIRQ = 0;
        }
 
        if (req->Attributes & IRQ_HANDLE_PRESENT) {
@@ -563,7 +580,6 @@ int pcmcia_release_irq(struct pcmcia_device *p_dev, irq_req_t *req)
 
        return CS_SUCCESS;
 } /* pcmcia_release_irq */
-EXPORT_SYMBOL(pcmcia_release_irq);
 
 
 int pcmcia_release_window(window_handle_t win)
@@ -573,7 +589,7 @@ int pcmcia_release_window(window_handle_t win)
        if ((win == NULL) || (win->magic != WINDOW_MAGIC))
                return CS_BAD_HANDLE;
        s = win->sock;
-       if (!(win->handle->state & CLIENT_WIN_REQ(win->index)))
+       if (!(win->handle->_win & CLIENT_WIN_REQ(win->index)))
                return CS_BAD_HANDLE;
 
        /* Shut down memory window */
@@ -587,7 +603,7 @@ int pcmcia_release_window(window_handle_t win)
                kfree(win->ctl.res);
                win->ctl.res = NULL;
        }
-       win->handle->state &= ~CLIENT_WIN_REQ(win->index);
+       win->handle->_win &= ~CLIENT_WIN_REQ(win->index);
 
        win->magic = 0;
 
@@ -610,16 +626,12 @@ int pcmcia_request_configuration(struct pcmcia_device *p_dev,
 
        if (req->IntType & INT_CARDBUS)
                return CS_UNSUPPORTED_MODE;
-       c = CONFIG(p_dev);
+       c = p_dev->function_config;
        if (c->state & CONFIG_LOCKED)
                return CS_CONFIGURATION_LOCKED;
 
        /* Do power control.  We don't allow changes in Vcc. */
-       if (s->socket.Vcc != req->Vcc)
-               return CS_BAD_VCC;
-       if (req->Vpp1 != req->Vpp2)
-               return CS_BAD_VPP;
-       s->socket.Vpp = req->Vpp1;
+       s->socket.Vpp = req->Vpp;
        if (s->ops->set_socket(s, &s->socket))
                return CS_BAD_VPP;
 
@@ -643,7 +655,7 @@ int pcmcia_request_configuration(struct pcmcia_device *p_dev,
 
        /* Set up CIS configuration registers */
        base = c->ConfigBase = req->ConfigBase;
-       c->Present = c->CardValues = req->Present;
+       c->CardValues = req->Present;
        if (req->Present & PRESENT_COPY) {
                c->Copy = req->Copy;
                pcmcia_write_cis_mem(s, 1, (base + CISREG_SCR)>>1, 1, &c->Copy);
@@ -690,10 +702,10 @@ int pcmcia_request_configuration(struct pcmcia_device *p_dev,
        if (c->state & CONFIG_IO_REQ) {
                iomap.speed = io_speed;
                for (i = 0; i < MAX_IO_WIN; i++)
-                       if (s->io[i].NumPorts != 0) {
+                       if (s->io[i].res) {
                                iomap.map = i;
                                iomap.flags = MAP_ACTIVE;
-                               switch (s->io[i].Attributes & IO_DATA_PATH_WIDTH) {
+                               switch (s->io[i].res->flags & IO_DATA_PATH_WIDTH) {
                                case IO_DATA_PATH_WIDTH_16:
                                        iomap.flags |= MAP_16BIT; break;
                                case IO_DATA_PATH_WIDTH_AUTO:
@@ -701,15 +713,15 @@ int pcmcia_request_configuration(struct pcmcia_device *p_dev,
                                default:
                                        break;
                                }
-                               iomap.start = s->io[i].BasePort;
-                               iomap.stop = iomap.start + s->io[i].NumPorts - 1;
+                               iomap.start = s->io[i].res->start;
+                               iomap.stop = s->io[i].res->end;
                                s->ops->set_io_map(s, &iomap);
                                s->io[i].Config++;
                        }
        }
 
        c->state |= CONFIG_LOCKED;
-       p_dev->state |= CLIENT_CONFIG_LOCKED;
+       p_dev->_locked = 1;
        return CS_SUCCESS;
 } /* pcmcia_request_configuration */
 EXPORT_SYMBOL(pcmcia_request_configuration);
@@ -730,7 +742,7 @@ int pcmcia_request_io(struct pcmcia_device *p_dev, io_req_t *req)
 
        if (!req)
                return CS_UNSUPPORTED_MODE;
-       c = CONFIG(p_dev);
+       c = p_dev->function_config;
        if (c->state & CONFIG_LOCKED)
                return CS_CONFIGURATION_LOCKED;
        if (c->state & CONFIG_IO_REQ)
@@ -755,7 +767,7 @@ int pcmcia_request_io(struct pcmcia_device *p_dev, io_req_t *req)
 
        c->io = *req;
        c->state |= CONFIG_IO_REQ;
-       p_dev->state |= CLIENT_IO_REQ;
+       p_dev->_io = 1;
        return CS_SUCCESS;
 } /* pcmcia_request_io */
 EXPORT_SYMBOL(pcmcia_request_io);
@@ -772,7 +784,7 @@ EXPORT_SYMBOL(pcmcia_request_io);
  */
 
 #ifdef CONFIG_PCMCIA_PROBE
-static irqreturn_t test_action(int cpl, void *dev_id, struct pt_regs *regs)
+static irqreturn_t test_action(int cpl, void *dev_id)
 {
        return IRQ_NONE;
 }
@@ -783,15 +795,23 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req)
        struct pcmcia_socket *s = p_dev->socket;
        config_t *c;
        int ret = CS_IN_USE, irq = 0;
+       int type;
 
        if (!(s->state & SOCKET_PRESENT))
                return CS_NO_CARD;
-       c = CONFIG(p_dev);
+       c = p_dev->function_config;
        if (c->state & CONFIG_LOCKED)
                return CS_CONFIGURATION_LOCKED;
        if (c->state & CONFIG_IRQ_REQ)
                return CS_IN_USE;
 
+       /* Decide what type of interrupt we are registering */
+       type = 0;
+       if (s->functions > 1)           /* All of this ought to be handled higher up */
+               type = IRQF_SHARED;
+       if (req->Attributes & IRQ_TYPE_DYNAMIC_SHARING)
+               type = IRQF_SHARED;
+
 #ifdef CONFIG_PCMCIA_PROBE
        if (s->irq.AssignedIRQ != 0) {
                /* If the interrupt is already assigned, it must be the same */
@@ -817,9 +837,7 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req)
                         * marked as used by the kernel resource management core */
                        ret = request_irq(irq,
                                          (req->Attributes & IRQ_HANDLE_PRESENT) ? req->Handler : test_action,
-                                         ((req->Attributes & IRQ_TYPE_DYNAMIC_SHARING) ||
-                                          (s->functions > 1) ||
-                                          (irq == s->pci_irq)) ? SA_SHIRQ : 0,
+                                         type,
                                          p_dev->devname,
                                          (req->Attributes & IRQ_HANDLE_PRESENT) ? req->Instance : data);
                        if (!ret) {
@@ -834,24 +852,27 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req)
        if (ret && !s->irq.AssignedIRQ) {
                if (!s->pci_irq)
                        return ret;
+               type = IRQF_SHARED;
                irq = s->pci_irq;
        }
 
-       if (ret && req->Attributes & IRQ_HANDLE_PRESENT) {
-               if (request_irq(irq, req->Handler,
-                               ((req->Attributes & IRQ_TYPE_DYNAMIC_SHARING) ||
-                                (s->functions > 1) ||
-                                (irq == s->pci_irq)) ? SA_SHIRQ : 0,
-                               p_dev->devname, req->Instance))
+       if (ret && (req->Attributes & IRQ_HANDLE_PRESENT)) {
+               if (request_irq(irq, req->Handler, type,  p_dev->devname, req->Instance))
                        return CS_IN_USE;
        }
 
+       /* Make sure the fact the request type was overridden is passed back */
+       if (type == IRQF_SHARED && !(req->Attributes & IRQ_TYPE_DYNAMIC_SHARING)) {
+               req->Attributes |= IRQ_TYPE_DYNAMIC_SHARING;
+               printk(KERN_WARNING "pcmcia: request for exclusive IRQ could not be fulfilled.\n");
+               printk(KERN_WARNING "pcmcia: the driver needs updating to supported shared IRQ lines.\n");
+       }
        c->irq.Attributes = req->Attributes;
        s->irq.AssignedIRQ = req->AssignedIRQ = irq;
        s->irq.Config++;
 
        c->state |= CONFIG_IRQ_REQ;
-       p_dev->state |= CLIENT_IRQ_REQ;
+       p_dev->_irq = 1;
 
 #ifdef CONFIG_PCMCIA_PROBE
        pcmcia_used_irq[irq]++;
@@ -911,7 +932,7 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h
                if (!win->ctl.res)
                        return CS_IN_USE;
        }
-       (*p_dev)->state |= CLIENT_WIN_REQ(w);
+       (*p_dev)->_win |= CLIENT_WIN_REQ(w);
 
        /* Configure the socket controller */
        win->ctl.map = w+1;
@@ -941,3 +962,12 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h
        return CS_SUCCESS;
 } /* pcmcia_request_window */
 EXPORT_SYMBOL(pcmcia_request_window);
+
+void pcmcia_disable_device(struct pcmcia_device *p_dev) {
+       pcmcia_release_configuration(p_dev);
+       pcmcia_release_io(p_dev, &p_dev->io);
+       pcmcia_release_irq(p_dev, &p_dev->irq);
+       if (&p_dev->win)
+               pcmcia_release_window(p_dev->win);
+}
+EXPORT_SYMBOL(pcmcia_disable_device);