aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/storage/libusual.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/drivers/usb/storage/libusual.c b/drivers/usb/storage/libusual.c
index 55b952084f0c..a28d49122e7a 100644
--- a/drivers/usb/storage/libusual.c
+++ b/drivers/usb/storage/libusual.c
@@ -9,6 +9,7 @@
9#include <linux/usb_usual.h> 9#include <linux/usb_usual.h>
10#include <linux/vmalloc.h> 10#include <linux/vmalloc.h>
11#include <linux/kthread.h> 11#include <linux/kthread.h>
12#include <linux/mutex.h>
12 13
13/* 14/*
14 */ 15 */
@@ -30,7 +31,7 @@ static atomic_t usu_bias = ATOMIC_INIT(USB_US_DEFAULT_BIAS);
30#define BIAS_NAME_SIZE (sizeof("usb-storage")) 31#define BIAS_NAME_SIZE (sizeof("usb-storage"))
31static const char *bias_names[3] = { "none", "usb-storage", "ub" }; 32static const char *bias_names[3] = { "none", "usb-storage", "ub" };
32 33
33static struct semaphore usu_init_notify; 34static DEFINE_MUTEX(usu_probe_mutex);
34static DECLARE_COMPLETION(usu_end_notify); 35static DECLARE_COMPLETION(usu_end_notify);
35static atomic_t total_threads = ATOMIC_INIT(0); 36static atomic_t total_threads = ATOMIC_INIT(0);
36 37
@@ -178,10 +179,7 @@ static int usu_probe_thread(void *arg)
178 int rc; 179 int rc;
179 unsigned long flags; 180 unsigned long flags;
180 181
181 /* A completion does not work here because it's counted. */ 182 mutex_lock(&usu_probe_mutex);
182 down(&usu_init_notify);
183 up(&usu_init_notify);
184
185 rc = request_module(bias_names[type]); 183 rc = request_module(bias_names[type]);
186 spin_lock_irqsave(&usu_lock, flags); 184 spin_lock_irqsave(&usu_lock, flags);
187 if (rc == 0 && (st->fls & USU_MOD_FL_PRESENT) == 0) { 185 if (rc == 0 && (st->fls & USU_MOD_FL_PRESENT) == 0) {
@@ -194,6 +192,7 @@ static int usu_probe_thread(void *arg)
194 } 192 }
195 st->fls &= ~USU_MOD_FL_THREAD; 193 st->fls &= ~USU_MOD_FL_THREAD;
196 spin_unlock_irqrestore(&usu_lock, flags); 194 spin_unlock_irqrestore(&usu_lock, flags);
195 mutex_unlock(&usu_probe_mutex);
197 196
198 complete_and_exit(&usu_end_notify, 0); 197 complete_and_exit(&usu_end_notify, 0);
199} 198}
@@ -204,10 +203,9 @@ static int __init usb_usual_init(void)
204{ 203{
205 int rc; 204 int rc;
206 205
207 sema_init(&usu_init_notify, 0); 206 mutex_lock(&usu_probe_mutex);
208
209 rc = usb_register(&usu_driver); 207 rc = usb_register(&usu_driver);
210 up(&usu_init_notify); 208 mutex_unlock(&usu_probe_mutex);
211 return rc; 209 return rc;
212} 210}
213 211