aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/pending-4.4/085-0003-leds-gpio-switch-to-managed-version-of-led_classdev_.patch
blob: 7aa865aa8360ae53c35cecbb28d199918e331925 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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",