aboutsummaryrefslogtreecommitdiff
path: root/drivers/staging/usbip/usbip_event.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2011-03-02 00:13:05 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2011-03-02 16:03:59 -0500
commit9720b4bc76a83807c68e00c62bfba575251bb73e (patch)
tree41794e9b5f715bf5ee52d428cadcf70ac773347b /drivers/staging/usbip/usbip_event.c
parent8c81161615feb8c666c675ec7a660dc9b011683f (diff)
staging/usbip: convert to kthread
usbip has its own infrastructure for managing kernel threads, similar to kthread. By changing it to use the standard functions, we can simplify the code and get rid of one of the last BKL users at the same time. Includes changes suggested by Max Vozeler. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Cc: Greg Kroah-Hartman <gregkh@suse.de> Cc: Takahiro Hirofuchi <hirofuchi@users.sourceforge.net> Cc: Max Vozeler <max@vozeler.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/usbip/usbip_event.c')
-rw-r--r--drivers/staging/usbip/usbip_event.c38
1 files changed, 13 insertions, 25 deletions
diff --git a/drivers/staging/usbip/usbip_event.c b/drivers/staging/usbip/usbip_event.c
index af3832b03e4..f4b287ef71d 100644
--- a/drivers/staging/usbip/usbip_event.c
+++ b/drivers/staging/usbip/usbip_event.c
@@ -62,55 +62,43 @@ static int event_handler(struct usbip_device *ud)
return 0;
}
-static void event_handler_loop(struct usbip_task *ut)
+static int event_handler_loop(void *data)
{
- struct usbip_device *ud = container_of(ut, struct usbip_device, eh);
+ struct usbip_device *ud = data;
- while (1) {
- if (signal_pending(current)) {
- usbip_dbg_eh("signal catched!\n");
- break;
- }
+ while (!kthread_should_stop()) {
+ wait_event_interruptible(ud->eh_waitq,
+ usbip_event_happened(ud) ||
+ kthread_should_stop());
+ usbip_dbg_eh("wakeup\n");
if (event_handler(ud) < 0)
break;
-
- wait_event_interruptible(ud->eh_waitq,
- usbip_event_happened(ud));
- usbip_dbg_eh("wakeup\n");
}
+ return 0;
}
int usbip_start_eh(struct usbip_device *ud)
{
- struct usbip_task *eh = &ud->eh;
- struct task_struct *th;
-
init_waitqueue_head(&ud->eh_waitq);
ud->event = 0;
- usbip_task_init(eh, "usbip_eh", event_handler_loop);
-
- th = kthread_run(usbip_thread, (void *)eh, "usbip");
- if (IS_ERR(th)) {
+ ud->eh = kthread_run(event_handler_loop, ud, "usbip_eh");
+ if (IS_ERR(ud->eh)) {
printk(KERN_WARNING
"Unable to start control thread\n");
- return PTR_ERR(th);
+ return PTR_ERR(ud->eh);
}
-
- wait_for_completion(&eh->thread_done);
return 0;
}
EXPORT_SYMBOL_GPL(usbip_start_eh);
void usbip_stop_eh(struct usbip_device *ud)
{
- struct usbip_task *eh = &ud->eh;
-
- if (eh->thread == current)
+ if (ud->eh == current)
return; /* do not wait for myself */
- wait_for_completion(&eh->thread_done);
+ kthread_stop(ud->eh);
usbip_dbg_eh("usbip_eh has finished\n");
}
EXPORT_SYMBOL_GPL(usbip_stop_eh);