Merge git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial
[pandora-kernel.git] / drivers / pcmcia / pcmcia_resource.c
index 45063b4..3281e51 100644 (file)
@@ -88,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].res->flags = (s->io[0].res->flags & ~IORESOURCE_BITS) | (attr & IORESOURCE_BITS);
                return 0;
        }
        /* Check for an already-allocated window that must conflict with
@@ -209,7 +208,6 @@ int pccard_get_configuration_info(struct pcmcia_socket *s,
        if (!(s->state & SOCKET_PRESENT))
                return CS_NO_CARD;
 
-       config->Function = p_dev->func;
 
 #ifdef CONFIG_CARDBUS
        if (s->state & SOCKET_CARDBUS) {
@@ -223,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].res->start;
-                       config->NumPorts1 = s->io[0].res->end - config->BasePort1 + 1;
+                       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 = (p_dev) ? p_dev->function_config : 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;
@@ -782,6 +788,7 @@ 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;
@@ -791,6 +798,13 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req)
        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 = SA_SHIRQ;
+       if (req->Attributes & IRQ_TYPE_DYNAMIC_SHARING)
+               type = SA_SHIRQ;
+
 #ifdef CONFIG_PCMCIA_PROBE
        if (s->irq.AssignedIRQ != 0) {
                /* If the interrupt is already assigned, it must be the same */
@@ -816,9 +830,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) {
@@ -833,18 +845,21 @@ 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 = SA_SHIRQ;
                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 == SA_SHIRQ && !(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++;
@@ -947,7 +962,5 @@ void pcmcia_disable_device(struct pcmcia_device *p_dev) {
        pcmcia_release_irq(p_dev, &p_dev->irq);
        if (&p_dev->win)
                pcmcia_release_window(p_dev->win);
-
-       p_dev->dev_node = NULL;
 }
 EXPORT_SYMBOL(pcmcia_disable_device);