Skip to content

Commit 50dfd79

Browse files
committed
usb_processing: add timeout arg
1 parent 7d497c0 commit 50dfd79

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/u2f.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ static void _process_wait_refresh(void)
984984
} else {
985985
_state.refresh_webpage_timeout++;
986986
/* Prevent the USB watchdog from killing this workflow. */
987-
usb_processing_timeout_reset();
987+
usb_processing_timeout_reset(0);
988988
}
989989
}
990990

src/usb/usb_processing.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ typedef struct {
121121
* USB_OUTSTANDING_OP_TIMEOUT_TICKS, any outstanding operation is aborted
122122
* and the USB stack is forcefully unlocked.
123123
*/
124-
uint16_t timeout_counter;
124+
int16_t timeout_counter;
125125
#endif
126126
} usb_processing_state_t;
127127

@@ -287,7 +287,7 @@ static void _usb_arbitrate_packet(struct usb_processing* ctx, const Packet* in_p
287287
} else {
288288
_usb_execute_packet(ctx, in_packet);
289289
/* New packet processed: reset the watchdog timeout. */
290-
_usb_state.timeout_counter = 0;
290+
usb_processing_timeout_reset(0);
291291
}
292292
}
293293
#endif
@@ -373,7 +373,7 @@ struct usb_processing* usb_processing_hww(void)
373373
static void _timer_cb(const struct timer_task* const timer_task)
374374
{
375375
(void)timer_task;
376-
if (_usb_state.timeout_counter != (uint16_t)-1) {
376+
if (_usb_state.timeout_counter < INT16_MAX) {
377377
_usb_state.timeout_counter++;
378378
}
379379
}
@@ -426,9 +426,9 @@ void usb_processing_lock(struct usb_processing* ctx)
426426
_usb_state.blocking_ctx = ctx;
427427
}
428428

429-
void usb_processing_timeout_reset(void)
429+
void usb_processing_timeout_reset(int16_t val)
430430
{
431-
_usb_state.timeout_counter = 0;
431+
_usb_state.timeout_counter = val;
432432
}
433433

434434
void usb_processing_unlock(void)

src/usb/usb_processing.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void usb_processing_lock(struct usb_processing* ctx);
7373
* expected behaviour, one can call this function to prevent
7474
* the USB watchdog from aborting the outstanding operation.
7575
*/
76-
void usb_processing_timeout_reset(void);
76+
void usb_processing_timeout_reset(int16_t val);
7777

7878
void usb_processing_unlock(void);
7979
#endif

0 commit comments

Comments
 (0)