Replace kernel_thread() with kthread_run(). Replace pid with tsk, and exited with kthread_stop()/kthread_should_stop(). Signed-off-by: Jason Cooper <jason@xxxxxxxxxxxxxx> --- drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c | 38 ++++++++++------------ drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h | 6 +-- 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c index 1c3b0d8..5e97d2c 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c @@ -35,6 +35,7 @@ #include <dhd.h> #include <linux/kernel.h> +#include <linux/kthread.h> #include <linux/netdevice.h> #include <linux/sched.h> #include <linux/etherdevice.h> @@ -2795,33 +2796,27 @@ static void wl_deinit_priv_mem(struct wl_priv *wl) static int32 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 (unlikely(IS_ERR(wl->event_tsk))) { 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 (!IS_ERR(wl->event_tsk)) + kthread_stop(wl->event_tsk); } static void wl_term_iscan(struct wl_priv *wl) { struct wl_iscan_ctrl *iscan = wl_to_iscan(wl); - if (wl->iscan_on && iscan->pid >= 0) { + if (wl->iscan_on && !IS_ERR(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); } } @@ -2954,6 +2949,8 @@ static int32 wl_iscan_thread(void *data) 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; @@ -2971,7 +2968,6 @@ static int32 wl_iscan_thread(void *data) del_timer_sync(&iscan->timer); iscan->timer_on = 0; } - complete_and_exit(&iscan->exited, 0); return 0; } @@ -2992,12 +2988,11 @@ static int32 wl_invoke_iscan(struct wl_priv *wl) struct wl_iscan_ctrl *iscan = wl_to_iscan(wl); int err = 0; - if (wl->iscan_on && iscan->pid < 0) { + if (wl->iscan_on && IS_ERR(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")); return -ENOMEM; } @@ -3030,9 +3025,8 @@ static int32 wl_init_iscan(struct wl_priv *wl) 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")); return -ENOMEM; } @@ -3172,6 +3166,8 @@ static int32 wl_event_handler(void *data) 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")); @@ -3186,7 +3182,7 @@ static int32 wl_event_handler(void *data) } wl_put_event(e); } - complete_and_exit(&wl->event_exit, 0); + return 0; } void diff --git a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h index 3843f75..c0a4ace 100644 --- a/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h +++ b/drivers/staging/brcm80211/brcmfmac/wl_cfg80211.h @@ -247,9 +247,8 @@ struct wl_iscan_ctrl { uint32 timer_ms; uint32 timer_on; int32 state; - int32 pid; + struct task_struct *tsk; struct semaphore sync; - struct completion exited; struct wl_iscan_eloop el; void *data; s8 ioctl_buf[WLC_IOCTL_SMLEN]; @@ -307,7 +306,6 @@ struct wl_priv { 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 @@ -315,7 +313,7 @@ struct wl_priv { struct wl_fw_ctrl *fw; /* control firwmare / nvram paramter downloading */ struct wl_pmk_list *pmk_list; /* wpa2 pmk list */ - int32 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; uint32 channel; /* current channel */ -- 1.6.3.3 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/devel