aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Murphy <dmurphy@ti.com>2017-12-18 15:23:07 -0500
committerJacek Anaszewski <jacek.anaszewski@gmail.com>2018-01-08 15:28:12 -0500
commita2169c9b762ac64899b2aefb170ea0e16178afd6 (patch)
tree02f249b0168bf12ebbb6addc79731adfc9cbcb24
parent50aa46c4bd7b79a57766537dfa8e8c4d8b174a3a (diff)
leds: lp8860: Various fixes to align with LED framework
Update the driver to conform with the LED framework: - use devm_led_classdev_register - destroy mutex on exit - remove dependency on CONFIG_OF in the driver and move to the Kconfig - update the MODULE_LICENSE to GPL v2 - remove setting of MAX brightness as the LED framework does this. Signed-off-by: Dan Murphy <dmurphy@ti.com> Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
-rw-r--r--drivers/leds/Kconfig2
-rw-r--r--drivers/leds/leds-lp8860.c13
2 files changed, 6 insertions, 9 deletions
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 1d215b39cefd..3e763d2a0cb3 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -354,7 +354,7 @@ config LEDS_LP8788
354 354
355config LEDS_LP8860 355config LEDS_LP8860
356 tristate "LED support for the TI LP8860 4 channel LED driver" 356 tristate "LED support for the TI LP8860 4 channel LED driver"
357 depends on LEDS_CLASS && I2C 357 depends on LEDS_CLASS && I2C && OF
358 select REGMAP_I2C 358 select REGMAP_I2C
359 help 359 help
360 If you say yes here you get support for the TI LP8860 4 channel 360 If you say yes here you get support for the TI LP8860 4 channel
diff --git a/drivers/leds/leds-lp8860.c b/drivers/leds/leds-lp8860.c
index 94b996b343ce..39c72a908f3b 100644
--- a/drivers/leds/leds-lp8860.c
+++ b/drivers/leds/leds-lp8860.c
@@ -421,7 +421,6 @@ static int lp8860_probe(struct i2c_client *client,
421 421
422 led->client = client; 422 led->client = client;
423 led->led_dev.name = led->label; 423 led->led_dev.name = led->label;
424 led->led_dev.max_brightness = LED_FULL;
425 led->led_dev.brightness_set_blocking = lp8860_brightness_set; 424 led->led_dev.brightness_set_blocking = lp8860_brightness_set;
426 425
427 mutex_init(&led->lock); 426 mutex_init(&led->lock);
@@ -448,7 +447,7 @@ static int lp8860_probe(struct i2c_client *client,
448 if (ret) 447 if (ret)
449 return ret; 448 return ret;
450 449
451 ret = led_classdev_register(&client->dev, &led->led_dev); 450 ret = devm_led_classdev_register(&client->dev, &led->led_dev);
452 if (ret) { 451 if (ret) {
453 dev_err(&client->dev, "led register err: %d\n", ret); 452 dev_err(&client->dev, "led register err: %d\n", ret);
454 return ret; 453 return ret;
@@ -462,8 +461,6 @@ static int lp8860_remove(struct i2c_client *client)
462 struct lp8860_led *led = i2c_get_clientdata(client); 461 struct lp8860_led *led = i2c_get_clientdata(client);
463 int ret; 462 int ret;
464 463
465 led_classdev_unregister(&led->led_dev);
466
467 if (led->enable_gpio) 464 if (led->enable_gpio)
468 gpiod_direction_output(led->enable_gpio, 0); 465 gpiod_direction_output(led->enable_gpio, 0);
469 466
@@ -474,6 +471,8 @@ static int lp8860_remove(struct i2c_client *client)
474 "Failed to disable regulator\n"); 471 "Failed to disable regulator\n");
475 } 472 }
476 473
474 mutex_destroy(&led->lock);
475
477 return 0; 476 return 0;
478} 477}
479 478
@@ -483,18 +482,16 @@ static const struct i2c_device_id lp8860_id[] = {
483}; 482};
484MODULE_DEVICE_TABLE(i2c, lp8860_id); 483MODULE_DEVICE_TABLE(i2c, lp8860_id);
485 484
486#ifdef CONFIG_OF
487static const struct of_device_id of_lp8860_leds_match[] = { 485static const struct of_device_id of_lp8860_leds_match[] = {
488 { .compatible = "ti,lp8860", }, 486 { .compatible = "ti,lp8860", },
489 {}, 487 {},
490}; 488};
491MODULE_DEVICE_TABLE(of, of_lp8860_leds_match); 489MODULE_DEVICE_TABLE(of, of_lp8860_leds_match);
492#endif
493 490
494static struct i2c_driver lp8860_driver = { 491static struct i2c_driver lp8860_driver = {
495 .driver = { 492 .driver = {
496 .name = "lp8860", 493 .name = "lp8860",
497 .of_match_table = of_match_ptr(of_lp8860_leds_match), 494 .of_match_table = of_lp8860_leds_match,
498 }, 495 },
499 .probe = lp8860_probe, 496 .probe = lp8860_probe,
500 .remove = lp8860_remove, 497 .remove = lp8860_remove,
@@ -504,4 +501,4 @@ module_i2c_driver(lp8860_driver);
504 501
505MODULE_DESCRIPTION("Texas Instruments LP8860 LED driver"); 502MODULE_DESCRIPTION("Texas Instruments LP8860 LED driver");
506MODULE_AUTHOR("Dan Murphy <dmurphy@ti.com>"); 503MODULE_AUTHOR("Dan Murphy <dmurphy@ti.com>");
507MODULE_LICENSE("GPL"); 504MODULE_LICENSE("GPL v2");