stm32mp: stm32prog: handle interruption during the first enumeration
authorPatrick Delaunay <patrick.delaunay@foss.st.com>
Mon, 28 Mar 2022 17:25:31 +0000 (19:25 +0200)
committerPatrice Chotard <patrice.chotard@foss.st.com>
Tue, 10 May 2022 08:56:39 +0000 (10:56 +0200)
When an interruption is received during the first USB enumeration
used to received the FlashLayout, with handle ctrl-c, the second
enumeration is not needed and the result for stm32prog_usb_loop
is false (reset is not needed).

This patch avoids the need of a second ctrl to interrupt the command
stm32prog.

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog_usb.c

index 82b702f..a8b57c4 100644 (file)
@@ -206,9 +206,12 @@ bool stm32prog_usb_loop(struct stm32prog_data *data, int dev)
        g_dnl_set_product(product);
 
        if (stm32prog_data->phase == PHASE_FLASHLAYOUT) {
+               /* forget any previous Control C */
+               clear_ctrlc();
                ret = run_usb_dnl_gadget(dev, "usb_dnl_dfu");
-               if (ret || stm32prog_data->phase != PHASE_FLASHLAYOUT)
-                       return ret;
+               /* DFU reset received, no error or CtrlC */
+               if (ret || stm32prog_data->phase != PHASE_FLASHLAYOUT || had_ctrlc())
+                       return ret; /* true = reset on DFU error */
                /* prepare the second enumeration with the FlashLayout */
                stm32prog_dfu_init(data);
        }