]> 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 fd4284ea4a3ed3b74dfb693956275c855c2c25f6..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;
@@ -947,44 +938,11 @@ static void ismt_remove(struct pci_dev *pdev)
        i2c_del_adapter(&priv->adapter);
 }
 
-/**
- * ismt_suspend() - place the device in suspend
- * @pdev: PCI-Express device
- * @mesg: PM message
- */
-#ifdef CONFIG_PM
-static int ismt_suspend(struct pci_dev *pdev, pm_message_t mesg)
-{
-       pci_save_state(pdev);
-       pci_set_power_state(pdev, pci_choose_state(pdev, mesg));
-       return 0;
-}
-
-/**
- * ismt_resume() - PCI resume code
- * @pdev: PCI-Express device
- */
-static int ismt_resume(struct pci_dev *pdev)
-{
-       pci_set_power_state(pdev, PCI_D0);
-       pci_restore_state(pdev);
-       return pci_enable_device(pdev);
-}
-
-#else
-
-#define ismt_suspend NULL
-#define ismt_resume NULL
-
-#endif
-
 static struct pci_driver ismt_driver = {
        .name = "ismt_smbus",
        .id_table = ismt_ids,
        .probe = ismt_probe,
        .remove = ismt_remove,
-       .suspend = ismt_suspend,
-       .resume = ismt_resume,
 };
 
 module_pci_driver(ismt_driver);