usb_asix: style cleanup

* While I was in the neighbourhood
* No functional change
This commit is contained in:
Alexander von Gluck IV
2013-04-04 23:36:16 -05:00
parent b208c3fa3b
commit 57419ce54f
4 changed files with 176 additions and 182 deletions
@@ -187,6 +187,7 @@ ASIXDevice::Read(uint8 *buffer, size_t *numBytes)
status_t result = gUSBModule->queue_bulk_v(fReadEndpoint,
&rxData[startIndex], chunkCount, _ReadCallback, this);
if (result != B_OK) {
TRACE_ALWAYS("Error of queue_bulk_v request:%#010x\n", result);
return result;
@@ -265,6 +266,7 @@ ASIXDevice::Write(const uint8 *buffer, size_t *numBytes)
status_t result = gUSBModule->queue_bulk_v(fWriteEndpoint,
&txData[startIndex], chunkCount, _WriteCallback, this);
if (result != B_OK) {
TRACE_ALWAYS("Error of queue_bulk_v request:%#010x\n", result);
return result;
@@ -388,9 +390,10 @@ ASIXDevice::SetupDevice(bool deviceReplugged)
// address (which should be at the same index) to make sure
if (memcmp(&address, &fMACAddress, sizeof(address)) != 0) {
TRACE_ALWAYS("Cannot replace device with MAC address:"
"%02x:%02x:%02x:%02x:%02x:%02x\n",
fMACAddress.ebyte[0], fMACAddress.ebyte[1], fMACAddress.ebyte[2],
fMACAddress.ebyte[3], fMACAddress.ebyte[4], fMACAddress.ebyte[5]);
"%02x:%02x:%02x:%02x:%02x:%02x\n", fMACAddress.ebyte[0],
fMACAddress.ebyte[1], fMACAddress.ebyte[2],
fMACAddress.ebyte[3], fMACAddress.ebyte[4],
fMACAddress.ebyte[5]);
return B_BAD_VALUE; // is not the same
}
} else
@@ -473,30 +476,26 @@ ASIXDevice::_SetupEndpoints()
for (size_t ep = 0; ep < interface->endpoint_count; ep++) {
usb_endpoint_descriptor *epd = interface->endpoint[ep].descr;
if ((epd->attributes & USB_ENDPOINT_ATTR_MASK)
== USB_ENDPOINT_ATTR_INTERRUPT)
{
== USB_ENDPOINT_ATTR_INTERRUPT) {
notifyEndpoint = ep;
continue;
}
if ((epd->attributes & USB_ENDPOINT_ATTR_MASK)
!= USB_ENDPOINT_ATTR_BULK)
{
!= USB_ENDPOINT_ATTR_BULK) {
TRACE_ALWAYS("Error: USB endpoint type %#04x is unknown.\n",
epd->attributes);
continue;
}
if ((epd->endpoint_address & USB_ENDPOINT_ADDR_DIR_IN)
== USB_ENDPOINT_ADDR_DIR_IN)
{
== USB_ENDPOINT_ADDR_DIR_IN) {
readEndpoint = ep;
continue;
}
if ((epd->endpoint_address & USB_ENDPOINT_ADDR_DIR_OUT)
== USB_ENDPOINT_ADDR_DIR_OUT)
{
== USB_ENDPOINT_ADDR_DIR_OUT) {
writeEndpoint = ep;
continue;
}
@@ -504,8 +503,8 @@ ASIXDevice::_SetupEndpoints()
if (notifyEndpoint == -1 || readEndpoint == -1 || writeEndpoint == -1) {
TRACE_ALWAYS("Error: not all USB endpoints were found: "
"notify:%d; read:%d; write:%d\n",
notifyEndpoint, readEndpoint, writeEndpoint);
"notify:%d; read:%d; write:%d\n", notifyEndpoint, readEndpoint,
writeEndpoint);
return B_ERROR;
}
@@ -524,9 +523,9 @@ ASIXDevice::ReadMACAddress(ether_address_t *address)
{
size_t actual_length = 0;
status_t result = gUSBModule->send_request(fDevice,
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN,
fReadNodeIDRequest, 0, 0, sizeof(ether_address),
address, &actual_length);
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN, fReadNodeIDRequest,
0, 0, sizeof(ether_address), address, &actual_length);
if (result != B_OK) {
TRACE_ALWAYS("Error of reading MAC address:%#010x\n", result);
return result;
@@ -549,14 +548,13 @@ ASIXDevice::ReadRXControlRegister(uint16 *rxcontrol)
*rxcontrol = 0;
status_t result = gUSBModule->send_request(fDevice,
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN,
READ_RX_CONTROL, 0, 0,
sizeof(*rxcontrol), rxcontrol, &actual_length);
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN, READ_RX_CONTROL,
0, 0, sizeof(*rxcontrol), rxcontrol, &actual_length);
if (sizeof(*rxcontrol) != actual_length) {
TRACE_ALWAYS("Mismatch during reading RX control register."
"Read %d bytes instead of %d.\n",
actual_length, sizeof(*rxcontrol));
"Read %d bytes instead of %d.\n", actual_length,
sizeof(*rxcontrol));
}
return result;
@@ -567,8 +565,8 @@ status_t
ASIXDevice::WriteRXControlRegister(uint16 rxcontrol)
{
status_t result = gUSBModule->send_request(fDevice,
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
WRITE_RX_CONTROL, rxcontrol, 0, 0, 0, 0);
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_RX_CONTROL,
rxcontrol, 0, 0, 0, 0);
return result;
}
@@ -578,9 +576,8 @@ ASIXDevice::StopDevice()
{
status_t result = WriteRXControlRegister(0);
if (result != B_OK) {
if (result != B_OK)
TRACE_ALWAYS("Error of writing %#04x RX Control:%#010x\n", 0, result);
}
TRACE_RET(result);
return result;
@@ -681,9 +678,9 @@ ASIXDevice::ModifyMulticastTable(bool join, ether_address_t* group)
// write multicast hash table
size_t actualLength = 0;
result = gUSBModule->send_request(fDevice,
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
WRITE_MF_ARRAY, 0, 0,
hashLength, hashTable, &actualLength);
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_MF_ARRAY,
0, 0, hashLength, hashTable, &actualLength);
if (result != B_OK) {
TRACE_ALWAYS("Error writing hash table in MAR: %#010x.\n", result);
return result;
@@ -175,8 +175,8 @@ AX88172Device::StartDevice()
for (size_t i = 0; i < sizeof(fIPG) / sizeof(fIPG[0]); i++) {
status_t result = gUSBModule->send_request(fDevice,
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
WRITE_IPG0, 0, 0, sizeof(fIPG[i]), &fIPG[i], &actualLength);
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_IPG0,
0, 0, sizeof(fIPG[i]), &fIPG[i], &actualLength);
if (result != B_OK) {
TRACE_ALWAYS("Error writing IPG%d: %#010x\n", i, result);
@@ -222,11 +222,13 @@ AX88172Device::OnNotify(uint32 actualLength)
switch(fMII.ActivePHY()) {
case PrimaryPHY:
phyIndex = 1;
linkIsUp = (notification->btNN & LINK_STATE_PHY1) == LINK_STATE_PHY1;
linkIsUp = (notification->btNN & LINK_STATE_PHY1)
== LINK_STATE_PHY1;
break;
case SecondaryPHY:
phyIndex = 2;
linkIsUp = (notification->btNN & LINK_STATE_PHY2) == LINK_STATE_PHY2;
linkIsUp = (notification->btNN & LINK_STATE_PHY2)
== LINK_STATE_PHY2;
break;
default:
case CurrentPHY:
@@ -202,8 +202,8 @@ AX88178Device::SetupDevice(bool deviceReplugged)
size_t actualLength = 0;
// get the "magic" word from EEPROM
result = gUSBModule->send_request(fDevice,
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
WRITE_SROM_ENABLE, 0, 0, 0, 0, &actualLength);
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_SROM_ENABLE,
0, 0, 0, 0, &actualLength);
if (result != B_OK) {
TRACE_ALWAYS("Error of enabling SROM access:%#010x\n", result);
@@ -212,9 +212,8 @@ AX88178Device::SetupDevice(bool deviceReplugged)
uint16 eepromData = 0;
status_t op_result = gUSBModule->send_request(fDevice,
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN,
READ_SROM, 0x17, 0,
sizeof(eepromData), &eepromData, &actualLength);
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN, READ_SROM,
0x17, 0, sizeof(eepromData), &eepromData, &actualLength);
if (op_result != B_OK) {
TRACE_ALWAYS("Error of reading SROM data:%#010x\n", result);
@@ -222,13 +221,12 @@ AX88178Device::SetupDevice(bool deviceReplugged)
if (actualLength != sizeof(eepromData)) {
TRACE_ALWAYS("Mismatch of reading SROM data."
"Read %d bytes instead of %d\n",
actualLength, sizeof(eepromData));
"Read %d bytes instead of %d\n", actualLength, sizeof(eepromData));
}
result = gUSBModule->send_request(fDevice,
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
WRITE_SROM_DISABLE, 0, 0, 0, 0, &actualLength);
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_SROM_DISABLE,
0, 0, 0, 0, &actualLength);
if (result != B_OK) {
TRACE_ALWAYS("Error of disabling SROM access: %#010x\n", result);
@@ -261,9 +259,8 @@ AX88178Device::SetupDevice(bool deviceReplugged)
for (size_t i = from; i <= to; i++) {
result = gUSBModule->send_request(fDevice,
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
WRITE_GPIOS, GPIOCommands[i].value,
0, 0, 0, &actualLength);
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_GPIOS,
GPIOCommands[i].value, 0, 0, 0, &actualLength);
snooze(GPIOCommands[i].delay);
@@ -277,8 +274,8 @@ AX88178Device::SetupDevice(bool deviceReplugged)
uint8 uSWReset = 0;
// finally a bit of exercises for SW reset register...
result = gUSBModule->send_request(fDevice,
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
WRITE_SOFT_RESET, uSWReset, 0, 0, 0, &actualLength);
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_SOFT_RESET,
uSWReset, 0, 0, 0, &actualLength);
if (result != B_OK) {
TRACE_ALWAYS("Error of SW reset to %#02x: %#010x\n", uSWReset, result);
@@ -289,8 +286,8 @@ AX88178Device::SetupDevice(bool deviceReplugged)
uSWReset = SW_RESET_PRL | SW_RESET_BIT6;
result = gUSBModule->send_request(fDevice,
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
WRITE_SOFT_RESET, uSWReset, 0, 0, 0, &actualLength);
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_SOFT_RESET,
uSWReset, 0, 0, 0, &actualLength);
if (result != B_OK) {
TRACE_ALWAYS("Error of SW reset to %#02x: %#010x\n", uSWReset, result);
@@ -317,8 +314,8 @@ AX88178Device::StartDevice()
{
size_t actualLength = 0;
status_t result = gUSBModule->send_request(fDevice,
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
WRITE_IPGS, 0, 0, sizeof(fIPG), fIPG, &actualLength);
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_IPGS,
0, 0, sizeof(fIPG), fIPG, &actualLength);
if (result != B_OK) {
TRACE_ALWAYS("Error of writing IPGs:%#010x\n", result);
@@ -363,11 +360,13 @@ AX88178Device::OnNotify(uint32 actualLength)
switch(fMII.ActivePHY()) {
case PrimaryPHY:
phyIndex = 1;
linkIsUp = (notification->btBB & LINK_STATE_PPLS) == LINK_STATE_PPLS;
linkIsUp = (notification->btBB & LINK_STATE_PPLS)
== LINK_STATE_PPLS;
break;
case SecondaryPHY:
phyIndex = 2;
linkIsUp = (notification->btBB & LINK_STATE_SPLS) == LINK_STATE_SPLS;
linkIsUp = (notification->btBB & LINK_STATE_SPLS)
== LINK_STATE_SPLS;
break;
default:
case CurrentPHY:
@@ -396,9 +395,8 @@ AX88178Device::GetLinkState(ether_link_state *linkState)
size_t actualLength = 0;
uint16 mediumStatus = 0;
status_t result = gUSBModule->send_request(fDevice,
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN,
READ_MEDIUM_STATUS, 0, 0, sizeof(mediumStatus),
&mediumStatus, &actualLength);
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN, READ_MEDIUM_STATUS,
0, 0, sizeof(mediumStatus), &mediumStatus, &actualLength);
if (result != B_OK) {
TRACE_ALWAYS("Error of reading medium status:%#010x.\n", result);
@@ -290,11 +290,9 @@ AX88772Device::SetupDevice(bool deviceReplugged)
size_t actualLength = 0;
result = gUSBModule->send_request(fDevice,
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
WRITE_MEDIUM_MODE,
MEDIUM_STATE_FD | MEDIUM_STATE_BIT2 |
MEDIUM_STATE_RFC| MEDIUM_STATE_TFC |
MEDIUM_STATE_RE | MEDIUM_STATE_PS_100,
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_MEDIUM_MODE,
MEDIUM_STATE_FD | MEDIUM_STATE_BIT2 | MEDIUM_STATE_RFC
| MEDIUM_STATE_TFC | MEDIUM_STATE_RE | MEDIUM_STATE_PS_100,
0, 0, 0, &actualLength);
if (result != B_OK) {
@@ -313,8 +311,8 @@ AX88772Device::_SetupAX88772()
// enable GPIO2 - magic from FreeBSD's if_axe
uint16 GPIOs = GPIO_OO_2EN | GPIO_IO_2 | GPIO_RSE;
status_t result = gUSBModule->send_request(fDevice,
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
WRITE_GPIOS, GPIOs, 0, 0, 0, &actualLength);
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_GPIOS,
GPIOs, 0, 0, 0, &actualLength);
if (result != B_OK) {
TRACE_ALWAYS("Error of wrinting GPIOs: %#010x\n", result);
@@ -323,8 +321,8 @@ AX88772Device::_SetupAX88772()
// select PHY
bool useEmbeddedPHY = fMII.PHYID() == PHYIDEmbedded;
uint16 selectPHY = useEmbeddedPHY ?
SW_PHY_SEL_STATUS_INT : SW_PHY_SEL_STATUS_EXT;
uint16 selectPHY = useEmbeddedPHY
? SW_PHY_SEL_STATUS_INT : SW_PHY_SEL_STATUS_EXT;
result = gUSBModule->send_request(fDevice,
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
@@ -362,9 +360,8 @@ AX88772Device::_SetupAX88772()
for (size_t i = from; i <= to; i++) {
result = gUSBModule->send_request(fDevice,
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
WRITE_SOFT_RESET, resetCommands[i].reset,
0, 0, 0, &actualLength);
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_SOFT_RESET,
resetCommands[i].reset, 0, 0, 0, &actualLength);
snooze(resetCommands[i].delay);
@@ -386,15 +383,15 @@ AX88772Device::_WakeupPHY()
{
// select PHY
bool useEmbeddedPHY = fMII.PHYID() == PHYIDEmbedded;
uint16 selectPHY = useEmbeddedPHY ?
SW_PHY_SEL_STATUS_INT : SW_PHY_SEL_STATUS_EXT;
uint16 selectPHY = useEmbeddedPHY
? SW_PHY_SEL_STATUS_INT : SW_PHY_SEL_STATUS_EXT;
selectPHY |= SW_PHY_SEL_STATUS_SS_MII | SW_PHY_SEL_STATUS_SS_ENB;
size_t actualLength = 0;
status_t result = gUSBModule->send_request(fDevice,
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
WRITE_PHY_SEL, selectPHY, 0, 0, 0, &actualLength);
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_PHY_SEL,
selectPHY, 0, 0, 0, &actualLength);
snooze(31000);
TRACE("Selecting %s PHY[%#02x].\n",
@@ -417,9 +414,8 @@ AX88772Device::_WakeupPHY()
for (size_t i = 0; i < _countof(resetCommands); i++) {
result = gUSBModule->send_request(fDevice,
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
WRITE_SOFT_RESET, resetCommands[i].reset,
0, 0, 0, &actualLength);
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_SOFT_RESET,
resetCommands[i].reset, 0, 0, 0, &actualLength);
snooze(resetCommands[i].delay);
@@ -440,8 +436,8 @@ AX88772Device::_SetupAX88772A()
// Reload EEPROM
size_t actualLength = 0;
status_t result = gUSBModule->send_request(fDevice,
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
WRITE_GPIOS, GPIO_RSE, 0, 0, 0, &actualLength);
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_GPIOS,
GPIO_RSE, 0, 0, 0, &actualLength);
if (result != B_OK) {
TRACE_ALWAYS("Error of reloading EEPROM: %#010x\n", result);
@@ -466,8 +462,8 @@ AX88772Device::_SetupAX88772B()
// Reload EEPROM
size_t actualLength = 0;
status_t result = gUSBModule->send_request(fDevice,
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
WRITE_GPIOS, GPIO_RSE, 0, 0, 0, &actualLength);
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_GPIOS,
GPIO_RSE, 0, 0, 0, &actualLength);
if (result != B_OK) {
TRACE_ALWAYS("Error of reloading EEPROM: %#010x\n", result);
@@ -491,8 +487,8 @@ AX88772Device::StartDevice()
{
size_t actualLength = 0;
status_t result = gUSBModule->send_request(fDevice,
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT,
WRITE_IPGS, 0, 0, sizeof(fIPG), fIPG, &actualLength);
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_IPGS,
0, 0, sizeof(fIPG), fIPG, &actualLength);
if (result != B_OK) {
TRACE_ALWAYS("Error of writing IPGs:%#010x\n", result);
@@ -560,11 +556,13 @@ AX88772Device::OnNotify(uint32 actualLength)
switch(fMII.ActivePHY()) {
case PrimaryPHY:
phyIndex = 1;
linkIsUp = (notification->btBB & LINK_STATE_PPLS) == LINK_STATE_PPLS;
linkIsUp = (notification->btBB & LINK_STATE_PPLS)
== LINK_STATE_PPLS;
break;
case SecondaryPHY:
phyIndex = 2;
linkIsUp = (notification->btBB & LINK_STATE_SPLS) == LINK_STATE_SPLS;
linkIsUp = (notification->btBB & LINK_STATE_SPLS)
== LINK_STATE_SPLS;
break;
default:
case CurrentPHY:
@@ -593,9 +591,8 @@ AX88772Device::GetLinkState(ether_link_state *linkState)
size_t actualLength = 0;
uint16 mediumStatus = 0;
status_t result = gUSBModule->send_request(fDevice,
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN,
READ_MEDIUM_STATUS, 0, 0, sizeof(mediumStatus),
&mediumStatus, &actualLength);
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN, READ_MEDIUM_STATUS,
0, 0, sizeof(mediumStatus), &mediumStatus, &actualLength);
if (result != B_OK) {
TRACE_ALWAYS("Error of reading medium status:%#010x.\n", result);
@@ -604,8 +601,8 @@ AX88772Device::GetLinkState(ether_link_state *linkState)
if (actualLength != sizeof(mediumStatus)) {
TRACE_ALWAYS("Mismatch of reading medium status."
"Read %d bytes instead of %d\n",
actualLength, sizeof(mediumStatus));
"Read %d bytes instead of %d\n", actualLength,
sizeof(mediumStatus));
}
TRACE_FLOW("Medium status is %#04x\n", mediumStatus);