diff options
author | Wim Van Sebroeck <wim@iguana.be> | 2007-05-01 08:53:01 +0200 |
---|---|---|
committer | Wim Van Sebroeck <wim@iguana.be> | 2007-05-01 08:53:01 +0200 |
commit | 48a7afe314bfc4d7f50e1608632f503dbba7e013 (patch) | |
tree | 4a80e6b96321a71affd1bacea817de93be08894b /drivers/net/wireless/libertas/thread.h | |
parent | [WATCHDOG] Semi-typical watchdog bug re early misc_register() (diff) | |
parent | libata: honour host controllers that want just one host (diff) | |
download | linux-48a7afe314bfc4d7f50e1608632f503dbba7e013.tar.xz linux-48a7afe314bfc4d7f50e1608632f503dbba7e013.zip |
Merge /pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'drivers/net/wireless/libertas/thread.h')
-rw-r--r-- | drivers/net/wireless/libertas/thread.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/drivers/net/wireless/libertas/thread.h b/drivers/net/wireless/libertas/thread.h new file mode 100644 index 000000000000..207b8a6cc33d --- /dev/null +++ b/drivers/net/wireless/libertas/thread.h @@ -0,0 +1,52 @@ +#ifndef __WLAN_THREAD_H_ +#define __WLAN_THREAD_H_ + +#include <linux/kthread.h> + +struct wlan_thread { + struct task_struct *task; + wait_queue_head_t waitq; + pid_t pid; + void *priv; +}; + +static inline void wlan_activate_thread(struct wlan_thread * thr) +{ + /** Record the thread pid */ + thr->pid = current->pid; + + /** Initialize the wait queue */ + init_waitqueue_head(&thr->waitq); +} + +static inline void wlan_deactivate_thread(struct wlan_thread * thr) +{ + ENTER(); + + thr->pid = 0; + + LEAVE(); +} + +static inline void wlan_create_thread(int (*wlanfunc) (void *), + struct wlan_thread * thr, char *name) +{ + thr->task = kthread_run(wlanfunc, thr, "%s", name); +} + +static inline int wlan_terminate_thread(struct wlan_thread * thr) +{ + ENTER(); + + /* Check if the thread is active or not */ + if (!thr->pid) { + printk(KERN_ERR "Thread does not exist\n"); + return -1; + } + kthread_stop(thr->task); + + LEAVE(); + return 0; +} + +#endif |