ChangeSet 1.883.3.11, 2002/12/17 21:49:24-08:00, [EMAIL PROTECTED]

[PATCH] USB: clean kernel thread exit for speedtouch

this makes sure that the kernel thread is dead and gone on module unload.
  - use a completion to wait for the kernel thread's death


diff -Nru a/drivers/usb/misc/speedtouch.c b/drivers/usb/misc/speedtouch.c
--- a/drivers/usb/misc/speedtouch.c     Wed Dec 18 00:34:36 2002
+++ b/drivers/usb/misc/speedtouch.c     Wed Dec 18 00:34:36 2002
@@ -144,8 +144,9 @@
 static const char udsl_driver_name[] = "Alcatel SpeedTouch USB";
 
 /* data thread */
-static int datapid = 0;
 DECLARE_WAIT_QUEUE_HEAD (udsl_wqh);
+static DECLARE_COMPLETION(thread_grave);
+static unsigned int datapid;
 
 #ifdef DEBUG_PACKET
 int udsl_print_packet (const unsigned char *data, int len);
@@ -443,9 +444,9 @@
        };
 
        remove_wait_queue (&udsl_wqh, &wait);
-       datapid = 0;
        PDEBUG ("SpeedSARd is exiting\n");
-       return 0;
+       complete_and_exit(&thread_grave, 0);
+       return 0; //never reached
 }
 
 
@@ -461,16 +462,7 @@
        /* Kill the thread */
        ret = kill_proc (datapid, SIGTERM, 1);
        if (!ret) {
-               /* Wait 10 seconds */
-               int count = 10 * 100;
-
-               while (datapid && --count) {
-                       current->state = TASK_INTERRUPTIBLE;
-                       schedule_timeout (1);
-               }
-
-               if (!count)
-                       err ("giving up on killing SpeedSAR thread.");
+               wait_for_completion(&thread_grave);
        }
 }
 


-------------------------------------------------------
This sf.net email is sponsored by:
With Great Power, Comes Great Responsibility 
Learn to use your power at OSDN's High Performance Computing Channel
http://hpc.devchannel.org/
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to