USB ACM serial driver did not take maxPacketSize provided by the device into account

Change-Id: Ic93d420012d757088b20936e6c8d942ccbc0e5bf
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6668
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
This commit is contained in:
Stian Skjelstad 2023-07-03 23:39:44 +02:00 committed by waddlesplash
parent a5afae7f96
commit 243ac0b9a6

View File

@ -87,6 +87,7 @@ ACMDevice::AddDevice(const usb_configuration_info *config)
|| descriptor->interface_class == USB_CDC_DATA_INTERFACE_CLASS)
&& interface->endpoint_count >= 1) {
SetControlPipe(interface->endpoint[0].handle);
SetInterruptBufferSize(interface->endpoint[0].descr->max_packet_size);
} else {
TRACE("Indicated command interface doesn't fit our needs!\n");
status = ENODEV;
@ -99,15 +100,21 @@ ACMDevice::AddDevice(const usb_configuration_info *config)
usb_interface_descriptor *descriptor = interface->descr;
if (descriptor->interface_class == USB_CDC_DATA_INTERFACE_CLASS
&& interface->endpoint_count >= 2) {
if (!(interface->endpoint[0].descr->endpoint_address & USB_ENDPOINT_ADDR_DIR_IN))
if (!(interface->endpoint[0].descr->endpoint_address & USB_ENDPOINT_ADDR_DIR_IN)) {
SetWriteBufferSize(ROUNDUP(interface->endpoint[0].descr->max_packet_size, 16));
SetWritePipe(interface->endpoint[0].handle);
else
} else {
SetReadBufferSize(ROUNDUP(interface->endpoint[0].descr->max_packet_size, 16));
SetReadPipe(interface->endpoint[0].handle);
}
if (interface->endpoint[1].descr->endpoint_address & USB_ENDPOINT_ADDR_DIR_IN)
if (interface->endpoint[1].descr->endpoint_address & USB_ENDPOINT_ADDR_DIR_IN) {
SetReadBufferSize(ROUNDUP(interface->endpoint[1].descr->max_packet_size, 16));
SetReadPipe(interface->endpoint[1].handle);
else
} else {
SetWriteBufferSize(ROUNDUP(interface->endpoint[1].descr->max_packet_size, 16));
SetWritePipe(interface->endpoint[1].handle);
}
} else {
TRACE("Indicated data interface doesn't fit our needs!\n");
status = ENODEV;