From cfdc6fa27902cf3bf9756d5a01252c31609987ff Mon Sep 17 00:00:00 2001 From: Yaacov Akiba Slama <ya@slamail.org> Date: Tue, 14 Jan 2003 22:53:08 -0800 Subject: [PATCH] [PATCH] fix cardbus/hotplugging The pci_enable_device() function will fail at least on i386 (see arch/i386/pci/i386.c: pcibios_enable_resource (line 260)) if the resources have not been assigned previously. Hence the ostensible resource collisions. I added a small comment (and modified another) so future janitors won't move pci_enable above pci_assign_resource again. --- drivers/pcmcia/cardbus.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/pcmcia/cardbus.c b/drivers/pcmcia/cardbus.c index 632304a455c5..a823f54bc593 100644 --- a/drivers/pcmcia/cardbus.c +++ b/drivers/pcmcia/cardbus.c @@ -285,25 +285,29 @@ int cb_alloc(socket_info_t * s) dev->dev.dma_mask = &dev->dma_mask; pci_setup_device(dev); - if (pci_enable_device(dev)) - continue; strcpy(dev->dev.bus_id, dev->slot_name); - /* FIXME: Do we need to enable the expansion ROM? */ + /* We need to assign resources for expansion ROM. */ for (r = 0; r < 7; r++) { struct resource *res = dev->resource + r; - if (res->flags) + if (!res->start && res->end) pci_assign_resource(dev, r); } /* Does this function have an interrupt at all? */ pci_readb(dev, PCI_INTERRUPT_PIN, &irq_pin); - if (irq_pin) { + if (irq_pin) dev->irq = irq; - pci_writeb(dev, PCI_INTERRUPT_LINE, irq); - } + + /* pci_enable_device needs to be called after pci_assign_resource */ + /* because it returns an error if (!res->start && res->end). */ + if (pci_enable_device(dev)) + continue; + if (irq_pin) + pci_writeb(dev, PCI_INTERRUPT_LINE, irq); + device_register(&dev->dev); pci_insert_device(dev, bus); } -- 2.30.9