Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 272206
b: refs/heads/master
c: 02c3294
h: refs/heads/master
v: v3
  • Loading branch information
Magnus Damm authored and Linus Torvalds committed Nov 1, 2011
1 parent 76c5335 commit 1bf6768
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 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: 3edc5804b7d27ec48975d7d7acbc0b3e1c62c064
refs/heads/master: 02c3294174e170a47cfd58956a739901160381a8
21 changes: 17 additions & 4 deletions trunk/drivers/leds/leds-renesas-tpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <linux/err.h>
#include <linux/slab.h>
#include <linux/pm_runtime.h>
#include <linux/workqueue.h>

enum r_tpu_pin { R_TPU_PIN_UNUSED, R_TPU_PIN_GPIO, R_TPU_PIN_GPIO_FN };
enum r_tpu_timer { R_TPU_TIMER_UNUSED, R_TPU_TIMER_ON };
Expand All @@ -44,6 +45,8 @@ struct r_tpu_priv {
enum r_tpu_timer timer_state;
unsigned long min_rate;
unsigned int refresh_rate;
struct work_struct work;
enum led_brightness new_brightness;
};

static DEFINE_SPINLOCK(r_tpu_lock);
Expand Down Expand Up @@ -211,22 +214,30 @@ static void r_tpu_set_pin(struct r_tpu_priv *p, enum r_tpu_pin new_state,
p->pin_state = new_state;
}

static void r_tpu_set_brightness(struct led_classdev *ldev,
enum led_brightness brightness)
static void r_tpu_work(struct work_struct *work)
{
struct r_tpu_priv *p = container_of(ldev, struct r_tpu_priv, ldev);
struct r_tpu_priv *p = container_of(work, struct r_tpu_priv, work);
enum led_brightness brightness = p->new_brightness;

r_tpu_disable(p);

/* off and maximum are handled as GPIO pins, in between PWM */
if ((brightness == 0) || (brightness == ldev->max_brightness))
if ((brightness == 0) || (brightness == p->ldev.max_brightness))
r_tpu_set_pin(p, R_TPU_PIN_GPIO, brightness);
else {
r_tpu_set_pin(p, R_TPU_PIN_GPIO_FN, 0);
r_tpu_enable(p, brightness);
}
}

static void r_tpu_set_brightness(struct led_classdev *ldev,
enum led_brightness brightness)
{
struct r_tpu_priv *p = container_of(ldev, struct r_tpu_priv, ldev);
p->new_brightness = brightness;
schedule_work(&p->work);
}

static int __devinit r_tpu_probe(struct platform_device *pdev)
{
struct led_renesas_tpu_config *cfg = pdev->dev.platform_data;
Expand Down Expand Up @@ -274,6 +285,7 @@ static int __devinit r_tpu_probe(struct platform_device *pdev)
r_tpu_set_pin(p, R_TPU_PIN_GPIO, LED_OFF);
platform_set_drvdata(pdev, p);

INIT_WORK(&p->work, r_tpu_work);

p->ldev.name = cfg->name;
p->ldev.brightness = LED_OFF;
Expand Down Expand Up @@ -307,6 +319,7 @@ static int __devexit r_tpu_remove(struct platform_device *pdev)

r_tpu_set_brightness(&p->ldev, LED_OFF);
led_classdev_unregister(&p->ldev);
cancel_work_sync(&p->work);
r_tpu_disable(p);
r_tpu_set_pin(p, R_TPU_PIN_UNUSED, LED_OFF);

Expand Down

0 comments on commit 1bf6768

Please sign in to comment.