diff options
-rw-r--r-- | src/drivers/bus/usb.c | 10 | ||||
-rw-r--r-- | src/include/ipxe/usb.h | 8 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/drivers/bus/usb.c b/src/drivers/bus/usb.c index 2b9efa4..3484cba 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 ); diff --git a/src/include/ipxe/usb.h b/src/include/ipxe/usb.h index 50d8a6f..d326678 100644 --- a/src/include/ipxe/usb.h +++ b/src/include/ipxe/usb.h @@ -916,6 +916,8 @@ struct usb_bus { /** Root hub */ struct usb_hub *hub; + /** List of USB buses */ + struct list_head list; /** List of devices */ struct list_head devices; /** List of hubs */ @@ -999,6 +1001,10 @@ usb_poll ( struct usb_bus *bus ) { bus->host->poll ( bus ); } +/** Iterate over all USB buses */ +#define for_each_usb_bus( bus ) \ + list_for_each_entry ( (bus), &usb_buses, list ) + /** * Complete transfer (without error) * @@ -1182,6 +1188,8 @@ usb_set_interface ( struct usb_device *usb, unsigned int interface, NULL, 0 ); } +extern struct list_head usb_buses; + extern struct usb_interface_descriptor * usb_interface_descriptor ( struct usb_configuration_descriptor *config, unsigned int interface, unsigned int alternate ); |