This patch does the following:
(o) Add comments showing what needs to be done to complete the hot-unplug
    system.
(o) Add a BUG_ON() for (what is now) a critical failure case.
(o) Make certain that a debug print happens even if a usb_get_intfdata()
    crashes.
(o) Add an un-necessary up() to balance a down, for the auto-code-checkers.

Greg, please apply.

Matt

# This is a BitKeeper generated patch for the following project:
# Project Name: greg k-h's linux 2.5 USB kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#                  ChangeSet    1.669   -> 1.670  
#       drivers/usb/storage/usb.c       1.70    -> 1.71   
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/01/25      [EMAIL PROTECTED]       1.670
# Add comments showing what needs to be done to complete the hot-unplug
# system.
# 
# Add a BUG_ON() for (what is now) a critical failure case.
# 
# Make certain that a debug print happens even if a usb_get_intfdata()
# crashes.
# 
# Add an un-necessary up() to balance a down, for the auto-code-checkers.
# --------------------------------------------
#
diff -Nru a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
--- a/drivers/usb/storage/usb.c Sat Jan 25 13:08:16 2003
+++ b/drivers/usb/storage/usb.c Sat Jan 25 13:08:16 2003
@@ -970,21 +970,29 @@
 /* Handle a disconnect event from the USB core */
 static void storage_disconnect(struct usb_interface *intf)
 {
-       struct us_data *ss = usb_get_intfdata(intf);
+       struct us_data *ss;
 
        US_DEBUGP("storage_disconnect() called\n");
 
+               ss = usb_get_intfdata(intf);
        usb_set_intfdata(intf, NULL);
 
-       /* this is the odd case -- we disconnected but weren't using it */
-       if (!ss) {
-               US_DEBUGP("-- device was not in use\n");
-               return;
-       }
+       /* serious error -- we're attempting to disconnect an interface but
+        * cannot locate the local data structure
+        */
+       BUG_ON(ss == NULL);
+
+       /* TODO: set devices offline -- need host lock for this */
 
        /* lock device access -- no need to unlock, as we're going away */
        down(&(ss->dev_semaphore));
 
+       /* TODO: complete all pending commands with
+        * cmd->result = DID_ERROR << 16 */
+
+       /* TODO: somehow, wait for the device to
+        * be 'idle' (tasklet completion) */
+
        /* remove the pointer to the data structure we were using */
        (struct us_data*)ss->host->hostdata[0] = NULL;
 
@@ -1025,6 +1033,10 @@
                US_DEBUGP("-- freeing the data structure\n");
                kfree(ss->extra);
        }
+
+       /* up the semaphore so auto-code-checkers won't complain about
+        * the down/up imbalance */
+       up(&(ss->dev_semaphore));
 
        /* free the structure itself */
        kfree (ss);
-- 
Matthew Dharm                              Home: [EMAIL PROTECTED] 
Maintainer, Linux USB Mass Storage Driver

Why am I talking to a toilet brush?
                                        -- CEO
User Friendly, 4/30/1998

Attachment: msg11089/pgp00000.pgp
Description: PGP signature

Reply via email to