compat-3.2.h: Avoid module_platform_driver redefinition
[~tnikolova/compat/.git] / compat / compat-2.6.36.c
1 /*
2  * Copyright 2010    Hauke Mehrtens <hauke@hauke-m.de>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * Compatibility file for Linux wireless for kernels 2.6.36.
9  */
10
11 #include <linux/compat.h>
12
13 struct workqueue_struct *system_wq __read_mostly;
14 struct workqueue_struct *system_long_wq __read_mostly;
15 struct workqueue_struct *system_nrt_wq __read_mostly;
16 EXPORT_SYMBOL_GPL(system_wq);
17 EXPORT_SYMBOL_GPL(system_long_wq);
18 EXPORT_SYMBOL_GPL(system_nrt_wq);
19
20 int schedule_work(struct work_struct *work)
21 {
22         return queue_work(system_wq, work);
23 }
24 EXPORT_SYMBOL_GPL(schedule_work);
25
26 int schedule_work_on(int cpu, struct work_struct *work)
27 {
28 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))
29         return queue_work_on(cpu, system_wq, work);
30 #else
31         return queue_work(system_wq, work);
32 #endif
33 }
34 EXPORT_SYMBOL_GPL(schedule_work_on);
35
36 int schedule_delayed_work(struct delayed_work *dwork,
37                                  unsigned long delay)
38 {
39         return queue_delayed_work(system_wq, dwork, delay);
40 }
41 EXPORT_SYMBOL_GPL(schedule_delayed_work);
42
43 int schedule_delayed_work_on(int cpu,
44                                     struct delayed_work *dwork,
45                                     unsigned long delay)
46 {
47         return queue_delayed_work_on(cpu, system_wq, dwork, delay);
48 }
49 EXPORT_SYMBOL_GPL(schedule_delayed_work_on);
50
51 void flush_scheduled_work(void)
52 {
53         flush_workqueue(system_wq);
54 }
55 EXPORT_SYMBOL_GPL(flush_scheduled_work);
56
57 /**
58  * work_busy - test whether a work is currently pending or running
59  * @work: the work to be tested
60  *
61  * Test whether @work is currently pending or running.  There is no
62  * synchronization around this function and the test result is
63  * unreliable and only useful as advisory hints or for debugging.
64  * Especially for reentrant wqs, the pending state might hide the
65  * running state.
66  *
67  * RETURNS:
68  * OR'd bitmask of WORK_BUSY_* bits.
69  */
70 unsigned int work_busy(struct work_struct *work)
71 {
72         unsigned int ret = 0;
73
74         if (work_pending(work))
75                 ret |= WORK_BUSY_PENDING;
76
77         return ret;
78 }
79 EXPORT_SYMBOL_GPL(work_busy);
80
81 int backport_system_workqueue_create()
82 {
83         system_wq = alloc_workqueue("events", 0, 0);
84         if (!system_wq)
85                 return -ENOMEM;
86
87         system_long_wq = alloc_workqueue("events_long", 0, 0);
88         if (!system_long_wq)
89                 goto err1;
90
91         system_nrt_wq = create_singlethread_workqueue("events_nrt");
92         if (!system_nrt_wq)
93                 goto err2;
94
95         return 0;
96
97 err2:
98         destroy_workqueue(system_long_wq);
99 err1:
100         destroy_workqueue(system_wq);
101         return -ENOMEM;
102 }
103
104 void backport_system_workqueue_destroy()
105 {
106         destroy_workqueue(system_nrt_wq);
107         destroy_workqueue(system_wq);
108         destroy_workqueue(system_long_wq);
109 }