X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fusb%2Fstorage%2Flibusual.c;h=d617e8ae6b006b6d0b014774d86eb78bd1c9c6e3;hb=e7849f16c13476288fe4fbd420975e8456c75aa0;hp=55b952084f0c07d065546526ea870ca27d869f3e;hpb=fe537c0ee86b27fbe0690a7869815da80f492dbd;p=linux-2.6-omap-h63xx.git diff --git a/drivers/usb/storage/libusual.c b/drivers/usb/storage/libusual.c index 55b952084f0..d617e8ae6b0 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 struct semaphore usu_init_notify; +static DEFINE_MUTEX(usu_probe_mutex); static DECLARE_COMPLETION(usu_end_notify); static atomic_t total_threads = ATOMIC_INIT(0); @@ -134,7 +135,7 @@ static int usu_probe(struct usb_interface *intf, stat[type].fls |= USU_MOD_FL_THREAD; spin_unlock_irqrestore(&usu_lock, flags); - task = kthread_run(usu_probe_thread, (void*)type, "libusual_%d", type); + task = kthread_run(usu_probe_thread, (void*)type, "libusual_%ld", type); if (IS_ERR(task)) { rc = PTR_ERR(task); printk(KERN_WARNING "libusual: " @@ -178,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) { @@ -194,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); } @@ -204,10 +203,9 @@ static int __init usb_usual_init(void) { int rc; - sema_init(&usu_init_notify, 0); - + mutex_lock(&usu_probe_mutex); rc = usb_register(&usu_driver); - up(&usu_init_notify); + mutex_unlock(&usu_probe_mutex); return rc; }