]> git.karo-electronics.de Git - linux-beck.git/commitdiff
i2c: Check for ACPI resource conflicts
authorJean Delvare <jdelvare@suse.de>
Mon, 14 Jul 2008 20:38:33 +0000 (22:38 +0200)
committerJean Delvare <khali@mahadeva.delvare>
Mon, 14 Jul 2008 20:38:33 +0000 (22:38 +0200)
Check for ACPI resource conflicts in i2c bus drivers. I've included
all recent SMBus master drivers for PC hardware.

I've voluntarily left out:
* Drivers that don't run on PCs: they can't conflict with ACPI.
* Bit-banged bus device drivers: it's very unlikely that ACPI would
  deal with such buses.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
13 files changed:
drivers/i2c/busses/i2c-ali1535.c
drivers/i2c/busses/i2c-ali1563.c
drivers/i2c/busses/i2c-ali15x3.c
drivers/i2c/busses/i2c-amd756.c
drivers/i2c/busses/i2c-amd8111.c
drivers/i2c/busses/i2c-i801.c
drivers/i2c/busses/i2c-isch.c
drivers/i2c/busses/i2c-nforce2.c
drivers/i2c/busses/i2c-piix4.c
drivers/i2c/busses/i2c-sis5595.c
drivers/i2c/busses/i2c-sis630.c
drivers/i2c/busses/i2c-sis96x.c
drivers/i2c/busses/i2c-viapro.c

index 8d1d90ab3a90343ff8bd0aba92e058c5ad9ee5b0..442d559b1aa9b7e7cebbc1bd69d5884b504f64c0 100644 (file)
@@ -61,6 +61,7 @@
 #include <linux/ioport.h>
 #include <linux/i2c.h>
 #include <linux/init.h>
+#include <linux/acpi.h>
 #include <asm/io.h>
 
 
@@ -159,6 +160,11 @@ static int ali1535_setup(struct pci_dev *dev)
                goto exit;
        }
 
+       retval = acpi_check_region(ali1535_smba, ALI1535_SMB_IOSIZE,
+                                  ali1535_driver.name);
+       if (retval)
+               goto exit;
+
        if (!request_region(ali1535_smba, ALI1535_SMB_IOSIZE,
                            ali1535_driver.name)) {
                dev_err(&dev->dev, "ALI1535_smb region 0x%x already in use!\n",
index 4b55ae19db8d3c43cc85a72dc37504f7d49eebb6..fc3e5b026423d8e7ab752c73a93a2e18d1e975b5 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/i2c.h>
 #include <linux/pci.h>
 #include <linux/init.h>
+#include <linux/acpi.h>
 
 #define ALI1563_MAX_TIMEOUT    500
 #define        ALI1563_SMBBA           0x80
@@ -356,6 +357,10 @@ static int __devinit ali1563_setup(struct pci_dev * dev)
                }
        }
 
