gpio: pca953x: store driver_data for future use
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Thu, 1 Oct 2015 11:20:27 +0000 (14:20 +0300)
committerLinus Walleij <linus.walleij@linaro.org>
Mon, 5 Oct 2015 08:56:22 +0000 (10:56 +0200)
Instead of using id->driver_data directly we copied it to the internal
structure. This will help to adapt driver for ACPI use.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-pca953x.c

index ae70630868a35cd7e4cce30a0c83bec41aae67e2..27c96cea8a81c406852c484d02fe476b0cecd610 100644 (file)
@@ -42,6 +42,9 @@
 #define PCA_INT                        0x0100
 #define PCA953X_TYPE           0x1000
 #define PCA957X_TYPE           0x2000
+#define PCA_TYPE_MASK          0xF000
+
+#define PCA_CHIP_TYPE(x)       ((x) & PCA_TYPE_MASK)
 
 static const struct i2c_device_id pca953x_id[] = {
        { "pca9505", 40 | PCA953X_TYPE | PCA_INT, },
@@ -96,6 +99,7 @@ struct pca953x_chip {
        struct gpio_chip gpio_chip;
        const char *const *names;
        int     chip_type;
+       unsigned long driver_data;
 };
 
 static inline struct pca953x_chip *to_pca(struct gpio_chip *gc)
@@ -518,14 +522,13 @@ static irqreturn_t pca953x_irq_handler(int irq, void *devid)
 }
 
 static int pca953x_irq_setup(struct pca953x_chip *chip,
-                            const struct i2c_device_id *id,
                             int irq_base)
 {
        struct i2c_client *client = chip->client;
        int ret, i, offset = 0;
 
        if (client->irq && irq_base != -1
-                       && (id->driver_data & PCA_INT)) {
+                       && (chip->driver_data & PCA_INT)) {
 
                switch (chip->chip_type) {
                case PCA953X_TYPE:
@@ -582,12 +585,11 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
 
 #else /* CONFIG_GPIO_PCA953X_IRQ */
 static int pca953x_irq_setup(struct pca953x_chip *chip,
-                            const struct i2c_device_id *id,
                             int irq_base)
 {
        struct i2c_client *client = chip->client;
 
-       if (irq_base != -1 && (id->driver_data & PCA_INT))
+       if (irq_base != -1 && (chip->driver_data & PCA_INT))
                dev_warn(&client->dev, "interrupt support not compiled in\n");
 
        return 0;
@@ -678,14 +680,15 @@ static int pca953x_probe(struct i2c_client *client,
 
        chip->client = client;
 
-       chip->chip_type = id->driver_data & (PCA953X_TYPE | PCA957X_TYPE);
+       chip->driver_data = id->driver_data;
+       chip->chip_type = PCA_CHIP_TYPE(chip->driver_data);
 
        mutex_init(&chip->i2c_lock);
 
        /* initialize cached registers from their original values.
         * we can't share this chip with another i2c master.
         */
-       pca953x_setup_gpio(chip, id->driver_data & PCA_GPIO_MASK);
+       pca953x_setup_gpio(chip, chip->driver_data & PCA_GPIO_MASK);
 
        if (chip->chip_type == PCA953X_TYPE)
                ret = device_pca953x_init(chip, invert);
@@ -698,7 +701,7 @@ static int pca953x_probe(struct i2c_client *client,
        if (ret)
                return ret;
 
-       ret = pca953x_irq_setup(chip, id, irq_base);
+       ret = pca953x_irq_setup(chip, irq_base);
        if (ret)
                return ret;