From: Magnus Damm <magnus.damm@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: linux-sh@vger.kernel.org, grant.likely@secretlab.ca,
lethal@linux-sh.org, rpurdie@rpsys.net,
Magnus Damm <magnus.damm@gmail.com>,
akpm@linux-foundation.org
Subject: [PATCH] leds: Update Renesas TPU LED driver to use workqueue
Date: Mon, 29 Aug 2011 13:53:28 +0900 [thread overview]
Message-ID: <20110829045328.23173.92976.sendpatchset@rxone.opensource.se> (raw)
From: Magnus Damm <damm@opensource.se>
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>
---
drivers/leds/leds-renesas-tpu.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
--- 0017/drivers/leds/leds-renesas-tpu.c
+++ work/drivers/leds/leds-renesas-tpu.c 2011-08-29 13:40:12.000000000 +0900
@@ -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 };
@@ -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);
@@ -211,15 +214,15 @@ static void r_tpu_set_pin(struct r_tpu_p
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);
@@ -227,6 +230,14 @@ static void r_tpu_set_brightness(struct
}
}
+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;
@@ -274,6 +285,7 @@ static int __devinit r_tpu_probe(struct
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;
@@ -307,6 +319,7 @@ static int __devexit r_tpu_remove(struct
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);
reply other threads:[~2011-08-29 4:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110829045328.23173.92976.sendpatchset@rxone.opensource.se \
--to=magnus.damm@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=grant.likely@secretlab.ca \
--cc=lethal@linux-sh.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=rpurdie@rpsys.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox