leds: lp8860: Various fixes to align with LED framework
authorDan Murphy <dmurphy@ti.com>
Mon, 18 Dec 2017 20:23:07 +0000 (14:23 -0600)
committerJacek Anaszewski <jacek.anaszewski@gmail.com>
Mon, 8 Jan 2018 20:28:12 +0000 (21:28 +0100)
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>
drivers/leds/Kconfig
drivers/leds/leds-lp8860.c

index 1d215b3..3e763d2 100644 (file)
@@ -354,7 +354,7 @@ config LEDS_LP8788
 
 config LEDS_LP8860
        tristate "LED support for the TI LP8860 4 channel LED driver"
-       depends on LEDS_CLASS && I2C
+       depends on LEDS_CLASS && I2C && OF
        select REGMAP_I2C
        help
          If you say yes here you get support for the TI LP8860 4 channel
index 94b996b..39c72a9 100644 (file)
@@ -421,7 +421,6 @@ static int lp8860_probe(struct i2c_client *client,
 
        led->client = client;
        led->led_dev.name = led->label;
-       led->led_dev.max_brightness = LED_FULL;
        led->led_dev.brightness_set_blocking = lp8860_brightness_set;
 
        mutex_init(&led->lock);
@@ -448,7 +447,7 @@ static int lp8860_probe(struct i2c_client *client,
        if (ret)
                return ret;
 
-       ret = led_classdev_register(&client->dev, &led->led_dev);
+       ret = devm_led_classdev_register(&client->dev, &led->led_dev);
        if (ret) {
                dev_err(&client->dev, "led register err: %d\n", ret);
                return ret;
@@ -462,8 +461,6 @@ static int lp8860_remove(struct i2c_client *client)
        struct lp8860_led *led = i2c_get_clientdata(client);
        int ret;
 
-       led_classdev_unregister(&led->led_dev);
-
        if (led->enable_gpio)
                gpiod_direction_output(led->enable_gpio, 0);
 
@@ -474,6 +471,8 @@ static int lp8860_remove(struct i2c_client *client)
                                "Failed to disable regulator\n");
        }
 
+       mutex_destroy(&led->lock);
+
        return 0;
 }
 
@@ -483,18 +482,16 @@ static const struct i2c_device_id lp8860_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, lp8860_id);
 
-#ifdef CONFIG_OF
 static const struct of_device_id of_lp8860_leds_match[] = {
        { .compatible = "ti,lp8860", },
        {},
 };
 MODULE_DEVICE_TABLE(of, of_lp8860_leds_match);
-#endif
 
 static struct i2c_driver lp8860_driver = {
        .driver = {
                .name   = "lp8860",
-               .of_match_table = of_match_ptr(of_lp8860_leds_match),
+               .of_match_table = of_lp8860_leds_match,
        },
        .probe          = lp8860_probe,
        .remove         = lp8860_remove,
@@ -504,4 +501,4 @@ module_i2c_driver(lp8860_driver);
 
 MODULE_DESCRIPTION("Texas Instruments LP8860 LED driver");
 MODULE_AUTHOR("Dan Murphy <dmurphy@ti.com>");
-MODULE_LICENSE("GPL");
+MODULE_LICENSE("GPL v2");