diff options
author | Przemyslaw Marczak <p.marczak@samsung.com> | 2013-10-23 14:30:46 +0200 |
---|---|---|
committer | Marek Vasut <marex@denx.de> | 2013-11-08 20:46:19 +0100 |
commit | 351e9b206934c2d4a6a0acd1547caf077e4e675c (patch) | |
tree | 6914a94379d73081a2f61f35e7d9d865ced5f5a5 /drivers | |
parent | 4b19ed6c765eb7f8a8873ab05db5c2dfca7f554a (diff) | |
download | u-boot-imx-351e9b206934c2d4a6a0acd1547caf077e4e675c.zip u-boot-imx-351e9b206934c2d4a6a0acd1547caf077e4e675c.tar.gz u-boot-imx-351e9b206934c2d4a6a0acd1547caf077e4e675c.tar.bz2 |
usb: ums: add ums exit feature by ctrl+c or by detach usb cable
This patch allows exiting from UMS mode to u-boot prompt
by detaching usb cable or by pressing ctrl+c.
Add new config: CONFIG_USB_CABLE_CHECK. If defined then board
file should provide function: usb_cable_connected() (include/usb.h)
that return 1 if cable is connected and 0 otherwise.
Changes v2:
- add a note to the README
Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com>
Cc: Marek Vasut <marex@denx.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/gadget/f_mass_storage.c | 24 |
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; |