]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/message/i2o/pci.c
Manual merge with Linus (conflict in drivers/input/misc/wistron_bnts.c)
[linux-2.6-omap-h63xx.git] / drivers / message / i2o / pci.c
index 7a60fd7be8ad4aa3f334a1885e3eaa439305b26a..ee7075fa1ec3e5ad31e5c3de88b295b2dea4663a 100644 (file)
@@ -32,6 +32,8 @@
 #include <linux/i2o.h>
 #include "core.h"
 
+#define OSM_DESCRIPTION        "I2O-subsystem"
+
 /* PCI device id table for all I2O controllers */
 static struct pci_device_id __devinitdata i2o_pci_ids[] = {
        {PCI_DEVICE_CLASS(PCI_CLASS_INTELLIGENT_I2O << 8, 0xffff00)},
@@ -66,6 +68,8 @@ static void i2o_pci_free(struct i2o_controller *c)
 
        if (c->base.virt)
                iounmap(c->base.virt);
+
+       pci_release_regions(c->pdev);
 }
 
 /**
@@ -84,6 +88,11 @@ static int __devinit i2o_pci_alloc(struct i2o_controller *c)
        struct device *dev = &pdev->dev;
        int i;
 
+       if (pci_request_regions(pdev, OSM_DESCRIPTION)) {
+               printk(KERN_ERR "%s: device already claimed\n", c->name);
+               return -ENODEV;
+       }
+
        for (i = 0; i < 6; i++) {
                /* Skip I/O spaces */
                if (!(pci_resource_flags(pdev, i) & IORESOURCE_IO)) {
@@ -138,6 +147,7 @@ static int __devinit i2o_pci_alloc(struct i2o_controller *c)
        c->base.virt = ioremap_nocache(c->base.phys, c->base.len);
        if (!c->base.virt) {
                printk(KERN_ERR "%s: Unable to map controller.\n", c->name);
+               i2o_pci_free(c);
                return -ENOMEM;
        }
 
@@ -293,6 +303,7 @@ static int __devinit i2o_pci_probe(struct pci_dev *pdev,
        struct i2o_controller *c;
        int rc;
        struct pci_dev *i960 = NULL;
+       int pci_dev_busy = 0;
 
        printk(KERN_INFO "i2o: Checking for PCI I2O controllers...\n");
 
@@ -385,6 +396,8 @@ static int __devinit i2o_pci_probe(struct pci_dev *pdev,
        if ((rc = i2o_pci_alloc(c))) {
                printk(KERN_ERR "%s: DMA / IO allocation for I2O controller "
                       " failed\n", c->name);
+               if (rc == -ENODEV)
+                       pci_dev_busy = 1;
                goto free_controller;
        }
 
@@ -411,11 +424,12 @@ static int __devinit i2o_pci_probe(struct pci_dev *pdev,
        i2o_pci_free(c);
 
       free_controller:
-       i2o_iop_free(c);
        put_device(c->device.parent);
+       i2o_iop_free(c);
 
       disable:
-       pci_disable_device(pdev);
+       if (!pci_dev_busy)
+               pci_disable_device(pdev);
 
        return rc;
 }