]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/i2c/busses/i2c-ismt.c
Merge remote-tracking branch 'i2c/i2c/for-next'
[karo-tx-linux.git] / drivers / i2c / busses / i2c-ismt.c
index 3889e6b4176d3f0e04af8aa7c625134f2cce0458..7ba795b24e75d4d212972ddfa0675d582a9ef671 100644 (file)
@@ -67,7 +67,7 @@
 #include <linux/acpi.h>
 #include <linux/interrupt.h>
 
-#include <asm-generic/io-64-nonatomic-lo-hi.h>
+#include <linux/io-64-nonatomic-lo-hi.h>
 
 /* PCI Address Constants */
 #define SMBBAR         0
@@ -172,7 +172,6 @@ struct ismt_priv {
        u8 head;                                /* ring buffer head pointer */
        struct completion cmp;                  /* interrupt completion */
        u8 dma_buffer[I2C_SMBUS_BLOCK_MAX + 1]; /* temp R/W data buffer */
-       bool using_msi;                         /* type of interrupt flag */
 };
 
 /**
@@ -398,7 +397,7 @@ static int ismt_access(struct i2c_adapter *adap, u16 addr,
        desc->tgtaddr_rw = ISMT_DESC_ADDR_RW(addr, read_write);
 
        /* Initialize common control bits */
-       if (likely(priv->using_msi))
+       if (likely(pci_dev_msi_enabled(priv->pci_dev)))
                desc->control = ISMT_DESC_INT | ISMT_DESC_FAIR;
        else
                desc->control = ISMT_DESC_FAIR;
@@ -789,11 +788,8 @@ static int ismt_int_init(struct ismt_priv *priv)
 
        /* Try using MSI interrupts */
        err = pci_enable_msi(priv->pci_dev);
-       if (err) {
-               dev_warn(&priv->pci_dev->dev,
-                        "Unable to use MSI interrupts, falling back to legacy\n");
+       if (err)
                goto intx;
-       }
 
        err = devm_request_irq(&priv->pci_dev->dev,
                               priv->pci_dev->irq,
@@ -806,11 +802,13 @@ static int ismt_int_init(struct ismt_priv *priv)
                goto intx;
        }
 
-       priv->using_msi = true;
-       goto done;
+       return 0;
 
        /* Try using legacy interrupts */
 intx:
+       dev_warn(&priv->pci_dev->dev,
+                "Unable to use MSI interrupts, falling back to legacy\n");
+
        err = devm_request_irq(&priv->pci_dev->dev,
                               priv->pci_dev->irq,
                               ismt_do_interrupt,
@@ -819,12 +817,9 @@ intx:
                               priv);
        if (err) {
                dev_err(&priv->pci_dev->dev, "no usable interrupts\n");
-               return -ENODEV;
+               return err;
        }
 
-       priv->using_msi = false;
-
-done:
        return 0;
 }
 
@@ -847,17 +842,13 @@ ismt_probe(struct pci_dev *pdev, const struct pci_device_id *id)
                return -ENOMEM;
 
        pci_set_drvdata(pdev, priv);
+
        i2c_set_adapdata(&priv->adapter, priv);
        priv->adapter.owner = THIS_MODULE;
-
        priv->adapter.class = I2C_CLASS_HWMON;
-
        priv->adapter.algo = &smbus_algorithm;
-
-       /* set up the sysfs linkage to our parent device */
        priv->adapter.dev.parent = &pdev->dev;
-
-       /* number of retries on lost arbitration */
+       ACPI_COMPANION_SET(&priv->adapter.dev, ACPI_COMPANION(&pdev->dev));
        priv->adapter.retries = ISMT_MAX_RETRIES;
 
        priv->pci_dev = pdev;