Commit 51fe4d3baeaa976ca71e228f09950a960d4f7430

Authored by Linus Torvalds

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"

Showing 3 changed files Side-by-side Diff

drivers/leds/led-class.c
... ... @@ -15,10 +15,10 @@
15 15 #include <linux/list.h>
16 16 #include <linux/spinlock.h>
17 17 #include <linux/device.h>
  18 +#include <linux/timer.h>
18 19 #include <linux/err.h>
19 20 #include <linux/ctype.h>
20 21 #include <linux/leds.h>
21   -#include <linux/workqueue.h>
22 22 #include "leds.h"
23 23  
24 24 static struct class *leds_class;
25 25  
... ... @@ -97,10 +97,9 @@
97 97 NULL,
98 98 };
99 99  
100   -static void led_work_function(struct work_struct *ws)
  100 +static void led_timer_function(unsigned long data)
101 101 {
102   - struct led_classdev *led_cdev =
103   - container_of(ws, struct led_classdev, blink_work.work);
  102 + struct led_classdev *led_cdev = (void *)data;
104 103 unsigned long brightness;
105 104 unsigned long delay;
106 105  
... ... @@ -144,8 +143,7 @@
144 143 }
145 144 }
146 145  
147   - queue_delayed_work(system_wq, &led_cdev->blink_work,
148   - msecs_to_jiffies(delay));
  146 + mod_timer(&led_cdev->blink_timer, jiffies + msecs_to_jiffies(delay));
149 147 }
150 148  
151 149 static void set_brightness_delayed(struct work_struct *ws)
... ... @@ -233,7 +231,9 @@
233 231  
234 232 INIT_WORK(&led_cdev->set_brightness_work, set_brightness_delayed);
235 233  
236   - INIT_DELAYED_WORK(&led_cdev->blink_work, led_work_function);
  234 + init_timer(&led_cdev->blink_timer);
  235 + led_cdev->blink_timer.function = led_timer_function;
  236 + led_cdev->blink_timer.data = (unsigned long)led_cdev;
237 237  
238 238 #ifdef CONFIG_LEDS_TRIGGERS
239 239 led_trigger_set_default(led_cdev);
drivers/leds/led-core.c
... ... @@ -16,7 +16,6 @@
16 16 #include <linux/module.h>
17 17 #include <linux/rwsem.h>
18 18 #include <linux/leds.h>
19   -#include <linux/workqueue.h>
20 19 #include "leds.h"
21 20  
22 21 DECLARE_RWSEM(leds_list_lock);
... ... @@ -52,7 +51,7 @@
52 51 return;
53 52 }
54 53  
55   - queue_delayed_work(system_wq, &led_cdev->blink_work, 1);
  54 + mod_timer(&led_cdev->blink_timer, jiffies + 1);
56 55 }
57 56  
58 57  
... ... @@ -76,7 +75,7 @@
76 75 unsigned long *delay_on,
77 76 unsigned long *delay_off)
78 77 {
79   - cancel_delayed_work_sync(&led_cdev->blink_work);
  78 + del_timer_sync(&led_cdev->blink_timer);
80 79  
81 80 led_cdev->flags &= ~LED_BLINK_ONESHOT;
82 81 led_cdev->flags &= ~LED_BLINK_ONESHOT_STOP;
... ... @@ -91,7 +90,7 @@
91 90 int invert)
92 91 {
93 92 if ((led_cdev->flags & LED_BLINK_ONESHOT) &&
94   - delayed_work_pending(&led_cdev->blink_work))
  93 + timer_pending(&led_cdev->blink_timer))
95 94 return;
96 95  
97 96 led_cdev->flags |= LED_BLINK_ONESHOT;
... ... @@ -108,7 +107,7 @@
108 107  
109 108 void led_stop_software_blink(struct led_classdev *led_cdev)
110 109 {
111   - cancel_delayed_work_sync(&led_cdev->blink_work);
  110 + del_timer_sync(&led_cdev->blink_timer);
112 111 led_cdev->blink_delay_on = 0;
113 112 led_cdev->blink_delay_off = 0;
114 113 }
... ... @@ -117,7 +116,7 @@
117 116 void led_set_brightness(struct led_classdev *led_cdev,
118 117 enum led_brightness brightness)
119 118 {
120   - /* delay brightness setting if need to stop soft-blink work */
  119 + /* delay brightness setting if need to stop soft-blink timer */
121 120 if (led_cdev->blink_delay_on || led_cdev->blink_delay_off) {
122 121 led_cdev->delayed_set_value = brightness;
123 122 schedule_work(&led_cdev->set_brightness_work);
include/linux/leds.h
... ... @@ -15,6 +15,7 @@
15 15 #include <linux/list.h>
16 16 #include <linux/spinlock.h>
17 17 #include <linux/rwsem.h>
  18 +#include <linux/timer.h>
18 19 #include <linux/workqueue.h>
19 20  
20 21 struct device;
... ... @@ -68,7 +69,7 @@
68 69 const char *default_trigger; /* Trigger to use */
69 70  
70 71 unsigned long blink_delay_on, blink_delay_off;
71   - struct delayed_work blink_work;
  72 + struct timer_list blink_timer;
72 73 int blink_brightness;
73 74  
74 75 struct work_struct set_brightness_work;