| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: workqueue.h,v 1.1.2.4 2013/07/24 02:09:43 riastradh Exp $ */ | | 1 | /* $NetBSD: workqueue.h,v 1.1.2.5 2013/07/24 03:04:04 riastradh Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2013 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Taylor R. Campbell. | | 8 | * by Taylor R. Campbell. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -41,43 +41,91 @@ | | | @@ -41,43 +41,91 @@ |
41 | * expedient, but wrong, if for no reason other than that we never call | | 41 | * expedient, but wrong, if for no reason other than that we never call |
42 | * callout_destroy. | | 42 | * callout_destroy. |
43 | */ | | 43 | */ |
44 | | | 44 | |
45 | struct work_struct { | | 45 | struct work_struct { |
46 | struct callout ws_callout; | | 46 | struct callout ws_callout; |
47 | }; | | 47 | }; |
48 | | | 48 | |
49 | struct delayed_work { | | 49 | struct delayed_work { |
50 | struct work_struct dw_work; | | 50 | struct work_struct dw_work; |
51 | }; | | 51 | }; |
52 | | | 52 | |
53 | static inline void | | 53 | static inline void |
54 | INIT_DELAYED_WORK(struct delayed_work *dw, void (*fn)(struct work_struct *)) | | 54 | INIT_WORK(struct work_struct *work, void (*fn)(struct work_struct *)) |
55 | { | | 55 | { |
56 | | | 56 | |
57 | callout_init(&dw->dw_work.ws_callout, 0); | | 57 | callout_init(&work->ws_callout, 0); |
58 | | | 58 | |
59 | /* XXX This cast business is sketchy. */ | | 59 | /* XXX This cast business is sketchy. */ |
60 | callout_setfunc(&dw->dw_work.ws_callout, (void (*)(void *))fn, | | 60 | callout_setfunc(&work->ws_callout, (void (*)(void *))fn, work); |
61 | &dw->dw_work); | | 61 | } |
| | | 62 | |
| | | 63 | static inline void |
| | | 64 | INIT_DELAYED_WORK(struct delayed_work *dw, void (*fn)(struct work_struct *)) |
| | | 65 | { |
| | | 66 | INIT_WORK(&dw->dw_work, fn); |
62 | } | | 67 | } |
63 | | | 68 | |
64 | static inline struct delayed_work * | | 69 | static inline struct delayed_work * |
65 | to_delayed_work(struct work_struct *work) | | 70 | to_delayed_work(struct work_struct *work) |
66 | { | | 71 | { |
67 | return container_of(work, struct delayed_work, dw_work); | | 72 | return container_of(work, struct delayed_work, dw_work); |
68 | } | | 73 | } |
69 | | | 74 | |
70 | static inline void | | 75 | static inline void |
| | | 76 | schedule_work(struct work_struct *work) |
| | | 77 | { |
| | | 78 | callout_schedule(&work->ws_callout, 0); |
| | | 79 | } |
| | | 80 | |
| | | 81 | static inline void |
71 | schedule_delayed_work(struct delayed_work *dw, unsigned long ticks) | | 82 | schedule_delayed_work(struct delayed_work *dw, unsigned long ticks) |
72 | { | | 83 | { |
73 | KASSERT(ticks < INT_MAX); | | 84 | KASSERT(ticks < INT_MAX); |
74 | callout_schedule(&dw->dw_work.ws_callout, (int)ticks); | | 85 | callout_schedule(&dw->dw_work.ws_callout, (int)ticks); |
75 | } | | 86 | } |
76 | | | 87 | |
77 | static inline void | | 88 | static inline void |
| | | 89 | cancel_work_sync(struct work_struct *work) |
| | | 90 | { |
| | | 91 | callout_halt(&work->ws_callout, NULL); |
| | | 92 | } |
| | | 93 | |
| | | 94 | static inline void |
78 | cancel_delayed_work_sync(struct delayed_work *dw) | | 95 | cancel_delayed_work_sync(struct delayed_work *dw) |
79 | { | | 96 | { |
80 | callout_halt(&dw->dw_work.ws_callout, NULL); | | 97 | cancel_work_sync(&dw->dw_work); |
| | | 98 | } |
| | | 99 | |
| | | 100 | /* |
| | | 101 | * XXX Bogus stubs for Linux work queues. |
| | | 102 | */ |
| | | 103 | |
| | | 104 | struct workqueue_struct; |
| | | 105 | |
| | | 106 | static inline struct workqueue_struct * |
| | | 107 | alloc_ordered_workqueue(const char *name __unused, int flags __unused) |
| | | 108 | { |
| | | 109 | return NULL; |
| | | 110 | } |
| | | 111 | |
| | | 112 | static inline void |
| | | 113 | destroy_workqueue(struct workqueue_struct *wq __unused) |
| | | 114 | { |
| | | 115 | } |
| | | 116 | |
| | | 117 | static inline void |
| | | 118 | queue_work(struct workqueue_struct *wq __unused, struct work_struct *work) |
| | | 119 | { |
| | | 120 | schedule_work(work); |
| | | 121 | } |
| | | 122 | |
| | | 123 | static inline void |
| | | 124 | queue_delayed_work(struct workqueue_struct *wq __unused, |
| | | 125 | struct delayed_work *dw, |
| | | 126 | unsigned int ticks) |
| | | 127 | { |
| | | 128 | schedule_delayed_work(dw, ticks); |
81 | } | | 129 | } |
82 | | | 130 | |
83 | #endif /* _LINUX_WORKQUEUE_H_ */ | | 131 | #endif /* _LINUX_WORKQUEUE_H_ */ |