summaryrefslogtreecommitdiffstats
path: root/src/drivers/bus
diff options
context:
space:
mode:
authorMichael Brown2015-05-08 16:07:26 +0200
committerMichael Brown2015-05-09 20:37:29 +0200
commit5e1e2069fd438b50b085416597d01009d13bc87b (patch)
tree56ba7f49849a6dd4e5bc13bf19d8df34141710ca /src/drivers/bus
parent[usb] Detect missed disconnections (diff)
downloadipxe-5e1e2069fd438b50b085416597d01009d13bc87b.tar.gz
ipxe-5e1e2069fd438b50b085416597d01009d13bc87b.tar.xz
ipxe-5e1e2069fd438b50b085416597d01009d13bc87b.zip
[usb] Maintain a list of all USB buses
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/drivers/bus')
-rw-r--r--src/drivers/bus/usb.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/drivers/bus/usb.c b/src/drivers/bus/usb.c
index 2b9efa45..3484cba1 100644
--- a/src/drivers/bus/usb.c
+++ b/src/drivers/bus/usb.c
@@ -40,6 +40,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
*
*/
+/** List of USB buses */
+struct list_head usb_buses = LIST_HEAD_INIT ( usb_buses );
+
/******************************************************************************
*
* Utility functions
@@ -1894,6 +1897,9 @@ int register_usb_bus ( struct usb_bus *bus ) {
if ( ( rc = bus->host->open ( bus ) ) != 0 )
goto err_open;
+ /* Add to list of USB buses */
+ list_add_tail ( &bus->list, &usb_buses );
+
/* Register root hub */
if ( ( rc = register_usb_hub ( bus->hub ) ) != 0 )
goto err_register_hub;
@@ -1905,6 +1911,7 @@ int register_usb_bus ( struct usb_bus *bus ) {
unregister_usb_hub ( bus->hub );
err_register_hub:
+ list_del ( &bus->list );
bus->host->close ( bus );
err_open:
return rc;
@@ -1927,6 +1934,9 @@ void unregister_usb_bus ( struct usb_bus *bus ) {
/* Unregister root hub */
unregister_usb_hub ( bus->hub );
+ /* Remove from list of USB buses */
+ list_del ( &bus->list );
+
/* Close bus */
bus->host->close ( bus );