diff options
author | Magnus Damm <damm@opensource.se> | 2011-10-31 20:12:06 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-10-31 20:30:55 -0400 |
commit | 02c3294174e170a47cfd58956a739901160381a8 (patch) | |
tree | e0531a64436f9604990585d7ac3a77ae22a4ea46 /drivers/leds | |
parent | 3edc5804b7d27ec48975d7d7acbc0b3e1c62c064 (diff) |
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: Magnus 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: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/leds')
-rw-r--r-- | drivers/leds/leds-renesas-tpu.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/drivers/leds/leds-renesas-tpu.c b/drivers/leds/leds-renesas-tpu.c index d9a7d72a7569..45dbdf58f5ee 100644 --- a/drivers/leds/leds-renesas-tpu.c +++ b/drivers/leds/leds-renesas-tpu.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/err.h> | 31 | #include <linux/err.h> |
32 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
33 | #include <linux/pm_runtime.h> | 33 | #include <linux/pm_runtime.h> |
34 | #include <linux/workqueue.h> | ||
34 | 35 | ||
35 | enum r_tpu_pin { R_TPU_PIN_UNUSED, R_TPU_PIN_GPIO, R_TPU_PIN_GPIO_FN }; | 36 | enum r_tpu_pin { R_TPU_PIN_UNUSED, R_TPU_PIN_GPIO, R_TPU_PIN_GPIO_FN }; |
36 | enum r_tpu_timer { R_TPU_TIMER_UNUSED, R_TPU_TIMER_ON }; | 37 | enum r_tpu_timer { R_TPU_TIMER_UNUSED, R_TPU_TIMER_ON }; |
@@ -44,6 +45,8 @@ struct r_tpu_priv { | |||
44 | enum r_tpu_timer timer_state; | 45 | enum r_tpu_timer timer_state; |
45 | unsigned long min_rate; | 46 | unsigned long min_rate; |
46 | unsigned int refresh_rate; | 47 | unsigned int refresh_rate; |
48 | struct work_struct work; | ||
49 | enum led_brightness new_brightness; | ||
47 | }; | 50 | }; |
48 | 51 | ||
49 | static DEFINE_SPINLOCK(r_tpu_lock); | 52 | 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 | p->pin_state = new_state; | 214 | p->pin_state = new_state; |
212 | } | 215 | } |
213 | 216 | ||
214 | static void r_tpu_set_brightness(struct led_classdev *ldev, | 217 | static void r_tpu_work(struct work_struct *work) |
215 | enum led_brightness brightness) | ||
216 | { | 218 | { |
217 | struct r_tpu_priv *p = container_of(ldev, struct r_tpu_priv, ldev); | 219 | struct r_tpu_priv *p = container_of(work, struct r_tpu_priv, work); |
220 | enum led_brightness brightness = p->new_brightness; | ||
218 | 221 | ||
219 | r_tpu_disable(p); | 222 | r_tpu_disable(p); |
220 | 223 | ||
221 | /* off and maximum are handled as GPIO pins, in between PWM */ | 224 | /* off and maximum are handled as GPIO pins, in between PWM */ |
222 | if ((brightness == 0) || (brightness == ldev->max_brightness)) | 225 | if ((brightness == 0) || (brightness == p->ldev.max_brightness)) |
223 | r_tpu_set_pin(p, R_TPU_PIN_GPIO, brightness); | 226 | r_tpu_set_pin(p, R_TPU_PIN_GPIO, brightness); |
224 | else { | 227 | else { |
225 | r_tpu_set_pin(p, R_TPU_PIN_GPIO_FN, 0); | 228 | 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 | } | 230 | } |
228 | } | 231 | } |
229 | 232 | ||
233 | static void r_tpu_set_brightness(struct led_classdev *ldev, | ||
234 | enum led_brightness brightness) | ||
235 | { | ||
236 | struct r_tpu_priv *p = container_of(ldev, struct r_tpu_priv, ldev); | ||
237 | p->new_brightness = brightness; | ||
238 | schedule_work(&p->work); | ||
239 | } | ||
240 | |||
230 | static int __devinit r_tpu_probe(struct platform_device *pdev) | 241 | static int __devinit r_tpu_probe(struct platform_device *pdev) |
231 | { | 242 | { |
232 | struct led_renesas_tpu_config *cfg = pdev->dev.platform_data; | 243 | 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 | r_tpu_set_pin(p, R_TPU_PIN_GPIO, LED_OFF); | 285 | r_tpu_set_pin(p, R_TPU_PIN_GPIO, LED_OFF); |
275 | platform_set_drvdata(pdev, p); | 286 | platform_set_drvdata(pdev, p); |
276 | 287 | ||
288 | INIT_WORK(&p->work, r_tpu_work); | ||
277 | 289 | ||
278 | p->ldev.name = cfg->name; | 290 | p->ldev.name = cfg->name; |
279 | p->ldev.brightness = LED_OFF; | 291 | p->ldev.brightness = LED_OFF; |
@@ -307,6 +319,7 @@ static int __devexit r_tpu_remove(struct platform_device *pdev) | |||
307 | 319 | ||
308 | r_tpu_set_brightness(&p->ldev, LED_OFF); | 320 | r_tpu_set_brightness(&p->ldev, LED_OFF); |
309 | led_classdev_unregister(&p->ldev); | 321 | led_classdev_unregister(&p->ldev); |
322 | cancel_work_sync(&p->work); | ||
310 | r_tpu_disable(p); | 323 | r_tpu_disable(p); |
311 | r_tpu_set_pin(p, R_TPU_PIN_UNUSED, LED_OFF); | 324 | r_tpu_set_pin(p, R_TPU_PIN_UNUSED, LED_OFF); |
312 | 325 | ||