summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsakumisu <[email protected]>2023-11-17 21:05:07 +0800
committersakumisu <[email protected]>2023-11-17 21:05:07 +0800
commita08097c90e725370aea9060e4425f7082a0265ed (patch)
tree9a640246def33b31659ccd13d484b8e528443c05
parent5bbe2a97f25ca780dde2bab0e9aafab46bac8913 (diff)
use static urb for ep0
-rw-r--r--class/hub/usbh_hub.c3
-rw-r--r--core/usbh_core.c5
-rw-r--r--core/usbh_core.h10
3 files changed, 8 insertions, 10 deletions
diff --git a/class/hub/usbh_hub.c b/class/hub/usbh_hub.c
index 6c8020dd..343b229d 100644
--- a/class/hub/usbh_hub.c
+++ b/class/hub/usbh_hub.c
@@ -308,6 +308,7 @@ static void usbh_hubport_release(struct usbh_hubport *child)
}
}
child->config.config_desc.bNumInterfaces = 0;
+ usbh_kill_urb(&child->ep0_urb);
}
}
@@ -600,7 +601,7 @@ static void usbh_hub_events(struct usbh_hub *hub)
USB_LOG_INFO("New %s device on Hub %u, Port %u connected\r\n", speed_table[speed], hub->index, port + 1);
/* create disposable thread to enumerate device on current hport, do not block hub thread */
- child->thread = usb_osal_thread_create("usbh_enum", CONFIG_USBHOST_PSC_STACKSIZE, CONFIG_USBHOST_PSC_PRIO + 1, usbh_hubport_enumerate_thread, (void *)child);
+ usb_osal_thread_create("usbh_enum", CONFIG_USBHOST_PSC_STACKSIZE, CONFIG_USBHOST_PSC_PRIO + 1, usbh_hubport_enumerate_thread, (void *)child);
} else {
child = &hub->child[port];
/** release child sources */
diff --git a/core/usbh_core.c b/core/usbh_core.c
index 025d0ecf..a02cfee0 100644
--- a/core/usbh_core.c
+++ b/core/usbh_core.c
@@ -672,16 +672,13 @@ int usbh_control_transfer(struct usbh_hubport *hport, struct usb_setup_packet *s
struct usbh_urb *urb;
int ret;
- urb = usb_malloc(sizeof(struct usbh_urb));
- memset(urb, 0, sizeof(struct usbh_urb));
+ urb = &hport->ep0_urb;
usbh_control_urb_fill(urb, hport, setup, buffer, setup->wLength, CONFIG_USBHOST_CONTROL_TRANSFER_TIMEOUT, NULL, NULL);
-
ret = usbh_submit_urb(urb);
if (ret == 0) {
ret = urb->actual_length;
}
- usb_free(urb);
return ret;
}
diff --git a/core/usbh_core.h b/core/usbh_core.h
index 5f538329..6678b6be 100644
--- a/core/usbh_core.h
+++ b/core/usbh_core.h
@@ -99,7 +99,6 @@ struct usbh_hubport {
uint8_t port; /* Hub port index */
uint8_t dev_addr; /* device address */
uint8_t speed; /* device speed */
- struct usb_endpoint_descriptor ep0;
struct usb_device_descriptor device_desc;
struct usbh_configuration config;
const char *iManufacturer;
@@ -111,7 +110,8 @@ struct usbh_hubport {
#ifdef CONFIG_USBHOST_XHCI
uint32_t protocol; /* port protocol, for xhci, some ports are USB2.0, others are USB3.0 */
#endif
- usb_osal_thread_t thread;
+ struct usb_endpoint_descriptor ep0;
+ struct usbh_urb ep0_urb;
};
struct usbh_hub {
@@ -120,12 +120,12 @@ struct usbh_hub {
bool is_roothub;
uint8_t index;
uint8_t hub_addr;
- struct usb_endpoint_descriptor *intin;
- uint8_t *int_buffer;
- struct usbh_urb intin_urb;
struct usb_hub_descriptor hub_desc;
struct usbh_hubport child[CONFIG_USBHOST_MAX_EHPORTS];
struct usbh_hubport *parent;
+ struct usb_endpoint_descriptor *intin;
+ struct usbh_urb intin_urb;
+ uint8_t *int_buffer;
};
static inline void usbh_control_urb_fill(struct usbh_urb *urb,