+       if (acpi_check_region(ali1563_smba, ALI1563_SMB_IOSIZE,
+                             ali1563_pci_driver.name))
+               goto Err;
+
        if (!request_region(ali1563_smba, ALI1563_SMB_IOSIZE,
                            ali1563_pci_driver.name)) {
                dev_err(&dev->dev, "Could not allocate I/O space at 0x%04x\n",
index e922c3950fcdc4081c26fa3ca122f4465b116ead..a030abd3b32bb1df44b8c41da249f34ef638a404 100644 (file)
@@ -68,6 +68,7 @@
 #include <linux/delay.h>
 #include <linux/i2c.h>
 #include <linux/init.h>
+#include <linux/acpi.h>
 #include <asm/io.h>
 
 /* ALI15X3 SMBus address offsets */
@@ -166,6 +167,10 @@ static int ali15x3_setup(struct pci_dev *ALI15X3_dev)
        if(force_addr)
                ali15x3_smba = force_addr & ~(ALI15X3_SMB_IOSIZE - 1);
 
+       if (acpi_check_region(ali15x3_smba, ALI15X3_SMB_IOSIZE,
+                             ali15x3_driver.name))
+               return -EBUSY;
+
        if (!request_region(ali15x3_smba, ALI15X3_SMB_IOSIZE,
                            ali15x3_driver.name)) {
                dev_err(&ALI15X3_dev->dev,
index bd4f6380fabe61e12827597565199f234d4eeb24..26acc657e5c93b49f3bf228eba55036ea7159051 100644 (file)
@@ -45,6 +45,7 @@
 #include <linux/ioport.h>
 #include <linux/i2c.h>
 #include <linux/init.h>
+#include <linux/acpi.h>
 #include <asm/io.h>
 
 /* AMD756 SMBus address offsets */
@@ -368,6 +369,11 @@ static int __devinit amd756_probe(struct pci_dev *pdev,
                amd756_ioport += SMB_ADDR_OFFSET;
        }
 
+       error = acpi_check_region(amd756_ioport, SMB_IOSIZE,
+                                 amd756_driver.name);
+       if (error)
+               return error;
+
        if (!request_region(amd756_ioport, SMB_IOSIZE, amd756_driver.name)) {
                dev_err(&pdev->dev, "SMB region 0x%x already in use!\n",
                        amd756_ioport);
index 0e18fe8460103e26eaac8bc68d6dbbe873079c77..3972208876b3d6f9671567fc3496eab12254df72 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/init.h>
 #include <linux/i2c.h>
 #include <linux/delay.h>
+#include <linux/acpi.h>
 #include <asm/io.h>
 
 MODULE_LICENSE("GPL");
@@ -374,6 +375,10 @@ static int __devinit amd8111_probe(struct pci_dev *dev,
        smbus->base = pci_resource_start(dev, 0);
        smbus->size = pci_resource_len(dev, 0);
 
+       error = acpi_check_resource_conflict(&dev->resource[0]);
+       if (error)
+               goto out_kfree;
+
        if (!request_region(smbus->base, smbus->size, amd8111_driver.name)) {
                error = -EBUSY;
                goto out_kfree;
index 46aa41f73fdd9e0bb39338be18b3378b8aaf15bd..8d0bc4bfe154a157ea1d1e63e1c425f5fe0d1aa3 100644 (file)
@@ -64,6 +64,7 @@
 #include <linux/ioport.h>
 #include <linux/init.h>
 #include <linux/i2c.h>
+#include <linux/acpi.h>
 #include <asm/io.h>
 
 /* I801 SMBus address offsets */
@@ -624,6 +625,10 @@ static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id
                goto exit;
        }
 
+       err = acpi_check_resource_conflict(&dev->resource[SMBBAR]);
+       if (err)
+               goto exit;
+
        err = pci_request_region(dev, SMBBAR, i801_driver.name);
        if (err) {
                dev_err(&dev->dev, "Failed to request SMBus region "
index 8d648911a7f5d137bf87b806800a03879a98d8ce..b9c01aa90036d49eb30fa841ca0e2924f98ddb82 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/i2c.h>
 #include <linux/init.h>
 #include <linux/io.h>
+#include <linux/acpi.h>
 
 /* SCH SMBus address offsets */
 #define SMBHSTCNT      (0 + sch_smba)
@@ -279,6 +280,8 @@ static int __devinit sch_probe(struct pci_dev *dev,
                dev_err(&dev->dev, "SMBus base address uninitialized!\n");
                return -ENODEV;
        }
+       if (acpi_check_region(sch_smba, SMBIOSIZE, sch_driver.name))
+               return -EBUSY;
        if (!request_region(sch_smba, SMBIOSIZE, sch_driver.name)) {
                dev_err(&dev->dev, "SMBus region 0x%x already in use!\n",
                        sch_smba);
index 2654f20d3a628ed4c8dd14a6910aaef3a0fc4952..3b19bc41a60b4d66f5995ff8082939160341a412 100644 (file)
@@ -51,6 +51,7 @@
 #include <linux/i2c.h>
 #include <linux/delay.h>
 #include <linux/dmi.h>
+#include <linux/acpi.h>
 #include <asm/io.h>
 
 MODULE_LICENSE("GPL");
@@ -343,6 +344,11 @@ static int __devinit nforce2_probe_smb (struct pci_dev *dev, int bar,
                smbus->size = 64;
        }
 
+       error = acpi_check_region(smbus->base, smbus->size,
+                                 nforce2_driver.name);
+       if (error)
+               return -1;
+
        if (!request_region(smbus->base, smbus->size, nforce2_driver.name)) {
                dev_err(&smbus->adapter.dev, "Error requesting region %02x .. %02X for %s\n",
                        smbus->base, smbus->base+smbus->size-1, name);
index 85d69f3e624f2a7faf8116a7e8121f55830d8648..924e84a53488c3aad5dae799fdd74af9c8dbd823 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/i2c.h>
 #include <linux/init.h>
 #include <linux/dmi.h>
+#include <linux/acpi.h>
 #include <asm/io.h>
 
 
@@ -168,6 +169,9 @@ static int __devinit piix4_setup(struct pci_dev *PIIX4_dev,
                }
        }
 
+       if (acpi_check_region(piix4_smba, SMBIOSIZE, piix4_driver.name))
+               return -EBUSY;
+
        if (!request_region(piix4_smba, SMBIOSIZE, piix4_driver.name)) {
                dev_err(&PIIX4_dev->dev, "SMBus region 0x%x already in use!\n",
                        piix4_smba);
index f76944b384f57c279d6dd0ae0ac5370778ee612b..3c8e0e1bd24fd566427a9715bc7abf3baef4db02 100644 (file)
@@ -62,6 +62,7 @@
 #include <linux/ioport.h>
 #include <linux/init.h>
 #include <linux/i2c.h>
+#include <linux/acpi.h>
 #include <asm/io.h>
 
 static int blacklist[] = {
@@ -174,6 +175,11 @@ static int sis5595_setup(struct pci_dev *SIS5595_dev)
 
        /* NB: We grab just the two SMBus registers here, but this may still
         * interfere with ACPI :-(  */
+       retval = acpi_check_region(sis5595_base + SMB_INDEX, 2,
+                                  sis5595_driver.name);
+       if (retval)
+               return retval;
+
        if (!request_region(sis5595_base + SMB_INDEX, 2,
                            sis5595_driver.name)) {
                dev_err(&SIS5595_dev->dev, "SMBus registers 0x%04x-0x%04x already in use!\n",
index eb2b2181fed7e2763531128cabeec4a1960ae422..72c29a650b22c44d7954e5c392bb16b8949ac5d7 100644 (file)
@@ -55,6 +55,7 @@
 #include <linux/ioport.h>
 #include <linux/init.h>
 #include <linux/i2c.h>
+#include <linux/acpi.h>
 #include <asm/io.h>
 
 /* SIS630 SMBus registers */
@@ -437,6 +438,11 @@ static int sis630_setup(struct pci_dev *sis630_dev)
 
        dev_dbg(&sis630_dev->dev, "ACPI base at 0x%04x\n", acpi_base);
 
+       retval = acpi_check_region(acpi_base + SMB_STS, SIS630_SMB_IOREGION,
+                                  sis630_driver.name);
+       if (retval)
+               goto exit;
+
        /* Everything is happy, let's grab the memory and set things up. */
        if (!request_region(acpi_base + SMB_STS, SIS630_SMB_IOREGION,
                            sis630_driver.name)) {
index 413e9e477723dfc53aca0674da678a7d7b096c32..848b37c97f7fbbf314f2e76ca31091c30262b19a 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/ioport.h>
 #include <linux/i2c.h>
 #include <linux/init.h>
+#include <linux/acpi.h>
 #include <asm/io.h>
 
 /* base address register in PCI config space */
@@ -281,6 +282,10 @@ static int __devinit sis96x_probe(struct pci_dev *dev,
        dev_info(&dev->dev, "SiS96x SMBus base address: 0x%04x\n",
                        sis96x_smbus_base);
 
+       retval = acpi_check_resource_conflict(&dev->resource[SIS96x_BAR]);
+       if (retval)
+               return retval;
+
        /* Everything is happy, let's grab the memory and set things up. */
        if (!request_region(sis96x_smbus_base, SMB_IOSIZE,
                            sis96x_driver.name)) {
index 7957ce51589156c4089b8f6a157216fdf1631d44..faef99560f236ba3cc9df46db8058fa40d949965 100644 (file)
@@ -50,6 +50,7 @@
 #include <linux/ioport.h>
 #include <linux/i2c.h>
 #include <linux/init.h>
+#include <linux/acpi.h>
 #include <asm/io.h>
 
 static struct pci_dev *vt596_pdev;
@@ -356,6 +357,10 @@ static int __devinit vt596_probe(struct pci_dev *pdev,
        }
 
 found:
+       error = acpi_check_region(vt596_smba, 8, vt596_driver.name);
+       if (error)
+               return error;
+
        if (!request_region(vt596_smba, 8, vt596_driver.name)) {
                dev_err(&pdev->dev, "SMBus region 0x%x already in use!\n",
                        vt596_smba);