summaryrefslogtreecommitdiffstats
path: root/src/drivers/usb
diff options
context:
space:
mode:
authorMichael Brown2015-09-14 17:53:05 +0200
committerMichael Brown2015-09-14 22:45:34 +0200
commit549a0caabb2f239fc702ccea3c1825518e13d121 (patch)
treeb89fb7f19ff26d792f50ff027e2755862e87cb1f /src/drivers/usb
parent[efi] Include a copy of the device path within struct efi_device (diff)
downloadipxe-549a0caabb2f239fc702ccea3c1825518e13d121.tar.gz
ipxe-549a0caabb2f239fc702ccea3c1825518e13d121.tar.xz
ipxe-549a0caabb2f239fc702ccea3c1825518e13d121.zip
[usb] Select preferred USB device configuration based on driver score
Generate a score for each possible USB device configuration based on the available driver support, and select the configuration with the highest score. This will allow us to prefer ECM over RNDIS (for devices which support both) and will allow us to meaningfully select a configuration even when we have drivers available for all functions (e.g. when exposing unused functions via EFI_USB_IO_PROTOCOL). Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/drivers/usb')
-rw-r--r--src/drivers/usb/usbhub.c1
-rw-r--r--src/drivers/usb/usbio.c18
-rw-r--r--src/drivers/usb/usbkbd.c1
-rw-r--r--src/drivers/usb/usbnet.c4
4 files changed, 12 insertions, 12 deletions
diff --git a/src/drivers/usb/usbhub.c b/src/drivers/usb/usbhub.c
index bf2a2000..97d21ef4 100644
--- a/src/drivers/usb/usbhub.c
+++ b/src/drivers/usb/usbhub.c
@@ -542,6 +542,7 @@ static struct usb_device_id hub_ids[] = {
struct usb_driver usb_hub_driver __usb_driver = {
.ids = hub_ids,
.id_count = ( sizeof ( hub_ids ) / sizeof ( hub_ids[0] ) ),
+ .score = USB_SCORE_NORMAL,
.probe = hub_probe,
.remove = hub_remove,
};
diff --git a/src/drivers/usb/usbio.c b/src/drivers/usb/usbio.c
index 2c15200c..55c61ed4 100644
--- a/src/drivers/usb/usbio.c
+++ b/src/drivers/usb/usbio.c
@@ -158,7 +158,7 @@ static int usbio_interface ( struct usbio_device *usbio,
continue;
/* Iterate over all interfaces for a match */
- for ( i = 0 ; i < func->count ; i++ ) {
+ for ( i = 0 ; i < func->desc.count ; i++ ) {
if ( interface->interface ==
func->interface[i] )
return interface->interface;
@@ -1287,15 +1287,13 @@ static int usbio_supported ( EFI_HANDLE handle ) {
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
EFI_USB_DEVICE_DESCRIPTOR device;
EFI_USB_INTERFACE_DESCRIPTOR interface;
- struct usb_class class;
+ struct usb_function_descriptor desc;
struct usb_driver *driver;
struct usb_device_id *id;
union {
void *interface;
EFI_USB_IO_PROTOCOL *io;
} usb;
- unsigned int vendor;
- unsigned int product;
EFI_STATUS efirc;
int rc;
@@ -1318,8 +1316,8 @@ static int usbio_supported ( EFI_HANDLE handle ) {
"%s\n", efi_handle_name ( handle ), strerror ( rc ) );
goto err_get_device_descriptor;
}
- vendor = device.IdVendor;
- product = device.IdProduct;
+ desc.vendor = device.IdVendor;
+ desc.product = device.IdProduct;
/* Get interface descriptor */
if ( ( efirc = usb.io->UsbGetInterfaceDescriptor ( usb.io,
@@ -1329,12 +1327,12 @@ static int usbio_supported ( EFI_HANDLE handle ) {
"%s\n", efi_handle_name ( handle ), strerror ( rc ) );
goto err_get_interface_descriptor;
}
- class.class = interface.InterfaceClass;
- class.subclass = interface.InterfaceSubClass;
- class.protocol = interface.InterfaceProtocol;
+ desc.class.class = interface.InterfaceClass;
+ desc.class.subclass = interface.InterfaceSubClass;
+ desc.class.protocol = interface.InterfaceProtocol;
/* Look for a driver for this interface */
- driver = usb_find_driver ( vendor, product, &class, &id );
+ driver = usb_find_driver ( &desc, &id );
if ( ! driver ) {
rc = -ENOTSUP;
goto err_unsupported;
diff --git a/src/drivers/usb/usbkbd.c b/src/drivers/usb/usbkbd.c
index ea94f2e6..b134bc78 100644
--- a/src/drivers/usb/usbkbd.c
+++ b/src/drivers/usb/usbkbd.c
@@ -449,6 +449,7 @@ static struct usb_device_id usbkbd_ids[] = {
struct usb_driver usbkbd_driver __usb_driver = {
.ids = usbkbd_ids,
.id_count = ( sizeof ( usbkbd_ids ) / sizeof ( usbkbd_ids[0] ) ),
+ .score = USB_SCORE_NORMAL,
.probe = usbkbd_probe,
.remove = usbkbd_remove,
};
diff --git a/src/drivers/usb/usbnet.c b/src/drivers/usb/usbnet.c
index b92336d0..d18d8177 100644
--- a/src/drivers/usb/usbnet.c
+++ b/src/drivers/usb/usbnet.c
@@ -173,7 +173,7 @@ static int usbnet_comms_describe ( struct usbnet_device *usbnet,
int rc;
/* Iterate over all available interfaces */
- for ( i = 0 ; i < usbnet->func->count ; i++ ) {
+ for ( i = 0 ; i < usbnet->func->desc.count ; i++ ) {
/* Get interface number */
comms = usbnet->func->interface[i];
@@ -217,7 +217,7 @@ static int usbnet_data_describe ( struct usbnet_device *usbnet,
int rc;
/* Iterate over all available interfaces */
- for ( i = 0 ; i < usbnet->func->count ; i++ ) {
+ for ( i = 0 ; i < usbnet->func->desc.count ; i++ ) {
/* Get interface number */
data = usbnet->func->interface[i];