aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/leds/leds-renesas-tpu.c21
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
35enum r_tpu_pin { R_TPU_PIN_UNUSED, R_TPU_PIN_GPIO, R_TPU_PIN_GPIO_FN }; 36enum r_tpu_pin { R_TPU_PIN_UNUSED, R_TPU_PIN_GPIO, R_TPU_PIN_GPIO_FN };
36enum r_tpu_timer { R_TPU_TIMER_UNUSED, R_TPU_TIMER_ON }; 37enum 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
49static DEFINE_SPINLOCK(r_tpu_lock); 52static 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
214static void r_tpu_set_brightness(struct led_classdev *ldev, 217static 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
233static 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
230static int __devinit r_tpu_probe(struct platform_device *pdev) 241static 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