[PATCH v1 2/2] cmd: ums: abort mounting by pressing any key

Svyatoslav Ryhel clamor95 at gmail.com
Mon Jan 23 21:03:54 CET 2023


This patch introduses config which allows interrupt run of usb
mass storage with any key. This is especially useful on devices
with limited input capabilities like tablets and smatphones which
have only gpio keys in direct access.

Signed-off-by: Svyatoslav Ryhel <clamor95 at gmail.com>
---
 cmd/Kconfig            | 6 ++++++
 cmd/usb_mass_storage.c | 9 +++++++++
 2 files changed, 15 insertions(+)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index 4fe2c75de2..5c177f87ea 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -1536,6 +1536,12 @@ config CMD_USB_MASS_STORAGE
 	  export a block device: U-Boot, the USB device, acts as a simple
 	  external hard drive plugged on the host USB port.
 
+config UMS_ABORT_KEYED
+	bool "UMS abort with any key"
+	depends on CMD_USB_MASS_STORAGE
+	help
+	  Allow interruption of usb mass storage run with any key pressed.
+
 config CMD_PVBLOCK
 	bool "Xen para-virtualized block device"
 	depends on XEN
diff --git a/cmd/usb_mass_storage.c b/cmd/usb_mass_storage.c
index b7daaa6e8e..ade81013d0 100644
--- a/cmd/usb_mass_storage.c
+++ b/cmd/usb_mass_storage.c
@@ -231,6 +231,15 @@ static int do_usb_mass_storage(struct cmd_tbl *cmdtp, int flag,
 			goto cleanup_register;
 		}
 
+		if (IS_ENABLED(CONFIG_UMS_ABORT_KEYED)) {
+			/* Abort by pressing any key */
+			if (getchar()) {
+				printf("\rOperation aborted.\n");
+				rc = CMD_RET_SUCCESS;
+				goto cleanup_register;
+			}
+		}
+
 		schedule();
 	}
 
-- 
2.25.1



More information about the U-Boot mailing list