]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[usb] Add find_usb_bus_by_location() helper function
authorMichael Brown <mcb30@ipxe.org>
Fri, 8 May 2015 15:50:47 +0000 (16:50 +0100)
committerMichael Brown <mcb30@ipxe.org>
Sat, 9 May 2015 19:09:08 +0000 (20:09 +0100)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/drivers/bus/usb.c
src/include/ipxe/usb.h

index 16f182595762d77cab81cb9590df276ee2f07b47..0fe6da2042824508cdf3aed7e81c07e930e1f56a 100644 (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
index ee826bc117c5f16582979d50df08bf90d80a7b89..eb5b99f8a9651cdabb4929192b9c38724ab0b12d 100644 (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 );