aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Loeffler <zvpunry@zvpunry.de>2008-01-13 18:20:52 -0500
committerRichard Purdie <rpurdie@rpsys.net>2008-02-07 04:52:03 -0500
commitf5506a2f71ad75d680c81090117ff2f89602f9b9 (patch)
treeccdd80a2afeba70af9bb831c5d591ec3c0ca155c
parent2b7f1b8c8f4a8991dfeefc31844e15c642b6de2a (diff)
leds: Add power LED to the wrap driver
The 3rd LED on this board is something like a power-led, it is on all the time. With this change to the leds-wrap driver it is possible to use this LED too. Signed-off-by: Michael Loeffler <zvpunry@zvpunry.de> Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
-rw-r--r--drivers/leds/leds-wrap.c43
1 files changed, 37 insertions, 6 deletions
diff --git a/drivers/leds/leds-wrap.c b/drivers/leds/leds-wrap.c
index 5770cc36ec20..7ac61a7b56ad 100644
--- a/drivers/leds/leds-wrap.c
+++ b/drivers/leds/leds-wrap.c
@@ -19,11 +19,21 @@
19#include <linux/scx200_gpio.h> 19#include <linux/scx200_gpio.h>
20 20
21#define DRVNAME "wrap-led" 21#define DRVNAME "wrap-led"
22#define WRAP_POWER_LED_GPIO 2
22#define WRAP_ERROR_LED_GPIO 3 23#define WRAP_ERROR_LED_GPIO 3
23#define WRAP_EXTRA_LED_GPIO 18 24#define WRAP_EXTRA_LED_GPIO 18
24 25
25static struct platform_device *pdev; 26static struct platform_device *pdev;
26 27
28static void wrap_power_led_set(struct led_classdev *led_cdev,
29 enum led_brightness value)
30{
31 if (value)
32 scx200_gpio_set_low(WRAP_POWER_LED_GPIO);
33 else
34 scx200_gpio_set_high(WRAP_POWER_LED_GPIO);
35}
36
27static void wrap_error_led_set(struct led_classdev *led_cdev, 37static void wrap_error_led_set(struct led_classdev *led_cdev,
28 enum led_brightness value) 38 enum led_brightness value)
29{ 39{
@@ -42,6 +52,11 @@ static void wrap_extra_led_set(struct led_classdev *led_cdev,
42 scx200_gpio_set_high(WRAP_EXTRA_LED_GPIO); 52 scx200_gpio_set_high(WRAP_EXTRA_LED_GPIO);
43} 53}
44 54
55static struct led_classdev wrap_power_led = {
56 .name = "wrap::power",
57 .brightness_set = wrap_power_led_set,
58};
59
45static struct led_classdev wrap_error_led = { 60static struct led_classdev wrap_error_led = {
46 .name = "wrap::error", 61 .name = "wrap::error",
47 .brightness_set = wrap_error_led_set, 62 .brightness_set = wrap_error_led_set,
@@ -56,6 +71,7 @@ static struct led_classdev wrap_extra_led = {
56static int wrap_led_suspend(struct platform_device *dev, 71static int wrap_led_suspend(struct platform_device *dev,
57 pm_message_t state) 72 pm_message_t state)
58{ 73{
74 led_classdev_suspend(&wrap_power_led);
59 led_classdev_suspend(&wrap_error_led); 75 led_classdev_suspend(&wrap_error_led);
60 led_classdev_suspend(&wrap_extra_led); 76 led_classdev_suspend(&wrap_extra_led);
61 return 0; 77 return 0;
@@ -63,6 +79,7 @@ static int wrap_led_suspend(struct platform_device *dev,
63 79
64static int wrap_led_resume(struct platform_device *dev) 80static int wrap_led_resume(struct platform_device *dev)
65{ 81{
82 led_classdev_resume(&wrap_power_led);
66 led_classdev_resume(&wrap_error_led); 83 led_classdev_resume(&wrap_error_led);
67 led_classdev_resume(&wrap_extra_led); 84 led_classdev_resume(&wrap_extra_led);
68 return 0; 85 return 0;
@@ -76,17 +93,31 @@ static int wrap_led_probe(struct platform_device *pdev)
76{ 93{
77 int ret; 94 int ret;
78 95
96 ret = led_classdev_register(&pdev->dev, &wrap_power_led);
97 if (ret < 0)
98 return ret;
99
79 ret = led_classdev_register(&pdev->dev, &wrap_error_led); 100 ret = led_classdev_register(&pdev->dev, &wrap_error_led);
80 if (ret == 0) { 101 if (ret < 0)
81 ret = led_classdev_register(&pdev->dev, &wrap_extra_led); 102 goto err1;
82 if (ret < 0) 103
83 led_classdev_unregister(&wrap_error_led); 104 ret = led_classdev_register(&pdev->dev, &wrap_extra_led);
84 } 105 if (ret < 0)
106 goto err2;
107
108 return ret;
109
110err2:
111 led_classdev_unregister(&wrap_error_led);
112err1:
113 led_classdev_unregister(&wrap_power_led);
114
85 return ret; 115 return ret;
86} 116}
87 117
88static int wrap_led_remove(struct platform_device *pdev) 118static int wrap_led_remove(struct platform_device *pdev)
89{ 119{
120 led_classdev_unregister(&wrap_power_led);
90 led_classdev_unregister(&wrap_error_led); 121 led_classdev_unregister(&wrap_error_led);
91 led_classdev_unregister(&wrap_extra_led); 122 led_classdev_unregister(&wrap_extra_led);
92 return 0; 123 return 0;