summaryrefslogtreecommitdiff
path: root/src/host
diff options
context:
space:
mode:
authorScott Shawcroft <[email protected]>2024-03-27 11:21:13 -0700
committerhathach <[email protected]>2024-03-28 21:41:59 +0700
commitd50003e33d89740c0993ae236629392df82453c2 (patch)
treea78d7c0abf36f5d2483c917365ec2a8f49ad420c /src/host
parenta5a90937b4d6c2d67491ed335fd901a77c2ac50f (diff)
Fake unplug devices when a root hub is deinit
Diffstat (limited to 'src/host')
-rw-r--r--src/host/usbh.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/host/usbh.c b/src/host/usbh.c
index f2dc2f7c1..29c6eb1e9 100644
--- a/src/host/usbh.c
+++ b/src/host/usbh.c
@@ -415,6 +415,15 @@ bool tuh_deinit(uint8_t rhport) {
_usbh_controller = TUSB_INDEX_INVALID_8;
+ // "unplug" all devices on this rhport
+ for (uint8_t idx = 0; idx < CFG_TUH_DEVICE_MAX + CFG_TUH_HUB; idx++) {
+ usbh_device_t *dev = &_usbh_devices[idx];
+ if (!dev->connected || dev->rhport != rhport) {
+ continue;
+ }
+ process_removing_device(rhport, dev->hub_addr, dev->hub_port);
+ }
+
// deinit host stack if no controller is active
if (!tuh_inited()) {
// Class drivers