[coreboot] New patch to review for coreboot: a194d14 libpayload: Detach devices behind removed USB hubs

Nico Huber (nico.huber@secunet.com) gerrit at coreboot.org
Fri Nov 23 15:01:02 CET 2012


Nico Huber (nico.huber at secunet.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/1903

-gerrit

commit a194d14df2677e48ac3726106a6545ebded463a5
Author: Nico Huber <nico.huber at secunet.com>
Date:   Thu Nov 22 11:18:19 2012 +0100

    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 at secunet.com>
---
 payloads/libpayload/drivers/usb/usbhub.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/payloads/libpayload/drivers/usb/usbhub.c b/payloads/libpayload/drivers/usb/usbhub.c
index 47215fc..90e08db 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));




More information about the coreboot mailing list