openwrtv4/target/linux/generic/patches-4.4/085-0003-leds-gpio-switch-to-managed-version-of-led_classdev_.patch
Rafał Miłecki 318f2d6101 kernel: fix of_node handling in LEDs core code
This backports fixes for setting of_node and making it possible to read
extra info from DT. This was partially fixed by:
[PATCH] leds: leds-gpio: Set of_node for created LED devices
but it didn't work during initialization.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
2017-03-08 13:06:16 +01:00

75 lines
2.1 KiB
Diff

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",