1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef WORKQUEUES_H
3 #define WORKQUEUES_H
4 
5 #include <stdbool.h>
6 
7 #include "barriers.h"
8 #include "bug_on.h"
9 #include "int_typedefs.h"
10 
11 #include <linux/types.h>
12 
13 /* Stub workqueue implementation. */
14 
15 struct work_struct;
16 typedef void (*work_func_t)(struct work_struct *work);
17 void delayed_work_timer_fn(unsigned long __data);
18 
19 struct work_struct {
20 /*	atomic_long_t data; */
21 	unsigned long data;
22 
23 	struct list_head entry;
24 	work_func_t func;
25 #ifdef CONFIG_LOCKDEP
26 	struct lockdep_map lockdep_map;
27 #endif
28 };
29 
30 struct timer_list {
31 	struct hlist_node	entry;
32 	unsigned long		expires;
33 	void			(*function)(unsigned long);
34 	unsigned long		data;
35 	u32			flags;
36 	int			slack;
37 };
38 
39 struct delayed_work {
40 	struct work_struct work;
41 	struct timer_list timer;
42 
43 	/* target workqueue and CPU ->timer uses to queue ->work */
44 	struct workqueue_struct *wq;
45 	int cpu;
46 };
47 
48 
schedule_work(struct work_struct * work)49 static inline bool schedule_work(struct work_struct *work)
50 {
51 	BUG();
52 	return true;
53 }
54 
schedule_work_on(int cpu,struct work_struct * work)55 static inline bool schedule_work_on(int cpu, struct work_struct *work)
56 {
57 	BUG();
58 	return true;
59 }
60 
queue_work(struct workqueue_struct * wq,struct work_struct * work)61 static inline bool queue_work(struct workqueue_struct *wq,
62 			      struct work_struct *work)
63 {
64 	BUG();
65 	return true;
66 }
67 
queue_delayed_work(struct workqueue_struct * wq,struct delayed_work * dwork,unsigned long delay)68 static inline bool queue_delayed_work(struct workqueue_struct *wq,
69 				      struct delayed_work *dwork,
70 				      unsigned long delay)
71 {
72 	BUG();
73 	return true;
74 }
75 
76 #define INIT_WORK(w, f) \
77 	do { \
78 		(w)->data = 0; \
79 		(w)->func = (f); \
80 	} while (0)
81 
82 #define INIT_DELAYED_WORK(w, f) INIT_WORK(&(w)->work, (f))
83 
84 #define __WORK_INITIALIZER(n, f) { \
85 		.data = 0, \
86 		.entry = { &(n).entry, &(n).entry }, \
87 		.func = f \
88 	}
89 
90 /* Don't bother initializing timer. */
91 #define __DELAYED_WORK_INITIALIZER(n, f, tflags) { \
92 	.work = __WORK_INITIALIZER((n).work, (f)), \
93 	}
94 
95 #define DECLARE_WORK(n, f) \
96 	struct workqueue_struct n = __WORK_INITIALIZER
97 
98 #define DECLARE_DELAYED_WORK(n, f) \
99 	struct delayed_work n = __DELAYED_WORK_INITIALIZER(n, f, 0)
100 
101 #define system_power_efficient_wq ((struct workqueue_struct *) NULL)
102 
103 #endif
104