Wed Jul 24 03:04:04 2013 UTC ()
Add kludgey non-delayed work to <linux/workqueue.h>.


(riastradh)
diff -r1.1.2.4 -r1.1.2.5 src/sys/external/bsd/drm2/include/linux/workqueue.h

cvs diff -r1.1.2.4 -r1.1.2.5 src/sys/external/bsd/drm2/include/linux/Attic/workqueue.h (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/include/linux/Attic/workqueue.h 2013/07/24 02:09:43 1.1.2.4
+++ src/sys/external/bsd/drm2/include/linux/Attic/workqueue.h 2013/07/24 03:04:04 1.1.2.5
@@ -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
45struct work_struct { 45struct work_struct {
46 struct callout ws_callout; 46 struct callout ws_callout;
47}; 47};
48 48
49struct delayed_work { 49struct delayed_work {
50 struct work_struct dw_work; 50 struct work_struct dw_work;
51}; 51};
52 52
53static inline void 53static inline void
54INIT_DELAYED_WORK(struct delayed_work *dw, void (*fn)(struct work_struct *)) 54INIT_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
 63static inline void
 64INIT_DELAYED_WORK(struct delayed_work *dw, void (*fn)(struct work_struct *))
 65{
 66 INIT_WORK(&dw->dw_work, fn);
62} 67}
63 68
64static inline struct delayed_work * 69static inline struct delayed_work *
65to_delayed_work(struct work_struct *work) 70to_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
70static inline void 75static inline void
 76schedule_work(struct work_struct *work)
 77{
 78 callout_schedule(&work->ws_callout, 0);
 79}
 80
 81static inline void
71schedule_delayed_work(struct delayed_work *dw, unsigned long ticks) 82schedule_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
77static inline void 88static inline void
 89cancel_work_sync(struct work_struct *work)
 90{
 91 callout_halt(&work->ws_callout, NULL);
 92}
 93
 94static inline void
78cancel_delayed_work_sync(struct delayed_work *dw) 95cancel_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
 104struct workqueue_struct;
 105
 106static inline struct workqueue_struct *
 107alloc_ordered_workqueue(const char *name __unused, int flags __unused)
 108{
 109 return NULL;
 110}
 111
 112static inline void
 113destroy_workqueue(struct workqueue_struct *wq __unused)
 114{
 115}
 116
 117static inline void
 118queue_work(struct workqueue_struct *wq __unused, struct work_struct *work)
 119{
 120 schedule_work(work);
 121}
 122
 123static inline void
 124queue_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_ */