Skip to content

Commit c666414

Browse files
andy-shevLinus Walleij
authored andcommitted
gpio: pca953x: store driver_data for future use
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>
1 parent 8d24026 commit c666414

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

drivers/gpio/gpio-pca953x.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
#define PCA_INT 0x0100
4343
#define PCA953X_TYPE 0x1000
4444
#define PCA957X_TYPE 0x2000
45+
#define PCA_TYPE_MASK 0xF000
46+
47+
#define PCA_CHIP_TYPE(x) ((x) & PCA_TYPE_MASK)
4548

4649
static const struct i2c_device_id pca953x_id[] = {
4750
{ "pca9505", 40 | PCA953X_TYPE | PCA_INT, },
@@ -96,6 +99,7 @@ struct pca953x_chip {
9699
struct gpio_chip gpio_chip;
97100
const char *const *names;
98101
int chip_type;
102+
unsigned long driver_data;
99103
};
100104

101105
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)
518522
}
519523

520524
static int pca953x_irq_setup(struct pca953x_chip *chip,
521-
const struct i2c_device_id *id,
522525
int irq_base)
523526
{
524527
struct i2c_client *client = chip->client;
525528
int ret, i, offset = 0;
526529

527530
if (client->irq && irq_base != -1
528-
&& (id->driver_data & PCA_INT)) {
531+
&& (chip->driver_data & PCA_INT)) {
529532

530533
switch (chip->chip_type) {
531534
case PCA953X_TYPE:
@@ -582,12 +585,11 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
582585

583586
#else /* CONFIG_GPIO_PCA953X_IRQ */
584587
static int pca953x_irq_setup(struct pca953x_chip *chip,
585-
const struct i2c_device_id *id,
586588
int irq_base)
587589
{
588590
struct i2c_client *client = chip->client;
589591

590-
if (irq_base != -1 && (id->driver_data & PCA_INT))
592+
if (irq_base != -1 && (chip->driver_data & PCA_INT))
591593
dev_warn(&client->dev, "interrupt support not compiled in\n");
592594

593595
return 0;
@@ -678,14 +680,15 @@ static int pca953x_probe(struct i2c_client *client,
678680

679681
chip->client = client;
680682

681-
chip->chip_type = id->driver_data & (PCA953X_TYPE | PCA957X_TYPE);
683+
chip->driver_data = id->driver_data;
684+
chip->chip_type = PCA_CHIP_TYPE(chip->driver_data);
682685

683686
mutex_init(&chip->i2c_lock);
684687

685688
/* initialize cached registers from their original values.
686689
* we can't share this chip with another i2c master.
687690
*/
688-
pca953x_setup_gpio(chip, id->driver_data & PCA_GPIO_MASK);
691+
pca953x_setup_gpio(chip, chip->driver_data & PCA_GPIO_MASK);
689692

690693
if (chip->chip_type == PCA953X_TYPE)
691694
ret = device_pca953x_init(chip, invert);
@@ -698,7 +701,7 @@ static int pca953x_probe(struct i2c_client *client,
698701
if (ret)
699702
return ret;
700703

701-
ret = pca953x_irq_setup(chip, id, irq_base);
704+
ret = pca953x_irq_setup(chip, irq_base);
702705
if (ret)
703706
return ret;
704707

0 commit comments

Comments
 (0)