Module Name: src Committed By: riastradh Date: Wed Jul 24 01:52:24 UTC 2013
Modified Files: src/sys/external/bsd/drm2/include/linux [riastradh-drm2]: workqueue.h Log Message: Add callout-based delayed_work implementation to <linux/workqueue.h>. To generate a diff of this commit: cvs rdiff -u -r1.1.2.1 -r1.1.2.2 \ src/sys/external/bsd/drm2/include/linux/workqueue.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/external/bsd/drm2/include/linux/workqueue.h diff -u src/sys/external/bsd/drm2/include/linux/workqueue.h:1.1.2.1 src/sys/external/bsd/drm2/include/linux/workqueue.h:1.1.2.2 --- src/sys/external/bsd/drm2/include/linux/workqueue.h:1.1.2.1 Wed Jul 24 00:33:12 2013 +++ src/sys/external/bsd/drm2/include/linux/workqueue.h Wed Jul 24 01:52:24 2013 @@ -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_ */