@@ -76,7 +76,7 @@ struct pca955x_chipdef {
76
76
int slv_addr_shift ; /* Number of bits to ignore */
77
77
};
78
78
79
- static struct pca955x_chipdef pca955x_chipdefs [] = {
79
+ static const struct pca955x_chipdef pca955x_chipdefs [] = {
80
80
[pca9550 ] = {
81
81
.bits = 2 ,
82
82
.slv_addr = /* 110000x */ 0x60 ,
@@ -105,19 +105,19 @@ static struct pca955x_chipdef pca955x_chipdefs[] = {
105
105
};
106
106
107
107
static const struct i2c_device_id pca955x_id [] = {
108
- { "pca9550" , pca9550 },
109
- { "pca9551" , pca9551 },
110
- { "pca9552" , pca9552 },
111
- { "ibm-pca9552" , ibm_pca9552 },
112
- { "pca9553" , pca9553 },
108
+ { "pca9550" , ( kernel_ulong_t ) & pca955x_chipdefs [ pca9550 ] },
109
+ { "pca9551" , ( kernel_ulong_t ) & pca955x_chipdefs [ pca9551 ] },
110
+ { "pca9552" , ( kernel_ulong_t ) & pca955x_chipdefs [ pca9552 ] },
111
+ { "ibm-pca9552" , ( kernel_ulong_t ) & pca955x_chipdefs [ ibm_pca9552 ] },
112
+ { "pca9553" , ( kernel_ulong_t ) & pca955x_chipdefs [ pca9553 ] },
113
113
{ }
114
114
};
115
115
MODULE_DEVICE_TABLE (i2c , pca955x_id );
116
116
117
117
struct pca955x {
118
118
struct mutex lock ;
119
119
struct pca955x_led * leds ;
120
- struct pca955x_chipdef * chipdef ;
120
+ const struct pca955x_chipdef * chipdef ;
121
121
struct i2c_client * client ;
122
122
unsigned long active_pins ;
123
123
#ifdef CONFIG_LEDS_PCA955X_GPIO
@@ -415,7 +415,7 @@ static int pca955x_gpio_direction_output(struct gpio_chip *gc,
415
415
#endif /* CONFIG_LEDS_PCA955X_GPIO */
416
416
417
417
static struct pca955x_platform_data *
418
- pca955x_get_pdata (struct i2c_client * client , struct pca955x_chipdef * chip )
418
+ pca955x_get_pdata (struct i2c_client * client , const struct pca955x_chipdef * chip )
419
419
{
420
420
struct pca955x_platform_data * pdata ;
421
421
struct pca955x_led * led ;
@@ -458,11 +458,11 @@ pca955x_get_pdata(struct i2c_client *client, struct pca955x_chipdef *chip)
458
458
}
459
459
460
460
static const struct of_device_id of_pca955x_match [] = {
461
- { .compatible = "nxp,pca9550" , .data = ( void * ) pca9550 },
462
- { .compatible = "nxp,pca9551" , .data = ( void * ) pca9551 },
463
- { .compatible = "nxp,pca9552" , .data = ( void * ) pca9552 },
464
- { .compatible = "ibm,pca9552" , .data = ( void * ) ibm_pca9552 },
465
- { .compatible = "nxp,pca9553" , .data = ( void * ) pca9553 },
461
+ { .compatible = "nxp,pca9550" , .data = & pca955x_chipdefs [ pca9550 ] },
462
+ { .compatible = "nxp,pca9551" , .data = & pca955x_chipdefs [ pca9551 ] },
463
+ { .compatible = "nxp,pca9552" , .data = & pca955x_chipdefs [ pca9552 ] },
464
+ { .compatible = "ibm,pca9552" , .data = & pca955x_chipdefs [ ibm_pca9552 ] },
465
+ { .compatible = "nxp,pca9553" , .data = & pca955x_chipdefs [ pca9553 ] },
466
466
{},
467
467
};
468
468
MODULE_DEVICE_TABLE (of , of_pca955x_match );
@@ -471,7 +471,7 @@ static int pca955x_probe(struct i2c_client *client)
471
471
{
472
472
struct pca955x * pca955x ;
473
473
struct pca955x_led * pca955x_led ;
474
- struct pca955x_chipdef * chip ;
474
+ const struct pca955x_chipdef * chip ;
475
475
struct led_classdev * led ;
476
476
struct led_init_data init_data ;
477
477
struct i2c_adapter * adapter ;
@@ -480,24 +480,11 @@ static int pca955x_probe(struct i2c_client *client)
480
480
bool set_default_label = false;
481
481
bool keep_pwm = false;
482
482
char default_label [8 ];
483
- enum pca955x_type chip_type ;
484
- const void * md = device_get_match_data (& client -> dev );
485
-
486
- if (md ) {
487
- chip_type = (enum pca955x_type )(uintptr_t )md ;
488
- } else {
489
- const struct i2c_device_id * id = i2c_match_id (pca955x_id ,
490
- client );
491
-
492
- if (id ) {
493
- chip_type = (enum pca955x_type )id -> driver_data ;
494
- } else {
495
- dev_err (& client -> dev , "unknown chip\n" );
496
- return - ENODEV ;
497
- }
498
- }
499
483
500
- chip = & pca955x_chipdefs [chip_type ];
484
+ chip = i2c_get_match_data (client );
485
+ if (!chip )
486
+ return dev_err_probe (& client -> dev , - ENODEV , "unknown chip\n" );
487
+
501
488
adapter = client -> adapter ;
502
489
pdata = dev_get_platdata (& client -> dev );
503
490
if (!pdata ) {
0 commit comments