]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/usb/storage/usb.c
Merge branch 'for-3.3' of git://linux-nfs.org/~bfields/linux
[karo-tx-linux.git] / drivers / usb / storage / usb.c
index 0ca095820f3e7ca10c98e27a4eaeea728e5c533e..3dd7da9fd5043cad98a00e552ba8c11ebe9ff581 100644 (file)
@@ -832,13 +832,24 @@ static int usb_stor_scan_thread(void * __us)
        dev_dbg(dev, "device found\n");
 
        set_freezable();
-       /* Wait for the timeout to expire or for a disconnect */
+
+       /*
+        * Wait for the timeout to expire or for a disconnect
+        *
+        * We can't freeze in this thread or we risk causing khubd to
+        * fail to freeze, but we can't be non-freezable either. Nor can
+        * khubd freeze while waiting for scanning to complete as it may
+        * hold the device lock, causing a hang when suspending devices.
+        * So instead of using wait_event_freezable(), explicitly test
+        * for (DONT_SCAN || freezing) in interruptible wait and proceed
+        * if any of DONT_SCAN, freezing or timeout has happened.
+        */
        if (delay_use > 0) {
                dev_dbg(dev, "waiting for device to settle "
                                "before scanning\n");
-               wait_event_freezable_timeout(us->delay_wait,
-                               test_bit(US_FLIDX_DONT_SCAN, &us->dflags),
-                               delay_use * HZ);
+               wait_event_interruptible_timeout(us->delay_wait,
+                               test_bit(US_FLIDX_DONT_SCAN, &us->dflags) ||
+                               freezing(current), delay_use * HZ);
        }
 
        /* If the device is still connected, perform the scanning */
@@ -1063,6 +1074,7 @@ static struct usb_driver usb_storage_driver = {
        .id_table =     usb_storage_usb_ids,
        .supports_autosuspend = 1,
        .soft_unbind =  1,
+       .no_dynamic_id = 1,
 };
 
 static int __init usb_stor_init(void)