[haiku-development] Haiku USB: actual_length returned from send_request() is differ than amount of transferred data.
- From: Siarzhuk Zharski <zharik@xxxxxx>
- To: haiku-development@xxxxxxxxxxxxx
- Date: Fri, 18 Jul 2008 22:51:05 +0200
Hi!
During work on some USB2Ethernet BeOS/Haiku driver I have observed that
send_request call behaves a bit differently on Haiku than on R5.
Please look on the following code:
status_t
MIIBus::Write(uint16 miiRegister, uint16 value, PHYIndex phyIndex /*= CurrentPHY*/)
{
size_t actual_length = 0;
[......]
uint16 phyId = PHYID(phyIndex);
// switch to SW operation mode
result = gUSBModule->send_request(fDevice,
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
fSWOperationRequest, 0, 0, 0, 0, &actual_length);
if(result != B_OK) {
TRACE_ALWAYS("MIIBus::Write "
"couldn't switch to SW operation mode: %08x\n",
result);
return result;
}
// write register value
status_t op_result = gUSBModule->send_request(fDevice,
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
fWriteValueRequest, phyId, miiRegister,
sizeof(value), &value, &actual_length);
if(op_result != B_OK) {
TRACE_ALWAYS("MIIBus::Write: "
"failed to write register %d at phy %d: %08x\n",
miiRegister, phyId, op_result);
}
if(sizeof(value) != actual_length) {
TRACE_ALWAYS("MIIBus::Write "
"register %d at phy %d written %d bytes instead of %d\n",
miiRegister, phyId, actual_length, sizeof(value));
}
// switch to HW operation mode
result = gUSBModule->send_request(fDevice,
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
fHWOperationRequest, 0, 0, 0, 0, &actual_length);
if(result != B_OK) {
TRACE_ALWAYS("MIIBus::Write "
"couldn't switch to HW operation mode: %08x\n",
result);
}
return op_result;
}
The "write register value" call on Haiku returns 10 as actual_length of
transferred data. On R5 this code returns only 2. I have quickly browse
through Haiku USB implementation and found that this parameter is set
by corresponding transfer callback to size of _all_ data transferred
during this send_request call. I thought that usual user want only
transferred data size here. Am I right? :-)
By the way, the driver code is currently available at
http://sis4be.cvs.sourceforge.net/sis4be/usb_asix/. It inherits skeleton
functionality from Haiku's usb_ecm one and support ASIX
AX88172/AX88772/AX88178-based USB2Ethernet adapters. It is also known as
"if_axe" on FreeBSD and as "asix" on Linux. May it be useful to beautify
Haiku's Tree too? ;-)
---
Kind Regards,
S.Zharski.
Other related posts: