]> git.sur5r.net Git - u-boot/blobdiff - drivers/usb/gadget/f_mass_storage.c
Merge branch 'u-boot-ti/master' into 'u-boot-arm/master'
[u-boot] / drivers / usb / gadget / f_mass_storage.c
index be6b418d4e82fffe03e8041912e03100cb848335..b1fe8bd3a805df4a1d97d50395a128a30ad21eaa 100644 (file)
 #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;