7aa865aa8360ae53c35cecbb28d199918e331925
[openwrt/staging/wigyori.git] /
1 From bc2c0dd85a0a31505ca2f92bef891ddac9126725 Mon Sep 17 00:00:00 2001
2 From: Heiner Kallweit <hkallweit1@gmail.com>
3 Date: Wed, 14 Sep 2016 20:55:27 +0200
4 Subject: [PATCH] leds: gpio: switch to managed version of
5 led_classdev_register
6
7 Using the managed version of led_classdev_register allows to
8 significantly simplify the code.
9
10 Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
11 Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
12 ---
13 drivers/leds/leds-gpio.c | 23 ++---------------------
14 1 file changed, 2 insertions(+), 21 deletions(-)
15
16 --- a/drivers/leds/leds-gpio.c
17 +++ b/drivers/leds/leds-gpio.c
18 @@ -143,7 +143,7 @@ static int create_gpio_led(const struct
19
20 INIT_WORK(&led_dat->work, gpio_led_work);
21
22 - return led_classdev_register(parent, &led_dat->cdev);
23 + return devm_led_classdev_register(parent, &led_dat->cdev);
24 }
25
26 static void delete_gpio_led(struct gpio_led_data *led)
27 @@ -231,8 +231,6 @@ static struct gpio_leds_priv *gpio_leds_
28 return priv;
29
30 err:
31 - for (count = priv->num_leds - 1; count >= 0; count--)
32 - delete_gpio_led(&priv->leds[count]);
33 return ERR_PTR(ret);
34 }
35
36 @@ -261,12 +259,8 @@ static int gpio_led_probe(struct platfor
37 ret = create_gpio_led(&pdata->leds[i],
38 &priv->leds[i],
39 &pdev->dev, pdata->gpio_blink_set);
40 - if (ret < 0) {
41 - /* On failure: unwind the led creations */
42 - for (i = i - 1; i >= 0; i--)
43 - delete_gpio_led(&priv->leds[i]);
44 + if (ret < 0)
45 return ret;
46 - }
47 }
48 } else {
49 priv = gpio_leds_create(pdev);
50 @@ -279,17 +273,6 @@ static int gpio_led_probe(struct platfor
51 return 0;
52 }
53
54 -static int gpio_led_remove(struct platform_device *pdev)
55 -{
56 - struct gpio_leds_priv *priv = platform_get_drvdata(pdev);
57 - int i;
58 -
59 - for (i = 0; i < priv->num_leds; i++)
60 - delete_gpio_led(&priv->leds[i]);
61 -
62 - return 0;
63 -}
64 -
65 static void gpio_led_shutdown(struct platform_device *pdev)
66 {
67 struct gpio_leds_priv *priv = platform_get_drvdata(pdev);
68 @@ -304,7 +287,6 @@ static void gpio_led_shutdown(struct pla
69
70 static struct platform_driver gpio_led_driver = {
71 .probe = gpio_led_probe,
72 - .remove = gpio_led_remove,
73 .shutdown = gpio_led_shutdown,
74 .driver = {
75 .name = "leds-gpio",