On STM32MP157C-DK2, when aborting the command "ums" using CTRL-C
it may take a while to get the control back on the console,
sometimes around 1 second.

By removing the if (k == 10) test, it increases the CTRL+C responsiveness.

Tested on STM32MP157C-DK board.

Signed-off-by: Marek Vasut <[email protected]>
Signed-off-by: Patrice Chotard <[email protected]>
---
 drivers/usb/gadget/f_mass_storage.c | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/drivers/usb/gadget/f_mass_storage.c 
b/drivers/usb/gadget/f_mass_storage.c
index 7eb667c130d..e567fd03046 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -651,7 +651,7 @@ static void busy_indicator(void)
 static int sleep_thread(struct fsg_common *common)
 {
        int     rc = 0;
-       int i = 0, k = 0;
+       int i = 0;
 
        /* Wait until a signal arrives or we are woken up */
        for (;;) {
@@ -661,24 +661,19 @@ static int sleep_thread(struct fsg_common *common)
                if (++i == 20000) {
                        busy_indicator();
                        i = 0;
-                       k++;
                }
 
-               if (k == 10) {
-                       /* Handle START-STOP UNIT */
-                       if (common->eject)
-                               return -EPIPE;
+               /* Handle START-STOP UNIT */
+               if (common->eject)
+                       return -EPIPE;
 
-                       /* Handle CTRL+C */
-                       if (ctrlc())
-                               return -EPIPE;
+               /* Handle CTRL+C */
+               if (ctrlc())
+                       return -EPIPE;
 
-                       /* Check cable connection */
-                       if (!g_dnl_board_usb_cable_connected())
-                               return -EIO;
-
-                       k = 0;
-               }
+               /* Check cable connection */
+               if (!g_dnl_board_usb_cable_connected())
+                       return -EIO;
 
                schedule();
                dm_usb_gadget_handle_interrupts(udcdev);

---
base-commit: b4ac71db13a33c4e6532c60a781ddf34b7f4375a
change-id: 20260917-ums_increase_ctrl-c_responsiveness-0824bf3ede7b

Best regards,
--  
Patrice Chotard <[email protected]>

Reply via email to