Skip to content

Commit 66c4113

Browse files
bebarinopavelmachek
authored andcommitted
leds: pca953x: Use of_device_get_match_data()
This driver can use the of_device_get_match_data() API to simplify the code. Replace calls to of_match_device() with this newer API under the assumption that where it is called will be when we know the device is backed by a DT node. This nicely avoids referencing the match table when it is undefined with configurations where CONFIG_OF=n. Cc: Arnd Bergmann <[email protected]> Cc: Geert Uytterhoeven <[email protected]> Cc: Riku Voipio <[email protected]> Cc: Rob Herring <[email protected]> Cc: Frank Rowand <[email protected]> Cc: Jacek Anaszewski <[email protected]> Cc: Pavel Machek <[email protected]> Cc: Dan Murphy <[email protected]> Cc: <[email protected]> Signed-off-by: Stephen Boyd <[email protected]> Signed-off-by: Pavel Machek <[email protected]>
1 parent 9cc93be commit 66c4113

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

drivers/leds/leds-pca9532.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -467,16 +467,11 @@ pca9532_of_populate_pdata(struct device *dev, struct device_node *np)
467467
{
468468
struct pca9532_platform_data *pdata;
469469
struct device_node *child;
470-
const struct of_device_id *match;
471470
int devid, maxleds;
472471
int i = 0;
473472
const char *state;
474473

475-
match = of_match_device(of_pca9532_leds_match, dev);
476-
if (!match)
477-
return ERR_PTR(-ENODEV);
478-
479-
devid = (int)(uintptr_t)match->data;
474+
devid = (int)(uintptr_t)of_device_get_match_data(dev);
480475
maxleds = pca9532_chip_info_tbl[devid].num_leds;
481476

482477
pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
@@ -509,7 +504,6 @@ static int pca9532_probe(struct i2c_client *client,
509504
const struct i2c_device_id *id)
510505
{
511506
int devid;
512-
const struct of_device_id *of_id;
513507
struct pca9532_data *data = i2c_get_clientdata(client);
514508
struct pca9532_platform_data *pca9532_pdata =
515509
dev_get_platdata(&client->dev);
@@ -525,11 +519,7 @@ static int pca9532_probe(struct i2c_client *client,
525519
dev_err(&client->dev, "no platform data\n");
526520
return -EINVAL;
527521
}
528-
of_id = of_match_device(of_pca9532_leds_match,
529-
&client->dev);
530-
if (unlikely(!of_id))
531-
return -EINVAL;
532-
devid = (int)(uintptr_t) of_id->data;
522+
devid = (int)(uintptr_t)of_device_get_match_data(&client->dev);
533523
} else {
534524
devid = id->driver_data;
535525
}

0 commit comments

Comments
 (0)