aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander von Gluck IV <kallisti5@unixzen.com>2012-07-22 13:48:57 -0500
committerAlexander von Gluck IV <kallisti5@unixzen.com>2012-07-22 13:48:57 -0500
commit7e67ec90a46ec4202ab7e4f7b0e07cf398200f45 (patch)
treec79b38b63fb19e8208efb65f9753351082981889
parent8899214980d031c69441a29c5c122e3fd592d0b7 (diff)
usb_serial: Set option driver to use the last found port.hrev44381
* Add a warning when >1 port is found (as we only use the last found serial port) * Verified working, remove if 0.
-rw-r--r--src/add-ons/kernel/drivers/ports/usb_serial/Option.cpp16
-rw-r--r--src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.cpp4
2 files changed, 13 insertions, 7 deletions
diff --git a/src/add-ons/kernel/drivers/ports/usb_serial/Option.cpp b/src/add-ons/kernel/drivers/ports/usb_serial/Option.cpp
index d82812d6dd..2041d8fe24 100644
--- a/src/add-ons/kernel/drivers/ports/usb_serial/Option.cpp
+++ b/src/add-ons/kernel/drivers/ports/usb_serial/Option.cpp
@@ -24,6 +24,7 @@ OptionDevice::AddDevice(const usb_configuration_info *config)
{
TRACE_FUNCALLS("> OptionDevice::AddDevice(%08x, %08x)\n", this, config);
+ int portsFound = 0;
if (config->interface_count > 0) {
for (size_t index = 0; index < config->interface_count; index++) {
usb_interface_info *interface = config->interface[index].active;
@@ -61,17 +62,26 @@ OptionDevice::AddDevice(const usb_configuration_info *config)
if (txEndpointID < 0 || rxEndpointID < 0 || irEndpointID < 0)
continue;
- TRACE("> OptionDevice::%s: found at interface %d\n", __func__,
+ TRACE("> OptionDevice::%s: found port at interface %d\n", __func__,
index);
+ portsFound++;
+
usb_endpoint_info *irEndpoint = &interface->endpoint[irEndpointID];
usb_endpoint_info *txEndpoint = &interface->endpoint[txEndpointID];
usb_endpoint_info *rxEndpoint = &interface->endpoint[rxEndpointID];
SetControlPipe(irEndpoint->handle);
SetReadPipe(rxEndpoint->handle);
SetWritePipe(txEndpoint->handle);
+ }
- // We accept the first found serial interface
- // TODO: We should set each matching interface up (can be > 1)
+ // TODO: We need to handle multiple ports
+ // We use the last found serial port for now
+ if (portsFound > 0) {
+ if (portsFound > 1) {
+ TRACE_ALWAYS("> OptionDevice::%s: Warning: Found more than one "
+ "serial port on this device (%d). Only the last one is "
+ "is used.\n", __func__, portsFound);
+ }
return B_OK;
}
}
diff --git a/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.cpp b/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.cpp
index e3d1694195..e8bb192c35 100644
--- a/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.cpp
+++ b/src/add-ons/kernel/drivers/ports/usb_serial/SerialDevice.cpp
@@ -760,9 +760,6 @@ SerialDevice::MakeDevice(usb_device device, uint16 vendorID,
}
}
- #if 0
- // Not yet working
-
// Option Serial Device
for (uint32 i = 0; i < sizeof(kOptionDevices)
/ sizeof(kOptionDevices[0]); i++) {
@@ -772,7 +769,6 @@ SerialDevice::MakeDevice(usb_device device, uint16 vendorID,
kOptionDevices[i].deviceName);
}
}
- #endif
// Otherwise, return standard ACM device
return new(std::nothrow) ACMDevice(device, vendorID, productID,