summaryrefslogtreecommitdiff
path: root/drivers/usb
diff options
context:
space:
mode:
authorJared Suttles <jared.suttles@motorola.com>2009-08-28 16:53:32 -0500
committerMike Lockwood <lockwood@android.com>2009-08-28 17:51:33 -0700
commit706346b927f090a4e75012f1c70d63f29223798c (patch)
tree57c846b287bdce402666bda42a6676fc0862791d /drivers/usb
parent53786ff7029712339acca43249d3edab89391d52 (diff)
usb: gadget: mass_storage: Fix Mass Storage Panic during PC reboot
Submitted on behalf of RaviKumar Vembu <ravi.v@motorola.com> Signed-off-by: Jared Suttles <jared.suttles@motorola.com> Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/gadget/f_mass_storage.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
index 86b128c68451..d81ce9ebf842 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -2079,8 +2079,12 @@ static int get_next_command(struct fsg_dev *fsg)
/* Wait for the CBW to arrive */
while (bh->state != BUF_STATE_FULL) {
rc = sleep_thread(fsg);
- if (rc)
+ if (rc) {
+ usb_ep_dequeue(fsg->bulk_out, bh->outreq);
+ bh->outreq_busy = 0;
+ bh->state = BUF_STATE_EMPTY;
return rc;
+ }
}
smp_rmb();
rc = received_cbw(fsg, bh);
@@ -2129,12 +2133,22 @@ static int do_set_interface(struct fsg_dev *fsg, int altsetting)
if (fsg->running)
DBG(fsg, "reset interface\n");
-
reset:
+ /* Disable the endpoints */
+ if (fsg->bulk_in_enabled) {
+ DBG(fsg, "usb_ep_disable %s\n", fsg->bulk_in->name);
+ usb_ep_disable(fsg->bulk_in);
+ fsg->bulk_in_enabled = 0;
+ }
+ if (fsg->bulk_out_enabled) {
+ DBG(fsg, "usb_ep_disable %s\n", fsg->bulk_out->name);
+ usb_ep_disable(fsg->bulk_out);
+ fsg->bulk_out_enabled = 0;
+ }
+
/* Deallocate the requests */
for (i = 0; i < NUM_BUFFERS; ++i) {
struct fsg_buffhd *bh = &fsg->buffhds[i];
-
if (bh->inreq) {
usb_ep_free_request(fsg->bulk_in, bh->inreq);
bh->inreq = NULL;
@@ -2145,17 +2159,6 @@ reset:
}
}
- /* Disable the endpoints */
- if (fsg->bulk_in_enabled) {
- DBG(fsg, "usb_ep_disable %s\n", fsg->bulk_in->name);
- usb_ep_disable(fsg->bulk_in);
- fsg->bulk_in_enabled = 0;
- }
- if (fsg->bulk_out_enabled) {
- DBG(fsg, "usb_ep_disable %s\n", fsg->bulk_out->name);
- usb_ep_disable(fsg->bulk_out);
- fsg->bulk_out_enabled = 0;
- }
fsg->running = 0;
if (altsetting < 0 || rc != 0)
@@ -2342,7 +2345,10 @@ static void handle_exception(struct fsg_dev *fsg)
case FSG_STATE_EXIT:
case FSG_STATE_TERMINATED:
- do_set_interface(fsg, -1);
+ if (new_config) {
+ fsg->new_config = 0;
+ do_set_interface(fsg, -1);
+ }
do_set_config(fsg, 0); /* Free resources */
spin_lock_irq(&fsg->lock);
fsg->state = FSG_STATE_TERMINATED; /* Stop the thread */