usb_ecm: Use the current configuration instead of a fixed one.

This allows usb_ecm to work in case it is part of a device using
different configurations for different types of interfaces and ECM is
not the first configuration.
This commit is contained in:
Michael Lotz
2016-03-12 13:15:49 +01:00
parent b62bb24fe4
commit 91ea4fb48a
@@ -103,18 +103,18 @@ ECMDevice::Open()
// reset the device by switching the data interface to the disabled first
// interface and then enable it by setting the second actual data interface
const usb_configuration_info *config
= gUSBModule->get_nth_configuration(fDevice, 0);
= gUSBModule->get_configuration(fDevice);
gUSBModule->set_alt_interface(fDevice,
&config->interface[fDataInterfaceIndex].alt[0]);
// update to the changed config
config = gUSBModule->get_nth_configuration(fDevice, 0);
config = gUSBModule->get_configuration(fDevice);
gUSBModule->set_alt_interface(fDevice,
&config->interface[fDataInterfaceIndex].alt[1]);
// update again
config = gUSBModule->get_nth_configuration(fDevice, 0);
config = gUSBModule->get_configuration(fDevice);
usb_interface_info *interface = config->interface[fDataInterfaceIndex].active;
if (interface->endpoint_count < 2) {
TRACE_ALWAYS("setting the data alternate interface failed\n");
@@ -156,7 +156,7 @@ ECMDevice::Close()
// put the device into non-connected mode again by switching the data
// interface to the disabled alternate
const usb_configuration_info *config
= gUSBModule->get_nth_configuration(fDevice, 0);
= gUSBModule->get_configuration(fDevice);
gUSBModule->set_alt_interface(fDevice,
&config->interface[fDataInterfaceIndex].alt[0]);
@@ -368,7 +368,7 @@ status_t
ECMDevice::_SetupDevice()
{
const usb_configuration_info *config
= gUSBModule->get_nth_configuration(fDevice, 0);
= gUSBModule->get_configuration(fDevice);
if (config == NULL) {
TRACE_ALWAYS("failed to get device configuration\n");