mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bryan Wu <bryan.wu@canonical.com>
To: rpurdie@rpsys.net, linux-kernel@vger.kernel.org,
	akpm@linux-foundation.org, linux-leds@vger.kernel.org,
	broonie@opensource.wolfsonmicro.com, fabio.baltieri@gmail.com,
	shuahkhan@gmail.com, raph@8d.com, tpiepho@freescale.com
Subject: [PATCH 2/2] leds-gpio: remove workqueue in .brightness_set()
Date: Fri, 14 Sep 2012 15:53:03 +0800	[thread overview]
Message-ID: <1347609183-26730-3-git-send-email-bryan.wu@canonical.com> (raw)
In-Reply-To: <1347609183-26730-1-git-send-email-bryan.wu@canonical.com>

LED core use workqueue internally now, need to use it in the class driver.

Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
---
 drivers/leds/leds-gpio.c | 43 ++++++-------------------------------------
 1 file changed, 6 insertions(+), 37 deletions(-)

diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index 087d1e6..c89dd15 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -18,36 +18,18 @@
 #include <linux/of_platform.h>
 #include <linux/of_gpio.h>
 #include <linux/slab.h>
-#include <linux/workqueue.h>
 #include <linux/module.h>
 #include <linux/pinctrl/consumer.h>
 
 struct gpio_led_data {
 	struct led_classdev cdev;
 	unsigned gpio;
-	struct work_struct work;
-	u8 new_level;
-	u8 can_sleep;
 	u8 active_low;
 	u8 blinking;
 	int (*platform_gpio_blink_set)(unsigned gpio, int state,
 			unsigned long *delay_on, unsigned long *delay_off);
 };
 
-static void gpio_led_work(struct work_struct *work)
-{
-	struct gpio_led_data	*led_dat =
-		container_of(work, struct gpio_led_data, work);
-
-	if (led_dat->blinking) {
-		led_dat->platform_gpio_blink_set(led_dat->gpio,
-						 led_dat->new_level,
-						 NULL, NULL);
-		led_dat->blinking = 0;
-	} else
-		gpio_set_value_cansleep(led_dat->gpio, led_dat->new_level);
-}
-
 static void gpio_led_set(struct led_classdev *led_cdev,
 	enum led_brightness value)
 {
@@ -63,21 +45,12 @@ static void gpio_led_set(struct led_classdev *led_cdev,
 	if (led_dat->active_low)
 		level = !level;
 
-	/* Setting GPIOs with I2C/etc requires a task context, and we don't
-	 * seem to have a reliable way to know if we're already in one; so
-	 * let's just assume the worst.
-	 */
-	if (led_dat->can_sleep) {
-		led_dat->new_level = level;
-		schedule_work(&led_dat->work);
-	} else {
-		if (led_dat->blinking) {
-			led_dat->platform_gpio_blink_set(led_dat->gpio, level,
-							 NULL, NULL);
-			led_dat->blinking = 0;
-		} else
-			gpio_set_value(led_dat->gpio, level);
-	}
+	if (led_dat->blinking) {
+		led_dat->platform_gpio_blink_set(led_dat->gpio, level,
+				NULL, NULL);
+		led_dat->blinking = 0;
+	} else
+		gpio_set_value(led_dat->gpio, level);
 }
 
 static int gpio_blink_set(struct led_classdev *led_cdev,
@@ -113,7 +86,6 @@ static int __devinit create_gpio_led(const struct gpio_led *template,
 	led_dat->cdev.name = template->name;
 	led_dat->cdev.default_trigger = template->default_trigger;
 	led_dat->gpio = template->gpio;
-	led_dat->can_sleep = gpio_cansleep(template->gpio);
 	led_dat->active_low = template->active_low;
 	led_dat->blinking = 0;
 	if (blink_set) {
@@ -133,8 +105,6 @@ static int __devinit create_gpio_led(const struct gpio_led *template,
 	if (ret < 0)
 		goto err;
 		
-	INIT_WORK(&led_dat->work, gpio_led_work);
-
 	ret = led_classdev_register(parent, &led_dat->cdev);
 	if (ret < 0)
 		goto err;
@@ -150,7 +120,6 @@ static void delete_gpio_led(struct gpio_led_data *led)
 	if (!gpio_is_valid(led->gpio))
 		return;
 	led_classdev_unregister(&led->cdev);
-	cancel_work_sync(&led->work);
 	gpio_free(led->gpio);
 }
 
-- 
1.7.11.4


      parent reply	other threads:[~2012-09-14  7:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-14  7:53 [RFC] [PATCH 0/2] leds: use workqueue in led_set_brightness() API internally Bryan Wu
2012-09-14  7:53 ` [PATCH 1/2] " Bryan Wu
2012-09-14 22:25   ` Shuah Khan
2012-09-15 15:23   ` Fabio Baltieri
2012-09-14  7:53 ` Bryan Wu [this message]

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=1347609183-26730-3-git-send-email-bryan.wu@canonical.com \
    --to=bryan.wu@canonical.com \
    --cc=akpm@linux-foundation.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=fabio.baltieri@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=raph@8d.com \
    --cc=rpurdie@rpsys.net \
    --cc=shuahkhan@gmail.com \
    --cc=tpiepho@freescale.com \
    /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

all inboxes | Powered by JetHome®