diff options
Diffstat (limited to 'drivers/leds/leds-lp5523.c')
-rw-r--r-- | drivers/leds/leds-lp5523.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c index 229f734040af..3979428f3100 100644 --- a/drivers/leds/leds-lp5523.c +++ b/drivers/leds/leds-lp5523.c | |||
@@ -429,12 +429,20 @@ static int lp5523_probe(struct i2c_client *client, | |||
429 | int ret; | 429 | int ret; |
430 | struct lp55xx_chip *chip; | 430 | struct lp55xx_chip *chip; |
431 | struct lp55xx_led *led; | 431 | struct lp55xx_led *led; |
432 | struct lp55xx_platform_data *pdata = client->dev.platform_data; | 432 | struct lp55xx_platform_data *pdata; |
433 | 433 | struct device_node *np = client->dev.of_node; | |
434 | if (!pdata) { | 434 | |
435 | dev_err(&client->dev, "no platform data\n"); | 435 | if (!client->dev.platform_data) { |
436 | return -EINVAL; | 436 | if (np) { |
437 | ret = lp55xx_of_populate_pdata(&client->dev, np); | ||
438 | if (ret < 0) | ||
439 | return ret; | ||
440 | } else { | ||
441 | dev_err(&client->dev, "no platform data\n"); | ||
442 | return -EINVAL; | ||
443 | } | ||
437 | } | 444 | } |
445 | pdata = client->dev.platform_data; | ||
438 | 446 | ||
439 | chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); | 447 | chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); |
440 | if (!chip) | 448 | if (!chip) |
@@ -500,9 +508,19 @@ static const struct i2c_device_id lp5523_id[] = { | |||
500 | 508 | ||
501 | MODULE_DEVICE_TABLE(i2c, lp5523_id); | 509 | MODULE_DEVICE_TABLE(i2c, lp5523_id); |
502 | 510 | ||
511 | #ifdef CONFIG_OF | ||
512 | static const struct of_device_id of_lp5523_leds_match[] = { | ||
513 | { .compatible = "national,lp5523", }, | ||
514 | {}, | ||
515 | }; | ||
516 | |||
517 | MODULE_DEVICE_TABLE(of, of_lp5523_leds_match); | ||
518 | #endif | ||
519 | |||
503 | static struct i2c_driver lp5523_driver = { | 520 | static struct i2c_driver lp5523_driver = { |
504 | .driver = { | 521 | .driver = { |
505 | .name = "lp5523x", | 522 | .name = "lp5523x", |
523 | .of_match_table = of_match_ptr(of_lp5523_leds_match), | ||
506 | }, | 524 | }, |
507 | .probe = lp5523_probe, | 525 | .probe = lp5523_probe, |
508 | .remove = lp5523_remove, | 526 | .remove = lp5523_remove, |