From e581097309c5ad54f987dd567555f844dba42357 Mon Sep 17 00:00:00 2001 From: sakumisu <1203593632@qq.com> Date: Tue, 4 Mar 2025 17:07:36 +0800 Subject: [PATCH] fix(core/usbd_core): fix two bugs - fix current_desc_len += p[DESC_bLength] before p+= p[DESC_bLength] - fix reset all eps when alt_setting=0 Signed-off-by: sakumisu <1203593632@qq.com> --- core/usbd_core.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/core/usbd_core.c b/core/usbd_core.c index a02bc3c..2a2fda4 100644 --- a/core/usbd_core.c +++ b/core/usbd_core.c @@ -446,8 +446,8 @@ static bool usbd_set_configuration(uint8_t busid, uint8_t config_index, uint8_t } /* skip to next descriptor */ - p += p[DESC_bLength]; current_desc_len += p[DESC_bLength]; + p += p[DESC_bLength]; if (current_desc_len >= desc_len && desc_len) { break; } @@ -512,7 +512,6 @@ static bool usbd_set_interface(uint8_t busid, uint8_t iface, uint8_t alt_setting if (alt_setting == 0) { ret = usbd_reset_endpoint(busid, ep_desc); - goto find_end; } else if (cur_alt_setting == alt_setting) { ret = usbd_set_endpoint(busid, ep_desc); } else { @@ -526,14 +525,13 @@ static bool usbd_set_interface(uint8_t busid, uint8_t iface, uint8_t alt_setting } /* skip to next descriptor */ - p += p[DESC_bLength]; current_desc_len += p[DESC_bLength]; + p += p[DESC_bLength]; if (current_desc_len >= desc_len && desc_len) { break; } } -find_end: usbd_class_event_notify_handler(busid, USBD_EVENT_SET_INTERFACE, (void *)if_desc); return ret; @@ -700,8 +698,8 @@ static bool usbd_std_interface_req_handler(uint8_t busid, struct usb_setup_packe } /* skip to next descriptor */ - p += p[DESC_bLength]; current_desc_len += p[DESC_bLength]; + p += p[DESC_bLength]; if (current_desc_len >= desc_len && desc_len) { break; }