david/ipxe
Archived
1
0

[usb] Add find_usb_bus_by_location() helper function

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown 2015-05-08 16:50:47 +01:00
parent b3de9664c7
commit a66fd8920d
2 changed files with 22 additions and 0 deletions

View File

@ -1976,6 +1976,26 @@ void free_usb_bus ( struct usb_bus *bus ) {
free ( bus );
}
/**
* Find USB bus by device location
*
* @v bus_type Bus type
* @v location Bus location
* @ret bus USB bus, or NULL
*/
struct usb_bus * find_usb_bus_by_location ( unsigned int bus_type,
unsigned int location ) {
struct usb_bus *bus;
for_each_usb_bus ( bus ) {
if ( ( bus->dev->desc.bus_type == bus_type ) &&
( bus->dev->desc.location == location ) )
return bus;
}
return NULL;
}
/******************************************************************************
*
* USB address assignment

View File

@ -1211,6 +1211,8 @@ extern struct usb_bus * alloc_usb_bus ( struct device *dev,
extern int register_usb_bus ( struct usb_bus *bus );
extern void unregister_usb_bus ( struct usb_bus *bus );
extern void free_usb_bus ( struct usb_bus *bus );
extern struct usb_bus * find_usb_bus_by_location ( unsigned int bus_type,
unsigned int location );
extern int usb_alloc_address ( struct usb_bus *bus );
extern void usb_free_address ( struct usb_bus *bus, unsigned int address );