diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/kmod.c | 16 | ||||
-rw-r--r-- | kernel/kthread.c | 13 | ||||
-rw-r--r-- | kernel/power/poweroff.c | 4 | ||||
-rw-r--r-- | kernel/sys.c | 4 | ||||
-rw-r--r-- | kernel/workqueue.c | 19 |
5 files changed, 30 insertions, 26 deletions
diff --git a/kernel/kmod.c b/kernel/kmod.c index bb4e29d924e4..7dc7a9dad6ac 100644 --- a/kernel/kmod.c +++ b/kernel/kmod.c | |||
@@ -114,6 +114,7 @@ EXPORT_SYMBOL(request_module); | |||
114 | #endif /* CONFIG_KMOD */ | 114 | #endif /* CONFIG_KMOD */ |
115 | 115 | ||
116 | struct subprocess_info { | 116 | struct subprocess_info { |
117 | struct work_struct work; | ||
117 | struct completion *complete; | 118 | struct completion *complete; |
118 | char *path; | 119 | char *path; |
119 | char **argv; | 120 | char **argv; |
@@ -221,9 +222,10 @@ static int wait_for_helper(void *data) | |||
221 | } | 222 | } |
222 | 223 | ||
223 | /* This is run by khelper thread */ | 224 | /* This is run by khelper thread */ |
224 | static void __call_usermodehelper(void *data) | 225 | static void __call_usermodehelper(struct work_struct *work) |
225 | { | 226 | { |
226 | struct subprocess_info *sub_info = data; | 227 | struct subprocess_info *sub_info = |
228 | container_of(work, struct subprocess_info, work); | ||
227 | pid_t pid; | 229 | pid_t pid; |
228 | int wait = sub_info->wait; | 230 | int wait = sub_info->wait; |
229 | 231 | ||
@@ -264,6 +266,8 @@ int call_usermodehelper_keys(char *path, char **argv, char **envp, | |||
264 | { | 266 | { |
265 | DECLARE_COMPLETION_ONSTACK(done); | 267 | DECLARE_COMPLETION_ONSTACK(done); |
266 | struct subprocess_info sub_info = { | 268 | struct subprocess_info sub_info = { |
269 | .work = __WORK_INITIALIZER(sub_info.work, | ||
270 | __call_usermodehelper), | ||
267 | .complete = &done, | 271 | .complete = &done, |
268 | .path = path, | 272 | .path = path, |
269 | .argv = argv, | 273 | .argv = argv, |
@@ -272,7 +276,6 @@ int call_usermodehelper_keys(char *path, char **argv, char **envp, | |||
272 | .wait = wait, | 276 | .wait = wait, |
273 | .retval = 0, | 277 | .retval = 0, |
274 | }; | 278 | }; |
275 | DECLARE_WORK(work, __call_usermodehelper, &sub_info); | ||
276 | 279 | ||
277 | if (!khelper_wq) | 280 | if (!khelper_wq) |
278 | return -EBUSY; | 281 | return -EBUSY; |
@@ -280,7 +283,7 @@ int call_usermodehelper_keys(char *path, char **argv, char **envp, | |||
280 | if (path[0] == '\0') | 283 | if (path[0] == '\0') |
281 | return 0; | 284 | return 0; |
282 | 285 | ||
283 | queue_work(khelper_wq, &work); | 286 | queue_work(khelper_wq, &sub_info.work); |
284 | wait_for_completion(&done); | 287 | wait_for_completion(&done); |
285 | return sub_info.retval; | 288 | return sub_info.retval; |
286 | } | 289 | } |
@@ -291,6 +294,8 @@ int call_usermodehelper_pipe(char *path, char **argv, char **envp, | |||
291 | { | 294 | { |
292 | DECLARE_COMPLETION(done); | 295 | DECLARE_COMPLETION(done); |
293 | struct subprocess_info sub_info = { | 296 | struct subprocess_info sub_info = { |
297 | .work = __WORK_INITIALIZER(sub_info.work, | ||
298 | __call_usermodehelper), | ||
294 | .complete = &done, | 299 | .complete = &done, |
295 | .path = path, | 300 | .path = path, |
296 | .argv = argv, | 301 | .argv = argv, |
@@ -298,7 +303,6 @@ int call_usermodehelper_pipe(char *path, char **argv, char **envp, | |||
298 | .retval = 0, | 303 | .retval = 0, |
299 | }; | 304 | }; |
300 | struct file *f; | 305 | struct file *f; |
301 | DECLARE_WORK(work, __call_usermodehelper, &sub_info); | ||
302 | 306 | ||
303 | if (!khelper_wq) | 307 | if (!khelper_wq) |
304 | return -EBUSY; | 308 | return -EBUSY; |
@@ -318,7 +322,7 @@ int call_usermodehelper_pipe(char *path, char **argv, char **envp, | |||
318 | } | 322 | } |
319 | sub_info.stdin = f; | 323 | sub_info.stdin = f; |
320 | 324 | ||
321 | queue_work(khelper_wq, &work); | 325 | queue_work(khelper_wq, &sub_info.work); |
322 | wait_for_completion(&done); | 326 | wait_for_completion(&done); |
323 | return sub_info.retval; | 327 | return sub_info.retval; |
324 | } | 328 | } |
diff --git a/kernel/kthread.c b/kernel/kthread.c index 4f9c60ef95e8..1db8c72d0d38 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c | |||
@@ -31,6 +31,8 @@ struct kthread_create_info | |||
31 | /* Result passed back to kthread_create() from keventd. */ | 31 | /* Result passed back to kthread_create() from keventd. */ |
32 | struct task_struct *result; | 32 | struct task_struct *result; |
33 | struct completion done; | 33 | struct completion done; |
34 | |||
35 | struct work_struct work; | ||
34 | }; | 36 | }; |
35 | 37 | ||
36 | struct kthread_stop_info | 38 | struct kthread_stop_info |
@@ -111,9 +113,10 @@ static int kthread(void *_create) | |||
111 | } | 113 | } |
112 | 114 | ||
113 | /* We are keventd: create a thread. */ | 115 | /* We are keventd: create a thread. */ |
114 | static void keventd_create_kthread(void *_create) | 116 | static void keventd_create_kthread(struct work_struct *work) |
115 | { | 117 | { |
116 | struct kthread_create_info *create = _create; | 118 | struct kthread_create_info *create = |
119 | container_of(work, struct kthread_create_info, work); | ||
117 | int pid; | 120 | int pid; |
118 | 121 | ||
119 | /* We want our own signal handler (we take no signals by default). */ | 122 | /* We want our own signal handler (we take no signals by default). */ |
@@ -154,20 +157,20 @@ struct task_struct *kthread_create(int (*threadfn)(void *data), | |||
154 | ...) | 157 | ...) |
155 | { | 158 | { |
156 | struct kthread_create_info create; | 159 | struct kthread_create_info create; |
157 | DECLARE_WORK(work, keventd_create_kthread, &create); | ||
158 | 160 | ||
159 | create.threadfn = threadfn; | 161 | create.threadfn = threadfn; |
160 | create.data = data; | 162 | create.data = data; |
161 | init_completion(&create.started); | 163 | init_completion(&create.started); |
162 | init_completion(&create.done); | 164 | init_completion(&create.done); |
165 | INIT_WORK(&create.work, keventd_create_kthread); | ||
163 | 166 | ||
164 | /* | 167 | /* |
165 | * The workqueue needs to start up first: | 168 | * The workqueue needs to start up first: |
166 | */ | 169 | */ |
167 | if (!helper_wq) | 170 | if (!helper_wq) |
168 | work.func(work.data); | 171 | create.work.func(&create.work); |
169 | else { | 172 | else { |
170 | queue_work(helper_wq, &work); | 173 | queue_work(helper_wq, &create.work); |
171 | wait_for_completion(&create.done); | 174 | wait_for_completion(&create.done); |
172 | } | 175 | } |
173 | if (!IS_ERR(create.result)) { | 176 | if (!IS_ERR(create.result)) { |
diff --git a/kernel/power/poweroff.c b/kernel/power/poweroff.c index f1f900ac3164..678ec736076b 100644 --- a/kernel/power/poweroff.c +++ b/kernel/power/poweroff.c | |||
@@ -16,12 +16,12 @@ | |||
16 | * callback we use. | 16 | * callback we use. |
17 | */ | 17 | */ |
18 | 18 | ||
19 | static void do_poweroff(void *dummy) | 19 | static void do_poweroff(struct work_struct *dummy) |
20 | { | 20 | { |
21 | kernel_power_off(); | 21 | kernel_power_off(); |
22 | } | 22 | } |
23 | 23 | ||
24 | static DECLARE_WORK(poweroff_work, do_poweroff, NULL); | 24 | static DECLARE_WORK(poweroff_work, do_poweroff); |
25 | 25 | ||
26 | static void handle_poweroff(int key, struct tty_struct *tty) | 26 | static void handle_poweroff(int key, struct tty_struct *tty) |
27 | { | 27 | { |
diff --git a/kernel/sys.c b/kernel/sys.c index 98489d82801b..c87b461de38d 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
@@ -880,7 +880,7 @@ asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void __user | |||
880 | return 0; | 880 | return 0; |
881 | } | 881 | } |
882 | 882 | ||
883 | static void deferred_cad(void *dummy) | 883 | static void deferred_cad(struct work_struct *dummy) |
884 | { | 884 | { |
885 | kernel_restart(NULL); | 885 | kernel_restart(NULL); |
886 | } | 886 | } |
@@ -892,7 +892,7 @@ static void deferred_cad(void *dummy) | |||
892 | */ | 892 | */ |
893 | void ctrl_alt_del(void) | 893 | void ctrl_alt_del(void) |
894 | { | 894 | { |
895 | static DECLARE_WORK(cad_work, deferred_cad, NULL); | 895 | static DECLARE_WORK(cad_work, deferred_cad); |
896 | 896 | ||
897 | if (C_A_D) | 897 | if (C_A_D) |
898 | schedule_work(&cad_work); | 898 | schedule_work(&cad_work); |
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 967479756511..8d1e7cb8a51a 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c | |||
@@ -241,14 +241,14 @@ static void run_workqueue(struct cpu_workqueue_struct *cwq) | |||
241 | struct work_struct *work = list_entry(cwq->worklist.next, | 241 | struct work_struct *work = list_entry(cwq->worklist.next, |
242 | struct work_struct, entry); | 242 | struct work_struct, entry); |
243 | work_func_t f = work->func; | 243 | work_func_t f = work->func; |
244 | void *data = work->data; | ||
245 | 244 | ||
246 | list_del_init(cwq->worklist.next); | 245 | list_del_init(cwq->worklist.next); |
247 | spin_unlock_irqrestore(&cwq->lock, flags); | 246 | spin_unlock_irqrestore(&cwq->lock, flags); |
248 | 247 | ||
249 | BUG_ON(get_wq_data(work) != cwq); | 248 | BUG_ON(get_wq_data(work) != cwq); |
250 | clear_bit(WORK_STRUCT_PENDING, &work->management); | 249 | if (!test_bit(WORK_STRUCT_NOAUTOREL, &work->management)) |
251 | f(data); | 250 | work_release(work); |
251 | f(work); | ||
252 | 252 | ||
253 | spin_lock_irqsave(&cwq->lock, flags); | 253 | spin_lock_irqsave(&cwq->lock, flags); |
254 | cwq->remove_sequence++; | 254 | cwq->remove_sequence++; |
@@ -527,7 +527,6 @@ EXPORT_SYMBOL(schedule_delayed_work_on); | |||
527 | /** | 527 | /** |
528 | * schedule_on_each_cpu - call a function on each online CPU from keventd | 528 | * schedule_on_each_cpu - call a function on each online CPU from keventd |
529 | * @func: the function to call | 529 | * @func: the function to call |
530 | * @info: a pointer to pass to func() | ||
531 | * | 530 | * |
532 | * Returns zero on success. | 531 | * Returns zero on success. |
533 | * Returns -ve errno on failure. | 532 | * Returns -ve errno on failure. |
@@ -536,7 +535,7 @@ EXPORT_SYMBOL(schedule_delayed_work_on); | |||
536 | * | 535 | * |
537 | * schedule_on_each_cpu() is very slow. | 536 | * schedule_on_each_cpu() is very slow. |
538 | */ | 537 | */ |
539 | int schedule_on_each_cpu(work_func_t func, void *info) | 538 | int schedule_on_each_cpu(work_func_t func) |
540 | { | 539 | { |
541 | int cpu; | 540 | int cpu; |
542 | struct work_struct *works; | 541 | struct work_struct *works; |
@@ -547,7 +546,7 @@ int schedule_on_each_cpu(work_func_t func, void *info) | |||
547 | 546 | ||
548 | mutex_lock(&workqueue_mutex); | 547 | mutex_lock(&workqueue_mutex); |
549 | for_each_online_cpu(cpu) { | 548 | for_each_online_cpu(cpu) { |
550 | INIT_WORK(per_cpu_ptr(works, cpu), func, info); | 549 | INIT_WORK(per_cpu_ptr(works, cpu), func); |
551 | __queue_work(per_cpu_ptr(keventd_wq->cpu_wq, cpu), | 550 | __queue_work(per_cpu_ptr(keventd_wq->cpu_wq, cpu), |
552 | per_cpu_ptr(works, cpu)); | 551 | per_cpu_ptr(works, cpu)); |
553 | } | 552 | } |
@@ -591,7 +590,6 @@ EXPORT_SYMBOL(cancel_rearming_delayed_work); | |||
591 | /** | 590 | /** |
592 | * execute_in_process_context - reliably execute the routine with user context | 591 | * execute_in_process_context - reliably execute the routine with user context |
593 | * @fn: the function to execute | 592 | * @fn: the function to execute |
594 | * @data: data to pass to the function | ||
595 | * @ew: guaranteed storage for the execute work structure (must | 593 | * @ew: guaranteed storage for the execute work structure (must |
596 | * be available when the work executes) | 594 | * be available when the work executes) |
597 | * | 595 | * |
@@ -601,15 +599,14 @@ EXPORT_SYMBOL(cancel_rearming_delayed_work); | |||
601 | * Returns: 0 - function was executed | 599 | * Returns: 0 - function was executed |
602 | * 1 - function was scheduled for execution | 600 | * 1 - function was scheduled for execution |
603 | */ | 601 | */ |
604 | int execute_in_process_context(work_func_t fn, void *data, | 602 | int execute_in_process_context(work_func_t fn, struct execute_work *ew) |
605 | struct execute_work *ew) | ||
606 | { | 603 | { |
607 | if (!in_interrupt()) { | 604 | if (!in_interrupt()) { |
608 | fn(data); | 605 | fn(&ew->work); |
609 | return 0; | 606 | return 0; |
610 | } | 607 | } |
611 | 608 | ||
612 | INIT_WORK(&ew->work, fn, data); | 609 | INIT_WORK(&ew->work, fn); |
613 | schedule_work(&ew->work); | 610 | schedule_work(&ew->work); |
614 | 611 | ||
615 | return 1; | 612 | return 1; |