diff options
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/atm/usbatm.c | 27 | ||||
-rw-r--r-- | drivers/usb/atm/usbatm.h | 2 |
2 files changed, 16 insertions, 13 deletions
diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c index e717f5b1caee..07228721cafe 100644 --- a/drivers/usb/atm/usbatm.c +++ b/drivers/usb/atm/usbatm.c | |||
@@ -80,6 +80,7 @@ | |||
80 | #include <linux/stat.h> | 80 | #include <linux/stat.h> |
81 | #include <linux/timer.h> | 81 | #include <linux/timer.h> |
82 | #include <linux/wait.h> | 82 | #include <linux/wait.h> |
83 | #include <linux/kthread.h> | ||
83 | 84 | ||
84 | #ifdef VERBOSE_DEBUG | 85 | #ifdef VERBOSE_DEBUG |
85 | static int usbatm_print_packet(const unsigned char *data, int len); | 86 | static int usbatm_print_packet(const unsigned char *data, int len); |
@@ -1014,10 +1015,7 @@ static int usbatm_do_heavy_init(void *arg) | |||
1014 | struct usbatm_data *instance = arg; | 1015 | struct usbatm_data *instance = arg; |
1015 | int ret; | 1016 | int ret; |
1016 | 1017 | ||
1017 | daemonize(instance->driver->driver_name); | ||
1018 | allow_signal(SIGTERM); | 1018 | allow_signal(SIGTERM); |
1019 | instance->thread_pid = current->pid; | ||
1020 | |||
1021 | complete(&instance->thread_started); | 1019 | complete(&instance->thread_started); |
1022 | 1020 | ||
1023 | ret = instance->driver->heavy_init(instance, instance->usb_intf); | 1021 | ret = instance->driver->heavy_init(instance, instance->usb_intf); |
@@ -1026,7 +1024,7 @@ static int usbatm_do_heavy_init(void *arg) | |||
1026 | ret = usbatm_atm_init(instance); | 1024 | ret = usbatm_atm_init(instance); |
1027 | 1025 | ||
1028 | mutex_lock(&instance->serialize); | 1026 | mutex_lock(&instance->serialize); |
1029 | instance->thread_pid = -1; | 1027 | instance->thread = NULL; |
1030 | mutex_unlock(&instance->serialize); | 1028 | mutex_unlock(&instance->serialize); |
1031 | 1029 | ||
1032 | complete_and_exit(&instance->thread_exited, ret); | 1030 | complete_and_exit(&instance->thread_exited, ret); |
@@ -1034,13 +1032,18 @@ static int usbatm_do_heavy_init(void *arg) | |||
1034 | 1032 | ||
1035 | static int usbatm_heavy_init(struct usbatm_data *instance) | 1033 | static int usbatm_heavy_init(struct usbatm_data *instance) |
1036 | { | 1034 | { |
1037 | int ret = kernel_thread(usbatm_do_heavy_init, instance, CLONE_FS | CLONE_FILES); | 1035 | struct task_struct *t; |
1038 | 1036 | ||
1039 | if (ret < 0) { | 1037 | t = kthread_create(usbatm_do_heavy_init, instance, |
1040 | usb_err(instance, "%s: failed to create kernel_thread (%d)!\n", __func__, ret); | 1038 | instance->driver->driver_name); |
1041 | return ret; | 1039 | if (IS_ERR(t)) { |
1040 | usb_err(instance, "%s: failed to create kernel_thread (%ld)!\n", | ||
1041 | __func__, PTR_ERR(t)); | ||
1042 | return PTR_ERR(t); | ||
1042 | } | 1043 | } |
1043 | 1044 | ||
1045 | instance->thread = t; | ||
1046 | wake_up_process(t); | ||
1044 | wait_for_completion(&instance->thread_started); | 1047 | wait_for_completion(&instance->thread_started); |
1045 | 1048 | ||
1046 | return 0; | 1049 | return 0; |
@@ -1124,7 +1127,7 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id, | |||
1124 | kref_init(&instance->refcount); /* dropped in usbatm_usb_disconnect */ | 1127 | kref_init(&instance->refcount); /* dropped in usbatm_usb_disconnect */ |
1125 | mutex_init(&instance->serialize); | 1128 | mutex_init(&instance->serialize); |
1126 | 1129 | ||
1127 | instance->thread_pid = -1; | 1130 | instance->thread = NULL; |
1128 | init_completion(&instance->thread_started); | 1131 | init_completion(&instance->thread_started); |
1129 | init_completion(&instance->thread_exited); | 1132 | init_completion(&instance->thread_exited); |
1130 | 1133 | ||
@@ -1287,8 +1290,8 @@ void usbatm_usb_disconnect(struct usb_interface *intf) | |||
1287 | 1290 | ||
1288 | mutex_lock(&instance->serialize); | 1291 | mutex_lock(&instance->serialize); |
1289 | instance->disconnected = 1; | 1292 | instance->disconnected = 1; |
1290 | if (instance->thread_pid >= 0) | 1293 | if (instance->thread != NULL) |
1291 | kill_proc(instance->thread_pid, SIGTERM, 1); | 1294 | send_sig(SIGTERM, instance->thread, 1); |
1292 | mutex_unlock(&instance->serialize); | 1295 | mutex_unlock(&instance->serialize); |
1293 | 1296 | ||
1294 | wait_for_completion(&instance->thread_exited); | 1297 | wait_for_completion(&instance->thread_exited); |
diff --git a/drivers/usb/atm/usbatm.h b/drivers/usb/atm/usbatm.h index fc6c2be5999c..e6887c6cf3cf 100644 --- a/drivers/usb/atm/usbatm.h +++ b/drivers/usb/atm/usbatm.h | |||
@@ -175,7 +175,7 @@ struct usbatm_data { | |||
175 | int disconnected; | 175 | int disconnected; |
176 | 176 | ||
177 | /* heavy init */ | 177 | /* heavy init */ |
178 | int thread_pid; | 178 | struct task_struct *thread; |
179 | struct completion thread_started; | 179 | struct completion thread_started; |
180 | struct completion thread_exited; | 180 | struct completion thread_exited; |
181 | 181 | ||