summaryrefslogtreecommitdiff
path: root/drivers/usb/gadget/f_mass_storage.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/gadget/f_mass_storage.c')
-rw-r--r--drivers/usb/gadget/f_mass_storage.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
index be6b418..b1fe8bd 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -243,6 +243,7 @@
#include <config.h>
#include <malloc.h>
#include <common.h>
+#include <usb.h>
#include <linux/err.h>
#include <linux/usb/ch9.h>
@@ -675,6 +676,18 @@ static int sleep_thread(struct fsg_common *common)
k++;
}
+ if (k == 10) {
+ /* Handle CTRL+C */
+ if (ctrlc())
+ return -EPIPE;
+#ifdef CONFIG_USB_CABLE_CHECK
+ /* Check cable connection */
+ if (!usb_cable_connected())
+ return -EIO;
+#endif
+ k = 0;
+ }
+
usb_gadget_handle_interrupts();
}
common->thread_wakeup_needed = 0;
@@ -2387,6 +2400,7 @@ static void handle_exception(struct fsg_common *common)
int fsg_main_thread(void *common_)
{
+ int ret;
struct fsg_common *common = the_fsg_common;
/* The main loop */
do {
@@ -2396,12 +2410,16 @@ int fsg_main_thread(void *common_)
}
if (!common->running) {
- sleep_thread(common);
+ ret = sleep_thread(common);
+ if (ret)
+ return ret;
+
continue;
}
- if (get_next_command(common))
- continue;
+ ret = get_next_command(common);
+ if (ret)
+ return ret;
if (!exception_in_progress(common))
common->state = FSG_STATE_DATA_PHASE;