]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
cmd: ums: abort mounting by pressing any key
authorSvyatoslav Ryhel <clamor95@gmail.com>
Mon, 20 Mar 2023 19:01:43 +0000 (21:01 +0200)
committerTom Rini <trini@konsulko.com>
Thu, 30 Mar 2023 19:09:59 +0000 (15:09 -0400)
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@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
cmd/Kconfig
cmd/usb_mass_storage.c

index 8138ab98eabef3e06696aa1d7dd39a5ffcb8bb6e..8c9b430f99f5450f85377899509fa3423fbca949 100644 (file)
@@ -1552,6 +1552,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 CMD_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
index b7daaa6e8e842390472c2ae4b70dd26a491a9a4e..c3cc1975f9d8b2b0858f6007e89e891ec2e7e2ea 100644 (file)
@@ -231,6 +231,16 @@ static int do_usb_mass_storage(struct cmd_tbl *cmdtp, int flag,
                        goto cleanup_register;
                }
 
+               if (IS_ENABLED(CONFIG_CMD_UMS_ABORT_KEYED)) {
+                       /* Abort by pressing any key */
+                       if (tstc()) {
+                               getchar();
+                               printf("\rOperation aborted.\n");
+                               rc = CMD_RET_SUCCESS;
+                               goto cleanup_register;
+                       }
+               }
+
                schedule();
        }