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
4649static 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
101105static 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
520524static 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 */
584587static 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