Commit dc18a916 authored by Matthew Dharm's avatar Matthew Dharm Committed by Greg Kroah-Hartman

[PATCH] usb-storage: comments, cleanup

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.
parent 5d81afb2
...@@ -970,21 +970,29 @@ static int storage_probe(struct usb_interface *intf, ...@@ -970,21 +970,29 @@ static int storage_probe(struct usb_interface *intf,
/* Handle a disconnect event from the USB core */ /* Handle a disconnect event from the USB core */
static void storage_disconnect(struct usb_interface *intf) 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"); US_DEBUGP("storage_disconnect() called\n");
ss = usb_get_intfdata(intf);
usb_set_intfdata(intf, NULL); usb_set_intfdata(intf, NULL);
/* this is the odd case -- we disconnected but weren't using it */ /* serious error -- we're attempting to disconnect an interface but
if (!ss) { * cannot locate the local data structure
US_DEBUGP("-- device was not in use\n"); */
return; 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 */ /* lock device access -- no need to unlock, as we're going away */
down(&(ss->dev_semaphore)); 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 */ /* remove the pointer to the data structure we were using */
(struct us_data*)ss->host->hostdata[0] = NULL; (struct us_data*)ss->host->hostdata[0] = NULL;
...@@ -1026,6 +1034,10 @@ static void storage_disconnect(struct usb_interface *intf) ...@@ -1026,6 +1034,10 @@ static void storage_disconnect(struct usb_interface *intf)
kfree(ss->extra); 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 */ /* free the structure itself */
kfree (ss); kfree (ss);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment