Skip to content

Commit 239f32b

Browse files
Eddie Jamespavelmachek
authored andcommitted
leds: pca955x: Switch to i2c probe_new
The deprecated i2c probe functionality doesn't work with OF compatible strings, as it only checks for the i2c device id. Switch to the new way of probing and grab the match data to select the chip type. Signed-off-by: Eddie James <[email protected]> Signed-off-by: Pavel Machek <[email protected]>
1 parent 7c48159 commit 239f32b

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

drivers/leds/leds-pca955x.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -479,8 +479,7 @@ static const struct of_device_id of_pca955x_match[] = {
479479
};
480480
MODULE_DEVICE_TABLE(of, of_pca955x_match);
481481

482-
static int pca955x_probe(struct i2c_client *client,
483-
const struct i2c_device_id *id)
482+
static int pca955x_probe(struct i2c_client *client)
484483
{
485484
struct pca955x *pca955x;
486485
struct pca955x_led *pca955x_led;
@@ -494,8 +493,24 @@ static int pca955x_probe(struct i2c_client *client,
494493
bool set_default_label = false;
495494
bool keep_pwm = false;
496495
char default_label[8];
496+
enum pca955x_type chip_type;
497+
const void *md = device_get_match_data(&client->dev);
497498

498-
chip = &pca955x_chipdefs[id->driver_data];
499+
if (md) {
500+
chip_type = (enum pca955x_type)md;
501+
} else {
502+
const struct i2c_device_id *id = i2c_match_id(pca955x_id,
503+
client);
504+
505+
if (id) {
506+
chip_type = (enum pca955x_type)id->driver_data;
507+
} else {
508+
dev_err(&client->dev, "unknown chip\n");
509+
return -ENODEV;
510+
}
511+
}
512+
513+
chip = &pca955x_chipdefs[chip_type];
499514
adapter = client->adapter;
500515
pdata = dev_get_platdata(&client->dev);
501516
if (!pdata) {
@@ -670,7 +685,7 @@ static struct i2c_driver pca955x_driver = {
670685
.name = "leds-pca955x",
671686
.of_match_table = of_pca955x_match,
672687
},
673-
.probe = pca955x_probe,
688+
.probe_new = pca955x_probe,
674689
.id_table = pca955x_id,
675690
};
676691

0 commit comments

Comments
 (0)