diff options
author | Nico Huber <nico.huber@secunet.com> | 2012-11-22 11:18:19 +0100 |
---|---|---|
committer | Patrick Georgi <patrick@georgi-clan.de> | 2012-11-23 18:18:31 +0100 |
commit | b2db28babe0e64e08b1a754b65dd7e437f8d82a9 (patch) | |
tree | 505f12ac4f43a4d1a2bf6f4f8a6d922209d69253 /payloads/libpayload/drivers | |
parent | ef88e102bb4895753c8ba67e01ee26fdfe3fa712 (diff) |
libpayload: Detach devices behind removed USB hubs
When a USB hub got removed, we should also remove all devices that
were attached to it.
Change-Id: I73c0da1b7570f1af9726925ca222781b3d752557
Signed-off-by: Nico Huber <nico.huber@secunet.com>
Reviewed-on: http://review.coreboot.org/1903
Reviewed-by: Patrick Georgi <patrick@georgi-clan.de>
Tested-by: build bot (Jenkins)
Diffstat (limited to 'payloads/libpayload/drivers')
-rw-r--r-- | payloads/libpayload/drivers/usb/usbhub.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/payloads/libpayload/drivers/usb/usbhub.c b/payloads/libpayload/drivers/usb/usbhub.c index 47215fcf10..90e08dbde4 100644 --- a/payloads/libpayload/drivers/usb/usbhub.c +++ b/payloads/libpayload/drivers/usb/usbhub.c @@ -53,6 +53,17 @@ typedef struct { static void usb_hub_destroy (usbdev_t *dev) { + int i; + + /* First, detach all devices behind this hub. */ + int *const ports = HUB_INST (dev)->ports; + for (i = 1; i <= HUB_INST (dev)->num_ports; i++) { + if (ports[i] != -1) { + usb_detach_device(dev->controller, ports[i]); + ports[i] = -1; + } + } + free (HUB_INST (dev)->ports); free (HUB_INST (dev)->descriptor); free (HUB_INST (dev)); |