Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 84049
b: refs/heads/master
c: f5506a2
h: refs/heads/master
i:
  84047: 9ebf353
v: v3
  • Loading branch information
Michael Loeffler authored and Richard Purdie committed Feb 7, 2008
1 parent 00a5903 commit 1065642
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2b7f1b8c8f4a8991dfeefc31844e15c642b6de2a
refs/heads/master: f5506a2f71ad75d680c81090117ff2f89602f9b9
43 changes: 37 additions & 6 deletions trunk/drivers/leds/leds-wrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,21 @@
#include <linux/scx200_gpio.h>

#define DRVNAME "wrap-led"
#define WRAP_POWER_LED_GPIO 2
#define WRAP_ERROR_LED_GPIO 3
#define WRAP_EXTRA_LED_GPIO 18
#define WRAP_EXTRA_LED_GPIO 18

static struct platform_device *pdev;

static void wrap_power_led_set(struct led_classdev *led_cdev,
enum led_brightness value)
{
if (value)
scx200_gpio_set_low(WRAP_POWER_LED_GPIO);
else
scx200_gpio_set_high(WRAP_POWER_LED_GPIO);
}

static void wrap_error_led_set(struct led_classdev *led_cdev,
enum led_brightness value)
{
Expand All @@ -42,6 +52,11 @@ static void wrap_extra_led_set(struct led_classdev *led_cdev,
scx200_gpio_set_high(WRAP_EXTRA_LED_GPIO);
}

static struct led_classdev wrap_power_led = {
.name = "wrap::power",
.brightness_set = wrap_power_led_set,
};

static struct led_classdev wrap_error_led = {
.name = "wrap::error",
.brightness_set = wrap_error_led_set,
Expand All @@ -56,13 +71,15 @@ static struct led_classdev wrap_extra_led = {
static int wrap_led_suspend(struct platform_device *dev,
pm_message_t state)
{
led_classdev_suspend(&wrap_power_led);
led_classdev_suspend(&wrap_error_led);
led_classdev_suspend(&wrap_extra_led);
return 0;
}

static int wrap_led_resume(struct platform_device *dev)
{
led_classdev_resume(&wrap_power_led);
led_classdev_resume(&wrap_error_led);
led_classdev_resume(&wrap_extra_led);
return 0;
Expand All @@ -76,17 +93,31 @@ static int wrap_led_probe(struct platform_device *pdev)
{
int ret;

ret = led_classdev_register(&pdev->dev, &wrap_power_led);
if (ret < 0)
return ret;

ret = led_classdev_register(&pdev->dev, &wrap_error_led);
if (ret == 0) {
ret = led_classdev_register(&pdev->dev, &wrap_extra_led);
if (ret < 0)
led_classdev_unregister(&wrap_error_led);
}
if (ret < 0)
goto err1;

ret = led_classdev_register(&pdev->dev, &wrap_extra_led);
if (ret < 0)
goto err2;

return ret;

err2:
led_classdev_unregister(&wrap_error_led);
err1:
led_classdev_unregister(&wrap_power_led);

return ret;
}

static int wrap_led_remove(struct platform_device *pdev)
{
led_classdev_unregister(&wrap_power_led);
led_classdev_unregister(&wrap_error_led);
led_classdev_unregister(&wrap_extra_led);
return 0;
Expand Down

0 comments on commit 1065642

Please sign in to comment.