#include <dhd.h>
#include <linux/kernel.h>
+#include <linux/kthread.h>
#include <linux/netdevice.h>
#include <linux/sched.h>
#include <linux/etherdevice.h>
static s32 wl_create_event_handler(struct wl_priv *wl)
{
sema_init(&wl->event_sync, 0);
- init_completion(&wl->event_exit);
- wl->event_pid = kernel_thread(wl_event_handler, wl, 0);
- if (unlikely(wl->event_pid < 0)) {
+ wl->event_tsk = kthread_run(wl_event_handler, wl, "wl_event_handler");
+ if (IS_ERR(wl->event_tsk)) {
+ wl->event_tsk = NULL;
WL_ERR(("failed to create event thread\n"));
return -ENOMEM;
}
- WL_DBG(("pid %d\n", wl->event_pid));
return 0;
}
static void wl_destroy_event_handler(struct wl_priv *wl)
{
- if (wl->event_pid >= 0) {
- KILL_PROC(wl->event_pid, SIGTERM);
- wait_for_completion(&wl->event_exit);
+ if (wl->event_tsk) {
+ kthread_stop(wl->event_tsk);
+ wl->event_tsk = NULL;
}
}
{
struct wl_iscan_ctrl *iscan = wl_to_iscan(wl);
- if (wl->iscan_on && iscan->pid >= 0) {
+ if (wl->iscan_on && iscan->tsk) {
iscan->state = WL_ISCAN_STATE_IDLE;
- KILL_PROC(iscan->pid, SIGTERM);
- wait_for_completion(&iscan->exited);
- iscan->pid = -1;
+ kthread_stop(iscan->tsk);
+ iscan->tsk = NULL;
}
}
sched_setscheduler(current, SCHED_FIFO, ¶m);
status = WL_SCAN_RESULTS_PARTIAL;
while (likely(!down_interruptible(&iscan->sync))) {
+ if (kthread_should_stop())
+ break;
if (iscan->timer_on) {
del_timer_sync(&iscan->timer);
iscan->timer_on = 0;
del_timer_sync(&iscan->timer);
iscan->timer_on = 0;
}
- complete_and_exit(&iscan->exited, 0);
return 0;
}
struct wl_iscan_ctrl *iscan = wl_to_iscan(wl);
int err = 0;
- if (wl->iscan_on && iscan->pid < 0) {
+ if (wl->iscan_on && !iscan->tsk) {
iscan->state = WL_ISCAN_STATE_IDLE;
sema_init(&iscan->sync, 0);
- init_completion(&iscan->exited);
- iscan->pid = kernel_thread(wl_iscan_thread, iscan, 0);
- if (unlikely(iscan->pid < 0)) {
+ iscan->tsk = kthread_run(wl_iscan_thread, iscan, "wl_iscan");
+ if (IS_ERR(iscan->tsk)) {
WL_ERR(("Could not create iscan thread\n"));
+ iscan->tsk = NULL;
return -ENOMEM;
}
}
iscan->timer.data = (unsigned long) iscan;
iscan->timer.function = wl_iscan_timer;
sema_init(&iscan->sync, 0);
- init_completion(&iscan->exited);
- iscan->pid = kernel_thread(wl_iscan_thread, iscan, 0);
- if (unlikely(iscan->pid < 0)) {
+ iscan->tsk = kthread_run(wl_iscan_thread, iscan, "wl_iscan");
+ if (IS_ERR(iscan->tsk)) {
WL_ERR(("Could not create iscan thread\n"));
+ iscan->tsk = NULL;
return -ENOMEM;
}
iscan->data = wl;
sched_setscheduler(current, SCHED_FIFO, ¶m);
while (likely(!down_interruptible(&wl->event_sync))) {
+ if(kthread_should_stop())
+ break;
e = wl_deq_event(wl);
if (unlikely(!e)) {
WL_ERR(("eqeue empty..\n"));
}
wl_put_event(e);
}
- complete_and_exit(&wl->event_exit, 0);
+ return 0;
}
void
u32 timer_ms;
u32 timer_on;
s32 state;
- s32 pid;
+ struct task_struct *tsk;
struct semaphore sync;
- struct completion exited;
struct wl_iscan_eloop el;
void *data;
s8 ioctl_buf[WLC_IOCTL_SMLEN];
struct ether_addr bssid; /* bssid of currently engaged network */
struct semaphore event_sync; /* for synchronization of main event
thread */
- struct completion event_exit;
struct wl_profile *profile; /* holding dongle profile */
struct wl_iscan_ctrl *iscan; /* iscan controller */
struct wl_connect_info conn_info; /* association information
struct wl_fw_ctrl *fw; /* control firwmare / nvram paramter
downloading */
struct wl_pmk_list *pmk_list; /* wpa2 pmk list */
- s32 event_pid; /* pid of main event handler thread */
+ struct task_struct *event_tsk; /* task of main event handler thread */
unsigned long status; /* current dongle status */
void *pub;
u32 channel; /* current channel */