Commit 02c32941 authored by Magnus Damm's avatar Magnus Damm Committed by Linus Torvalds

drivers/leds/leds-renesas-tpu.c: update driver to use workqueue

Use a workqueue in the Renesas TPU LED driver to allow the Runtime PM code
to sleep.
Signed-off-by: default avatarMagnus Damm <damm@opensource.se>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 3edc5804
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <linux/err.h> #include <linux/err.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/pm_runtime.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_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 }; enum r_tpu_timer { R_TPU_TIMER_UNUSED, R_TPU_TIMER_ON };
...@@ -44,6 +45,8 @@ struct r_tpu_priv { ...@@ -44,6 +45,8 @@ struct r_tpu_priv {
enum r_tpu_timer timer_state; enum r_tpu_timer timer_state;
unsigned long min_rate; unsigned long min_rate;
unsigned int refresh_rate; unsigned int refresh_rate;
struct work_struct work;
enum led_brightness new_brightness;
}; };
static DEFINE_SPINLOCK(r_tpu_lock); static DEFINE_SPINLOCK(r_tpu_lock);
...@@ -211,15 +214,15 @@ static void r_tpu_set_pin(struct r_tpu_priv *p, enum r_tpu_pin new_state, ...@@ -211,15 +214,15 @@ static void r_tpu_set_pin(struct r_tpu_priv *p, enum r_tpu_pin new_state,
p->pin_state = new_state; p->pin_state = new_state;
} }
static void r_tpu_set_brightness(struct led_classdev *ldev, static void r_tpu_work(struct work_struct *work)
enum led_brightness brightness)
{ {
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); r_tpu_disable(p);
/* off and maximum are handled as GPIO pins, in between PWM */ /* 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); r_tpu_set_pin(p, R_TPU_PIN_GPIO, brightness);
else { else {
r_tpu_set_pin(p, R_TPU_PIN_GPIO_FN, 0); r_tpu_set_pin(p, R_TPU_PIN_GPIO_FN, 0);
...@@ -227,6 +230,14 @@ static void r_tpu_set_brightness(struct led_classdev *ldev, ...@@ -227,6 +230,14 @@ static void r_tpu_set_brightness(struct led_classdev *ldev,
} }
} }
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) static int __devinit r_tpu_probe(struct platform_device *pdev)
{ {
struct led_renesas_tpu_config *cfg = pdev->dev.platform_data; struct led_renesas_tpu_config *cfg = pdev->dev.platform_data;
...@@ -274,6 +285,7 @@ static int __devinit r_tpu_probe(struct platform_device *pdev) ...@@ -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); r_tpu_set_pin(p, R_TPU_PIN_GPIO, LED_OFF);
platform_set_drvdata(pdev, p); platform_set_drvdata(pdev, p);
INIT_WORK(&p->work, r_tpu_work);
p->ldev.name = cfg->name; p->ldev.name = cfg->name;
p->ldev.brightness = LED_OFF; p->ldev.brightness = LED_OFF;
...@@ -307,6 +319,7 @@ static int __devexit r_tpu_remove(struct platform_device *pdev) ...@@ -307,6 +319,7 @@ static int __devexit r_tpu_remove(struct platform_device *pdev)
r_tpu_set_brightness(&p->ldev, LED_OFF); r_tpu_set_brightness(&p->ldev, LED_OFF);
led_classdev_unregister(&p->ldev); led_classdev_unregister(&p->ldev);
cancel_work_sync(&p->work);
r_tpu_disable(p); r_tpu_disable(p);
r_tpu_set_pin(p, R_TPU_PIN_UNUSED, LED_OFF); r_tpu_set_pin(p, R_TPU_PIN_UNUSED, LED_OFF);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment