Commit 9c8d6178 authored by akpm@osdl.org's avatar akpm@osdl.org Committed by Greg Kroah-Hartman

[PATCH] USB: khubd: use kthread API

Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent e8116e84
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <linux/ioctl.h> #include <linux/ioctl.h>
#include <linux/usb.h> #include <linux/usb.h>
#include <linux/usbdevice_fs.h> #include <linux/usbdevice_fs.h>
#include <linux/kthread.h>
#include <asm/semaphore.h> #include <asm/semaphore.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -47,8 +48,7 @@ static LIST_HEAD(hub_event_list); /* List of hubs needing servicing */ ...@@ -47,8 +48,7 @@ static LIST_HEAD(hub_event_list); /* List of hubs needing servicing */
/* Wakes up khubd */ /* Wakes up khubd */
static DECLARE_WAIT_QUEUE_HEAD(khubd_wait); static DECLARE_WAIT_QUEUE_HEAD(khubd_wait);
static pid_t khubd_pid = 0; /* PID of khubd */ static struct task_struct *khubd_task;
static DECLARE_COMPLETION(khubd_exited);
/* cycle leds on hubs that aren't blinking for attention */ /* cycle leds on hubs that aren't blinking for attention */
static int blinkenlights = 0; static int blinkenlights = 0;
...@@ -2807,23 +2807,16 @@ static void hub_events(void) ...@@ -2807,23 +2807,16 @@ static void hub_events(void)
static int hub_thread(void *__unused) static int hub_thread(void *__unused)
{ {
/*
* This thread doesn't need any user-level access,
* so get rid of all our resources
*/
daemonize("khubd");
allow_signal(SIGKILL);
/* Send me a signal to get me die (for debugging) */
do { do {
hub_events(); hub_events();
wait_event_interruptible(khubd_wait, !list_empty(&hub_event_list)); wait_event_interruptible(khubd_wait,
!list_empty(&hub_event_list) ||
kthread_should_stop());
try_to_freeze(); try_to_freeze();
} while (!signal_pending(current)); } while (!kthread_should_stop() || !list_empty(&hub_event_list));
pr_debug ("%s: khubd exiting\n", usbcore_name); pr_debug("%s: khubd exiting\n", usbcore_name);
complete_and_exit(&khubd_exited, 0); return 0;
} }
static struct usb_device_id hub_id_table [] = { static struct usb_device_id hub_id_table [] = {
...@@ -2849,20 +2842,15 @@ static struct usb_driver hub_driver = { ...@@ -2849,20 +2842,15 @@ static struct usb_driver hub_driver = {
int usb_hub_init(void) int usb_hub_init(void)
{ {
pid_t pid;
if (usb_register(&hub_driver) < 0) { if (usb_register(&hub_driver) < 0) {
printk(KERN_ERR "%s: can't register hub driver\n", printk(KERN_ERR "%s: can't register hub driver\n",
usbcore_name); usbcore_name);
return -1; return -1;
} }
pid = kernel_thread(hub_thread, NULL, CLONE_KERNEL); khubd_task = kthread_run(hub_thread, NULL, "khubd");
if (pid >= 0) { if (!IS_ERR(khubd_task))
khubd_pid = pid;
return 0; return 0;
}
/* Fall through if kernel_thread failed */ /* Fall through if kernel_thread failed */
usb_deregister(&hub_driver); usb_deregister(&hub_driver);
...@@ -2873,12 +2861,7 @@ int usb_hub_init(void) ...@@ -2873,12 +2861,7 @@ int usb_hub_init(void)
void usb_hub_cleanup(void) void usb_hub_cleanup(void)
{ {
int ret; kthread_stop(khubd_task);
/* Kill the thread */
ret = kill_proc(khubd_pid, SIGKILL, 1);
wait_for_completion(&khubd_exited);
/* /*
* Hub resources are freed for us by usb_deregister. It calls * Hub resources are freed for us by usb_deregister. It calls
...@@ -2890,7 +2873,6 @@ void usb_hub_cleanup(void) ...@@ -2890,7 +2873,6 @@ void usb_hub_cleanup(void)
usb_deregister(&hub_driver); usb_deregister(&hub_driver);
} /* usb_hub_cleanup() */ } /* usb_hub_cleanup() */
static int config_descriptors_changed(struct usb_device *udev) static int config_descriptors_changed(struct usb_device *udev)
{ {
unsigned index; unsigned index;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment