Commit 51fe4d3b authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'leds-fixes-for-3.17' of...

Merge branch 'leds-fixes-for-3.17' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds

Pull LED fix from Bryan Wu:
 "Hugh, Jiri and many other people found a kernel oops due to a LED
  change merged recently.  Now the right fix might just revert it and
  avoid the kernel oops"

* 'leds-fixes-for-3.17' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds:
  Revert "leds: convert blink timer to workqueue"
parents 7505ceaf 9067359f
...@@ -15,10 +15,10 @@ ...@@ -15,10 +15,10 @@
#include <linux/list.h> #include <linux/list.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/timer.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/ctype.h> #include <linux/ctype.h>
#include <linux/leds.h> #include <linux/leds.h>
#include <linux/workqueue.h>
#include "leds.h" #include "leds.h"
static struct class *leds_class; static struct class *leds_class;
...@@ -97,10 +97,9 @@ static const struct attribute_group *led_groups[] = { ...@@ -97,10 +97,9 @@ static const struct attribute_group *led_groups[] = {
NULL, NULL,
}; };
static void led_work_function(struct work_struct *ws) static void led_timer_function(unsigned long data)
{ {
struct led_classdev *led_cdev = struct led_classdev *led_cdev = (void *)data;
container_of(ws, struct led_classdev, blink_work.work);
unsigned long brightness; unsigned long brightness;
unsigned long delay; unsigned long delay;
...@@ -144,8 +143,7 @@ static void led_work_function(struct work_struct *ws) ...@@ -144,8 +143,7 @@ static void led_work_function(struct work_struct *ws)
} }
} }
queue_delayed_work(system_wq, &led_cdev->blink_work, mod_timer(&led_cdev->blink_timer, jiffies + msecs_to_jiffies(delay));
msecs_to_jiffies(delay));
} }
static void set_brightness_delayed(struct work_struct *ws) static void set_brightness_delayed(struct work_struct *ws)
...@@ -233,7 +231,9 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev) ...@@ -233,7 +231,9 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
INIT_WORK(&led_cdev->set_brightness_work, set_brightness_delayed); INIT_WORK(&led_cdev->set_brightness_work, set_brightness_delayed);
INIT_DELAYED_WORK(&led_cdev->blink_work, led_work_function); init_timer(&led_cdev->blink_timer);
led_cdev->blink_timer.function = led_timer_function;
led_cdev->blink_timer.data = (unsigned long)led_cdev;
#ifdef CONFIG_LEDS_TRIGGERS #ifdef CONFIG_LEDS_TRIGGERS
led_trigger_set_default(led_cdev); led_trigger_set_default(led_cdev);
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/rwsem.h> #include <linux/rwsem.h>
#include <linux/leds.h> #include <linux/leds.h>
#include <linux/workqueue.h>
#include "leds.h" #include "leds.h"
DECLARE_RWSEM(leds_list_lock); DECLARE_RWSEM(leds_list_lock);
...@@ -52,7 +51,7 @@ static void led_set_software_blink(struct led_classdev *led_cdev, ...@@ -52,7 +51,7 @@ static void led_set_software_blink(struct led_classdev *led_cdev,
return; return;
} }
queue_delayed_work(system_wq, &led_cdev->blink_work, 1); mod_timer(&led_cdev->blink_timer, jiffies + 1);
} }
...@@ -76,7 +75,7 @@ void led_blink_set(struct led_classdev *led_cdev, ...@@ -76,7 +75,7 @@ void led_blink_set(struct led_classdev *led_cdev,
unsigned long *delay_on, unsigned long *delay_on,
unsigned long *delay_off) unsigned long *delay_off)
{ {
cancel_delayed_work_sync(&led_cdev->blink_work); del_timer_sync(&led_cdev->blink_timer);
led_cdev->flags &= ~LED_BLINK_ONESHOT; led_cdev->flags &= ~LED_BLINK_ONESHOT;
led_cdev->flags &= ~LED_BLINK_ONESHOT_STOP; led_cdev->flags &= ~LED_BLINK_ONESHOT_STOP;
...@@ -91,7 +90,7 @@ void led_blink_set_oneshot(struct led_classdev *led_cdev, ...@@ -91,7 +90,7 @@ void led_blink_set_oneshot(struct led_classdev *led_cdev,
int invert) int invert)
{ {
if ((led_cdev->flags & LED_BLINK_ONESHOT) && if ((led_cdev->flags & LED_BLINK_ONESHOT) &&
delayed_work_pending(&led_cdev->blink_work)) timer_pending(&led_cdev->blink_timer))
return; return;
led_cdev->flags |= LED_BLINK_ONESHOT; led_cdev->flags |= LED_BLINK_ONESHOT;
...@@ -108,7 +107,7 @@ EXPORT_SYMBOL(led_blink_set_oneshot); ...@@ -108,7 +107,7 @@ EXPORT_SYMBOL(led_blink_set_oneshot);
void led_stop_software_blink(struct led_classdev *led_cdev) void led_stop_software_blink(struct led_classdev *led_cdev)
{ {
cancel_delayed_work_sync(&led_cdev->blink_work); del_timer_sync(&led_cdev->blink_timer);
led_cdev->blink_delay_on = 0; led_cdev->blink_delay_on = 0;
led_cdev->blink_delay_off = 0; led_cdev->blink_delay_off = 0;
} }
...@@ -117,7 +116,7 @@ EXPORT_SYMBOL_GPL(led_stop_software_blink); ...@@ -117,7 +116,7 @@ EXPORT_SYMBOL_GPL(led_stop_software_blink);
void led_set_brightness(struct led_classdev *led_cdev, void led_set_brightness(struct led_classdev *led_cdev,
enum led_brightness brightness) enum led_brightness brightness)
{ {
/* delay brightness setting if need to stop soft-blink work */ /* delay brightness setting if need to stop soft-blink timer */
if (led_cdev->blink_delay_on || led_cdev->blink_delay_off) { if (led_cdev->blink_delay_on || led_cdev->blink_delay_off) {
led_cdev->delayed_set_value = brightness; led_cdev->delayed_set_value = brightness;
schedule_work(&led_cdev->set_brightness_work); schedule_work(&led_cdev->set_brightness_work);
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/list.h> #include <linux/list.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/rwsem.h> #include <linux/rwsem.h>
#include <linux/timer.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
struct device; struct device;
...@@ -68,7 +69,7 @@ struct led_classdev { ...@@ -68,7 +69,7 @@ struct led_classdev {
const char *default_trigger; /* Trigger to use */ const char *default_trigger; /* Trigger to use */
unsigned long blink_delay_on, blink_delay_off; unsigned long blink_delay_on, blink_delay_off;
struct delayed_work blink_work; struct timer_list blink_timer;
int blink_brightness; int blink_brightness;
struct work_struct set_brightness_work; struct work_struct set_brightness_work;
......
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