[PATCH 2/5] staging: brcm80211: remove kernel_thread() for dhd_dpc_thread.

Jason Cooper jason at lakedaemon.net
Fri Oct 8 18:52:50 UTC 2010


use kthread_run(), kthread_stop(), and kthread_should_stop().  Removes
dpc_pid, dpc_exited, and the call to DAEMONIZE.

Signed-off-by: Jason Cooper <jason at lakedaemon.net>
---
 drivers/staging/brcm80211/brcmfmac/dhd_linux.c |   27 ++++++++++-------------
 1 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c
index cf9a181..a98c626 100644
--- a/drivers/staging/brcm80211/brcmfmac/dhd_linux.c
+++ b/drivers/staging/brcm80211/brcmfmac/dhd_linux.c
@@ -244,9 +244,8 @@ typedef struct dhd_info {
 	struct semaphore sdsem;
 	struct task_struct *watchdog_tsk;
 	struct semaphore watchdog_sem;
-	long dpc_pid;
+	struct task_struct *dpc_tsk;
 	struct semaphore dpc_sem;
-	struct completion dpc_exited;
 
 	/* Thread to issue ioctl for multicast */
 	long sysioc_pid;
@@ -1377,10 +1376,10 @@ static int dhd_dpc_thread(void *data)
 	}
 #endif				/* DHD_SCHED */
 
-	DAEMONIZE("dhd_dpc");
-
 	/* Run until signal received */
 	while (1) {
+		if(kthread_should_stop())
+			break;
 		if (down_interruptible(&dhd->dpc_sem) == 0) {
 			/* Call bus dpc unless it indicated down
 				 (then clean stop) */
@@ -1400,8 +1399,7 @@ static int dhd_dpc_thread(void *data)
 	}
 
 	WAKE_LOCK_DESTROY(&dhd->pub, WAKE_LOCK_DPC);
-
-	complete_and_exit(&dhd->dpc_exited, 0);
+	return 0;
 }
 
 static void dhd_dpc(unsigned long data)
@@ -1423,7 +1421,7 @@ void dhd_sched_dpc(dhd_pub_t *dhdp)
 {
 	dhd_info_t *dhd = (dhd_info_t *) dhdp->info;
 
-	if (dhd->dpc_pid >= 0) {
+	if (!IS_ERR(dhd->dpc_tsk)) {
 		up(&dhd->dpc_sem);
 		return;
 	}
@@ -2028,12 +2026,12 @@ dhd_pub_t *dhd_attach(osl_t *osh, struct dhd_bus *bus, uint bus_hdrlen)
 	if (dhd_dpc_prio >= 0) {
 		/* Initialize DPC thread */
 		sema_init(&dhd->dpc_sem, 0);
-		init_completion(&dhd->dpc_exited);
-		dhd->dpc_pid = kernel_thread(dhd_dpc_thread, dhd, 0);
-	} else {
+		dhd->dpc_tsk = kthread_run(dhd_dpc_thread, dhd, "dhd_dpc");
+		if (IS_ERR(dhd->dpc_tsk))
+			printk(KERN_WARNING
+				"dhd_dpc thread failed to start\n");
+	} else
 		tasklet_init(&dhd->tasklet, dhd_dpc, (unsigned long) dhd);
-		dhd->dpc_pid = -1;
-	}
 
 	if (dhd_sysioc) {
 		sema_init(&dhd->sysioc_sem, 0);
@@ -2356,9 +2354,8 @@ void dhd_detach(dhd_pub_t *dhdp)
 				kthread_stop(dhd->watchdog_tsk);
 			}
 
-			if (dhd->dpc_pid >= 0) {
-				KILL_PROC(dhd->dpc_pid, SIGTERM);
-				wait_for_completion(&dhd->dpc_exited);
+			if (!IS_ERR(dhd->dpc_tsk)) {
+				kthread_stop(dhd->dpc_tsk);
 			} else
 				tasklet_kill(&dhd->tasklet);
 
-- 
1.6.3.3




More information about the devel mailing list