dfu: Reset timeout in case of DFU request
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Wed, 29 Jan 2020 15:23:14 +0000 (17:23 +0200)
committerMarek Vasut <marek.vasut+renesas@gmail.com>
Sun, 1 Mar 2020 20:58:54 +0000 (21:58 +0100)
In case dfu command is being executed with timeout option,
the timer may expire in the middle of DFU operation. If there
is DFU request coming, we may simple reset timeout value
to prevent aborting of ongoing DFU operation.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Ferry Toth <ftoth@exalondelft.nl>
drivers/usb/gadget/f_dfu.c

index 675615513304cbafe0d7d88cda9d7d6a81eddc39..a4a57ba5f59492df1df325d4b08d97c492de382b 100644 (file)
@@ -596,6 +596,11 @@ dfu_handle(struct usb_function *f, const struct usb_ctrlrequest *ctrl)
        debug("req_type: 0x%x ctrl->bRequest: 0x%x f_dfu->dfu_state: 0x%x\n",
               req_type, ctrl->bRequest, f_dfu->dfu_state);
 
+#ifdef CONFIG_DFU_TIMEOUT
+       /* Forbid aborting by timeout. Next dfu command may update this */
+       dfu_set_timeout(0);
+#endif
+
        if (req_type == USB_TYPE_STANDARD) {
                if (ctrl->bRequest == USB_REQ_GET_DESCRIPTOR &&
                    (w_value >> 8) == DFU_DT_FUNC) {