diff mbox series

[v1] dfu: Reset timeout in case of DFU request

Message ID 20200129152314.86550-1-andriy.shevchenko@linux.intel.com
State Accepted
Commit 53d9bd4a568d6d187c894ce539ad2595023dfc2b
Headers show
Series [v1] dfu: Reset timeout in case of DFU request | expand

Commit Message

Andy Shevchenko Jan. 29, 2020, 3:23 p.m. UTC
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 at linux.intel.com>
---
 drivers/usb/gadget/f_dfu.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Ferry Toth Jan. 30, 2020, 9:27 a.m. UTC | #1
Op 29-01-2020 om 16:23 schreef Andy Shevchenko:
> 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 at linux.intel.com>
> ---
>   drivers/usb/gadget/f_dfu.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/usb/gadget/f_dfu.c b/drivers/usb/gadget/f_dfu.c
> index 6756155133..a4a57ba5f5 100644
> --- a/drivers/usb/gadget/f_dfu.c
> +++ b/drivers/usb/gadget/f_dfu.c
> @@ -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) {
> 
Tested-by: Ferry Toth <ftoth at exalondelft.nl>
diff mbox series

Patch

diff --git a/drivers/usb/gadget/f_dfu.c b/drivers/usb/gadget/f_dfu.c
index 6756155133..a4a57ba5f5 100644
--- a/drivers/usb/gadget/f_dfu.c
+++ b/drivers/usb/gadget/f_dfu.c
@@ -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) {