leds: lp55xx: Convert LED class registration to devm_*
authorDan Murphy <dmurphy@ti.com>
Thu, 16 Jul 2020 18:20:00 +0000 (13:20 -0500)
committerPavel Machek <pavel@ucw.cz>
Wed, 22 Jul 2020 12:42:06 +0000 (14:42 +0200)
Convert the LED class registration calls to the LED devm_*
registration calls.

Acked-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Dan Murphy <dmurphy@ti.com>
Signed-off-by: Pavel Machek <pavel@ucw.cz>
drivers/leds/leds-lp5521.c
drivers/leds/leds-lp5523.c
drivers/leds/leds-lp5562.c
drivers/leds/leds-lp55xx-common.c
drivers/leds/leds-lp55xx-common.h
drivers/leds/leds-lp8501.c

index 6f02722..6d2163c 100644 (file)
@@ -541,19 +541,17 @@ static int lp5521_probe(struct i2c_client *client,
 
        ret = lp55xx_register_leds(led, chip);
        if (ret)
-               goto err_register_leds;
+               goto err_out;
 
        ret = lp55xx_register_sysfs(chip);
        if (ret) {
                dev_err(&client->dev, "registering sysfs failed\n");
-               goto err_register_sysfs;
+               goto err_out;
        }
 
        return 0;
 
-err_register_sysfs:
-       lp55xx_unregister_leds(led, chip);
-err_register_leds:
+err_out:
        lp55xx_deinit_device(chip);
 err_init:
        return ret;
@@ -566,7 +564,6 @@ static int lp5521_remove(struct i2c_client *client)
 
        lp5521_stop_all_engines(chip);
        lp55xx_unregister_sysfs(chip);
-       lp55xx_unregister_leds(led, chip);
        lp55xx_deinit_device(chip);
 
        return 0;
index 8518de9..cb550cf 100644 (file)
@@ -909,19 +909,17 @@ static int lp5523_probe(struct i2c_client *client,
 
        ret = lp55xx_register_leds(led, chip);
        if (ret)
-               goto err_register_leds;
+               goto err_out;
 
        ret = lp55xx_register_sysfs(chip);
        if (ret) {
                dev_err(&client->dev, "registering sysfs failed\n");
-               goto err_register_sysfs;
+               goto err_out;
        }
 
        return 0;
 
-err_register_sysfs:
-       lp55xx_unregister_leds(led, chip);
-err_register_leds:
+err_out:
        lp55xx_deinit_device(chip);
 err_init:
        return ret;
@@ -934,7 +932,6 @@ static int lp5523_remove(struct i2c_client *client)
 
        lp5523_stop_all_engines(chip);
        lp55xx_unregister_sysfs(chip);
-       lp55xx_unregister_leds(led, chip);
        lp55xx_deinit_device(chip);
 
        return 0;
index edb57c4..1c94422 100644 (file)
@@ -554,19 +554,17 @@ static int lp5562_probe(struct i2c_client *client,
 
        ret = lp55xx_register_leds(led, chip);
        if (ret)
-               goto err_register_leds;
+               goto err_out;
 
        ret = lp55xx_register_sysfs(chip);
        if (ret) {
                dev_err(&client->dev, "registering sysfs failed\n");
-               goto err_register_sysfs;
+               goto err_out;
        }
 
        return 0;
 
-err_register_sysfs:
-       lp55xx_unregister_leds(led, chip);
-err_register_leds:
+err_out:
        lp55xx_deinit_device(chip);
 err_init:
        return ret;
@@ -580,7 +578,6 @@ static int lp5562_remove(struct i2c_client *client)
        lp5562_stop_engine(chip);
 
        lp55xx_unregister_sysfs(chip);
-       lp55xx_unregister_leds(led, chip);
        lp55xx_deinit_device(chip);
 
        return 0;
index 3d0bc4d..243c749 100644 (file)
@@ -179,7 +179,7 @@ static int lp55xx_init_led(struct lp55xx_led *led,
                led->cdev.name = name;
        }
 
-       ret = led_classdev_register(dev, &led->cdev);
+       ret = devm_led_classdev_register(dev, &led->cdev);
        if (ret) {
                dev_err(dev, "led register err: %d\n", ret);
                return ret;
@@ -480,23 +480,10 @@ int lp55xx_register_leds(struct lp55xx_led *led, struct lp55xx_chip *chip)
        return 0;
 
 err_init_led:
-       lp55xx_unregister_leds(led, chip);
        return ret;
 }
 EXPORT_SYMBOL_GPL(lp55xx_register_leds);
 
-void lp55xx_unregister_leds(struct lp55xx_led *led, struct lp55xx_chip *chip)
-{
-       int i;
-       struct lp55xx_led *each;
-
-       for (i = 0; i < chip->num_leds; i++) {
-               each = led + i;
-               led_classdev_unregister(&each->cdev);
-       }
-}
-EXPORT_SYMBOL_GPL(lp55xx_unregister_leds);
-
 int lp55xx_register_sysfs(struct lp55xx_chip *chip)
 {
        struct device *dev = &chip->cl->dev;
index 783ed51..b9b1041 100644 (file)
@@ -189,8 +189,6 @@ extern void lp55xx_deinit_device(struct lp55xx_chip *chip);
 /* common LED class device functions */
 extern int lp55xx_register_leds(struct lp55xx_led *led,
                                struct lp55xx_chip *chip);
-extern void lp55xx_unregister_leds(struct lp55xx_led *led,
-                               struct lp55xx_chip *chip);
 
 /* common device attributes functions */
 extern int lp55xx_register_sysfs(struct lp55xx_chip *chip);
index 2638dbf..a58019c 100644 (file)
@@ -344,19 +344,17 @@ static int lp8501_probe(struct i2c_client *client,
 
        ret = lp55xx_register_leds(led, chip);
        if (ret)
-               goto err_register_leds;
+               goto err_out;
 
        ret = lp55xx_register_sysfs(chip);
        if (ret) {
                dev_err(&client->dev, "registering sysfs failed\n");
-               goto err_register_sysfs;
+               goto err_out;
        }
 
        return 0;
 
-err_register_sysfs:
-       lp55xx_unregister_leds(led, chip);
-err_register_leds:
+err_out:
        lp55xx_deinit_device(chip);
 err_init:
        return ret;
@@ -369,7 +367,6 @@ static int lp8501_remove(struct i2c_client *client)
 
        lp8501_stop_engine(chip);
        lp55xx_unregister_sysfs(chip);
-       lp55xx_unregister_leds(led, chip);
        lp55xx_deinit_device(chip);
 
        return 0;