Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/riastradh-drm2]: src/sys/external/bsd/drm2/include/linux Add callout-bas...
details: https://anonhg.NetBSD.org/src/rev/26831b3fb24c
branches: riastradh-drm2
changeset: 788021:26831b3fb24c
user: riastradh <riastradh%NetBSD.org@localhost>
date: Wed Jul 24 01:52:24 2013 +0000
description:
Add callout-based delayed_work implementation to <linux/workqueue.h>.
diffstat:
sys/external/bsd/drm2/include/linux/workqueue.h | 42 ++++++++++++++++++++++++-
1 files changed, 41 insertions(+), 1 deletions(-)
diffs (54 lines):
diff -r da5dd0fb8f09 -r 26831b3fb24c sys/external/bsd/drm2/include/linux/workqueue.h
--- a/sys/external/bsd/drm2/include/linux/workqueue.h Wed Jul 24 01:52:08 2013 +0000
+++ b/sys/external/bsd/drm2/include/linux/workqueue.h Wed Jul 24 01:52:24 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: workqueue.h,v 1.1.2.1 2013/07/24 00:33:12 riastradh Exp $ */
+/* $NetBSD: workqueue.h,v 1.1.2.2 2013/07/24 01:52:24 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,4 +32,44 @@
#ifndef _LINUX_WORKQUEUE_H_
#define _LINUX_WORKQUEUE_H_
+#include <sys/callout.h>
+
+#include <linux/kernel.h>
+
+struct work_struct {
+ struct callout ws_callout;
+};
+
+struct delayed_work {
+ struct work_struct dw_work;
+};
+
+static inline void
+INIT_DELAYED_WORK(struct delayed_work *dw, void (*fn)(struct delayed_work *))
+{
+
+ /* XXX This cast business is sketchy. */
+ callout_setfunc(&dw->dw_work.ws_callout, (void (*)(void *))fn,
+ &dw->dw_work);
+}
+
+static inline struct delayed_work *
+to_delayed_work(struct work_struct *work)
+{
+ return container_of(work, struct delayed_work, dw_work);
+}
+
+static inline void
+schedule_delayed_work(struct delayed_work *dw, unsigned long ticks)
+{
+ KASSERT(ticks < INT_MAX);
+ callout_schedule(&dw->dw_work.ws_callout, (int)ticks);
+}
+
+static inline void
+cancel_delayed_work_sync(struct delayed_work *dw)
+{
+ callout_stop(&dw->dw_work.ws_callout);
+}
+
#endif /* _LINUX_WORKQUEUE_H_ */
Home |
Main Index |
Thread Index |
Old Index