openwrt/target/linux/generic/pending-4.4/085-0003-leds-gpio-switch-t...

76 lines
2.1 KiB
Diff
Raw Normal View History

From bc2c0dd85a0a31505ca2f92bef891ddac9126725 Mon Sep 17 00:00:00 2001
From: Heiner Kallweit <hkallweit1@gmail.com>
Date: Wed, 14 Sep 2016 20:55:27 +0200
Subject: [PATCH] leds: gpio: switch to managed version of
led_classdev_register
Using the managed version of led_classdev_register allows to
significantly simplify the code.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
---
drivers/leds/leds-gpio.c | 23 ++---------------------
1 file changed, 2 insertions(+), 21 deletions(-)
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -143,7 +143,7 @@ static int create_gpio_led(const struct
INIT_WORK(&led_dat->work, gpio_led_work);
- return led_classdev_register(parent, &led_dat->cdev);
+ return devm_led_classdev_register(parent, &led_dat->cdev);
}
static void delete_gpio_led(struct gpio_led_data *led)
@@ -231,8 +231,6 @@ static struct gpio_leds_priv *gpio_leds_
return priv;
err:
- for (count = priv->num_leds - 1; count >= 0; count--)
- delete_gpio_led(&priv->leds[count]);
return ERR_PTR(ret);
}
@@ -261,12 +259,8 @@ static int gpio_led_probe(struct platfor
ret = create_gpio_led(&pdata->leds[i],
&priv->leds[i],
&pdev->dev, pdata->gpio_blink_set);
- if (ret < 0) {
- /* On failure: unwind the led creations */
- for (i = i - 1; i >= 0; i--)
- delete_gpio_led(&priv->leds[i]);
+ if (ret < 0)
return ret;
- }
}
} else {
priv = gpio_leds_create(pdev);
@@ -279,17 +273,6 @@ static int gpio_led_probe(struct platfor
return 0;
}
-static int gpio_led_remove(struct platform_device *pdev)
-{
- struct gpio_leds_priv *priv = platform_get_drvdata(pdev);
- int i;
-
- for (i = 0; i < priv->num_leds; i++)
- delete_gpio_led(&priv->leds[i]);
-
- return 0;
-}
-
static void gpio_led_shutdown(struct platform_device *pdev)
{
struct gpio_leds_priv *priv = platform_get_drvdata(pdev);
@@ -304,7 +287,6 @@ static void gpio_led_shutdown(struct pla
static struct platform_driver gpio_led_driver = {
.probe = gpio_led_probe,
- .remove = gpio_led_remove,
.shutdown = gpio_led_shutdown,
.driver = {
.name = "leds-gpio",