瀏覽代碼

[usb] Add find_usb_bus_by_location() helper function

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 9 年之前
父節點
當前提交
a66fd8920d
共有 2 個文件被更改,包括 22 次插入0 次删除
  1. 20
    0
      src/drivers/bus/usb.c
  2. 2
    0
      src/include/ipxe/usb.h

+ 20
- 0
src/drivers/bus/usb.c 查看文件

@@ -1976,6 +1976,26 @@ void free_usb_bus ( struct usb_bus *bus ) {
1976 1976
 	free ( bus );
1977 1977
 }
1978 1978
 
1979
+/**
1980
+ * Find USB bus by device location
1981
+ *
1982
+ * @v bus_type		Bus type
1983
+ * @v location		Bus location
1984
+ * @ret bus		USB bus, or NULL
1985
+ */
1986
+struct usb_bus * find_usb_bus_by_location ( unsigned int bus_type,
1987
+					    unsigned int location ) {
1988
+	struct usb_bus *bus;
1989
+
1990
+	for_each_usb_bus ( bus ) {
1991
+		if ( ( bus->dev->desc.bus_type == bus_type ) &&
1992
+		     ( bus->dev->desc.location == location ) )
1993
+			return bus;
1994
+	}
1995
+
1996
+	return NULL;
1997
+}
1998
+
1979 1999
 /******************************************************************************
1980 2000
  *
1981 2001
  * USB address assignment

+ 2
- 0
src/include/ipxe/usb.h 查看文件

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

Loading…
取消
儲存