X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fusb%2Fstorage%2Flibusual.c;h=a28d49122e7a046301799edfade54e95f50d1cdd;hb=75c43b6ec6eb114e875e43fb151987c1a558e4f4;hp=599ad10a761b703da02f989eb51a88d0941ae0fd;hpb=82965addad66fce61a92c5f03104ea90b0b87124;p=pandora-kernel.git diff --git a/drivers/usb/storage/libusual.c b/drivers/usb/storage/libusual.c index 599ad10a761b..a28d49122e7a 100644 --- a/drivers/usb/storage/libusual.c +++ b/drivers/usb/storage/libusual.c @@ -9,6 +9,7 @@ #include #include #include +#include /* */ @@ -30,7 +31,7 @@ static atomic_t usu_bias = ATOMIC_INIT(USB_US_DEFAULT_BIAS); #define BIAS_NAME_SIZE (sizeof("usb-storage")) static const char *bias_names[3] = { "none", "usb-storage", "ub" }; -static DECLARE_MUTEX_LOCKED(usu_init_notify); +static DEFINE_MUTEX(usu_probe_mutex); static DECLARE_COMPLETION(usu_end_notify); static atomic_t total_threads = ATOMIC_INIT(0); @@ -117,6 +118,7 @@ EXPORT_SYMBOL_GPL(usb_usual_check_type); static int usu_probe(struct usb_interface *intf, const struct usb_device_id *id) { + int rc; unsigned long type; struct task_struct* task; unsigned long flags; @@ -135,7 +137,7 @@ static int usu_probe(struct usb_interface *intf, task = kthread_run(usu_probe_thread, (void*)type, "libusual_%d", type); if (IS_ERR(task)) { - int rc = PTR_ERR(task); + rc = PTR_ERR(task); printk(KERN_WARNING "libusual: " "Unable to start the thread for %s: %d\n", bias_names[type], rc); @@ -177,10 +179,7 @@ static int usu_probe_thread(void *arg) int rc; unsigned long flags; - /* A completion does not work here because it's counted. */ - down(&usu_init_notify); - up(&usu_init_notify); - + mutex_lock(&usu_probe_mutex); rc = request_module(bias_names[type]); spin_lock_irqsave(&usu_lock, flags); if (rc == 0 && (st->fls & USU_MOD_FL_PRESENT) == 0) { @@ -193,6 +192,7 @@ static int usu_probe_thread(void *arg) } st->fls &= ~USU_MOD_FL_THREAD; spin_unlock_irqrestore(&usu_lock, flags); + mutex_unlock(&usu_probe_mutex); complete_and_exit(&usu_end_notify, 0); } @@ -203,8 +203,9 @@ static int __init usb_usual_init(void) { int rc; + mutex_lock(&usu_probe_mutex); rc = usb_register(&usu_driver); - up(&usu_init_notify); + mutex_unlock(&usu_probe_mutex); return rc; }