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 /common | |
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 'common')
-rw-r--r-- | common/cmd_usb_mass_storage.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/common/cmd_usb_mass_storage.c b/common/cmd_usb_mass_storage.c index 4d3bbd8..99487f4 100644 --- a/common/cmd_usb_mass_storage.c +++ b/common/cmd_usb_mass_storage.c @@ -5,6 +5,7 @@ * SPDX-License-Identifier: GPL-2.0+ */ +#include <errno.h> #include <common.h> #include <command.h> #include <g_dnl.h> @@ -42,16 +43,20 @@ int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag, g_dnl_register("ums"); while (1) { - /* Handle control-c and timeouts */ - if (ctrlc()) { - error("The remote end did not respond in time."); - goto exit; - } - usb_gadget_handle_interrupts(); - /* Check if USB cable has been detached */ - if (fsg_main_thread(NULL) == EIO) + + rc = fsg_main_thread(NULL); + if (rc) { + /* Check I/O error */ + if (rc == -EIO) + printf("\rCheck USB cable connection\n"); + + /* Check CTRL+C */ + if (rc == -EPIPE) + printf("\rCTRL+C - Operation aborted\n"); + goto exit; + } } exit: g_dnl_unregister(); |