usb_asix: Little additional style cleanup

* Things I missed the other day
* No functional change
This commit is contained in:
Alexander von Gluck IV
2013-04-22 20:47:43 -05:00
parent 2b7a67e7aa
commit 526232b6d8
6 changed files with 62 additions and 81 deletions
@@ -276,8 +276,8 @@ AX88172Device::GetLinkState(ether_link_state *linkState)
linkState->quality = 1000; linkState->quality = 1000;
linkState->media = IFM_ETHER | (fHasConnection ? IFM_ACTIVE : 0); linkState->media = IFM_ETHER | (fHasConnection ? IFM_ACTIVE : 0);
linkState->media |= mediumStatus & (ANLPAR_TX_FD | ANLPAR_10_FD) ? linkState->media |= mediumStatus & (ANLPAR_TX_FD | ANLPAR_10_FD)
IFM_FULL_DUPLEX : IFM_HALF_DUPLEX; ? IFM_FULL_DUPLEX : IFM_HALF_DUPLEX;
linkState->speed = mediumStatus & (ANLPAR_TX_FD | ANLPAR_TX_HD) linkState->speed = mediumStatus & (ANLPAR_TX_FD | ANLPAR_TX_HD)
? 100000000 : 10000000; ? 100000000 : 10000000;
@@ -288,4 +288,3 @@ AX88172Device::GetLinkState(ether_link_state *linkState)
(linkState->media & IFM_FULL_DUPLEX) ? "full" : "half"); (linkState->media & IFM_FULL_DUPLEX) ? "full" : "half");
return B_OK; return B_OK;
} }
@@ -414,13 +414,13 @@ AX88178Device::GetLinkState(ether_link_state *linkState)
linkState->quality = 1000; linkState->quality = 1000;
linkState->media = IFM_ETHER | (fHasConnection ? IFM_ACTIVE : 0); linkState->media = IFM_ETHER | (fHasConnection ? IFM_ACTIVE : 0);
linkState->media |= (mediumStatus & MEDIUM_STATE_FD) ? linkState->media |= (mediumStatus & MEDIUM_STATE_FD)
IFM_FULL_DUPLEX : IFM_HALF_DUPLEX; ? IFM_FULL_DUPLEX : IFM_HALF_DUPLEX;
linkState->speed = (mediumStatus & MEDIUM_STATE_PS_100) linkState->speed = (mediumStatus & MEDIUM_STATE_PS_100)
? 100000000 : 10000000; ? 100000000 : 10000000;
linkState->speed = (mediumStatus & MEDIUM_STATE_GM) ? linkState->speed = (mediumStatus & MEDIUM_STATE_GM)
1000000000 : linkState->speed; ? 1000000000 : linkState->speed;
TRACE_FLOW("Medium state: %s, %lld MBit/s, %s duplex.\n", TRACE_FLOW("Medium state: %s, %lld MBit/s, %s duplex.\n",
(linkState->media & IFM_ACTIVE) ? "active" : "inactive", (linkState->media & IFM_ACTIVE) ? "active" : "inactive",
@@ -428,4 +428,3 @@ AX88178Device::GetLinkState(ether_link_state *linkState)
(linkState->media & IFM_FULL_DUPLEX) ? "full" : "half"); (linkState->media & IFM_FULL_DUPLEX) ? "full" : "half");
return B_OK; return B_OK;
} }
@@ -242,9 +242,8 @@ AX88772Device::ReadMACAddress(ether_address_t *address)
size_t actual_length = 0; size_t actual_length = 0;
uint16 addr = 0; uint16 addr = 0;
status_t result = gUSBModule->send_request(fDevice, status_t result = gUSBModule->send_request(fDevice,
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN, USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN, READ_SROM,
READ_SROM, EEPROM_772B_NODE_ID + i, 0, EEPROM_772B_NODE_ID + i, 0, sizeof(addr), &addr, &actual_length);
sizeof(addr), &addr, &actual_length);
if (result != B_OK) { if (result != B_OK) {
TRACE_ALWAYS("Error reading MAC[%d] address:%#010x\n", i, result); TRACE_ALWAYS("Error reading MAC[%d] address:%#010x\n", i, result);
return result; return result;
@@ -506,11 +505,9 @@ AX88772Device::StartDevice()
// AX88772B uses different maximum frame burst configuration. // AX88772B uses different maximum frame burst configuration.
if (fDeviceInfo.fType == DeviceInfo::AX88772B) { if (fDeviceInfo.fType == DeviceInfo::AX88772B) {
result = gUSBModule->send_request(fDevice, result = gUSBModule->send_request(fDevice,
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, WRITE_RXCONTROL_CFG,
WRITE_RXCONTROL_CFG,
AX88772B_MFBTable[AX88772B_MFB_2K].ByteCount, AX88772B_MFBTable[AX88772B_MFB_2K].ByteCount,
AX88772B_MFBTable[AX88772B_MFB_2K].Threshold, AX88772B_MFBTable[AX88772B_MFB_2K].Threshold, 0, 0, &actualLength);
0, 0, &actualLength);
if (result != B_OK) { if (result != B_OK) {
TRACE_ALWAYS("Error of writing frame burst:%#010x\n", result); TRACE_ALWAYS("Error of writing frame burst:%#010x\n", result);
@@ -610,8 +607,8 @@ AX88772Device::GetLinkState(ether_link_state *linkState)
linkState->quality = 1000; linkState->quality = 1000;
linkState->media = IFM_ETHER | (fHasConnection ? IFM_ACTIVE : 0); linkState->media = IFM_ETHER | (fHasConnection ? IFM_ACTIVE : 0);
linkState->media |= (mediumStatus & MEDIUM_STATE_FD) ? linkState->media |= (mediumStatus & MEDIUM_STATE_FD)
IFM_FULL_DUPLEX : IFM_HALF_DUPLEX; ? IFM_FULL_DUPLEX : IFM_HALF_DUPLEX;
linkState->speed = (mediumStatus & MEDIUM_STATE_PS_100) linkState->speed = (mediumStatus & MEDIUM_STATE_PS_100)
? 100000000 : 10000000; ? 100000000 : 10000000;
@@ -622,4 +619,3 @@ AX88772Device::GetLinkState(ether_link_state *linkState)
(linkState->media & IFM_FULL_DUPLEX) ? "full" : "half"); (linkState->media & IFM_FULL_DUPLEX) ? "full" : "half");
return B_OK; return B_OK;
} }
@@ -390,4 +390,3 @@ find_device(const char *name)
return &deviceHooks; return &deviceHooks;
} }
@@ -47,8 +47,8 @@ MIIBus::Init(usb_device device)
size_t actual_length = 0; size_t actual_length = 0;
status_t result = gUSBModule->send_request(device, status_t result = gUSBModule->send_request(device,
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN, USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN, READ_PHYID, 0, 0,
READ_PHYID, 0, 0, sizeof(fPHYs), fPHYs, &actual_length); sizeof(fPHYs), fPHYs, &actual_length);
if (result != B_OK) { if (result != B_OK) {
TRACE_ALWAYS("Request of the PHYIDs failed:%#010x\n", result); TRACE_ALWAYS("Request of the PHYIDs failed:%#010x\n", result);
@@ -181,9 +181,8 @@ MIIBus::Read(uint16 miiRegister, uint16 *value, PHYIndex phyIndex /*= CurrPHY*/)
size_t actual_length = 0; size_t actual_length = 0;
// switch to SW operation mode // switch to SW operation mode
result = gUSBModule->send_request(fDevice, result = gUSBModule->send_request(fDevice, USB_REQTYPE_VENDOR
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, | USB_REQTYPE_DEVICE_OUT, SW_MII_OP, 0, 0, 0, 0, &actual_length);
SW_MII_OP, 0, 0, 0, 0, &actual_length);
if (result != B_OK) { if (result != B_OK) {
TRACE_ALWAYS("Error of switching MII to SW op.mode: %#010x\n", result); TRACE_ALWAYS("Error of switching MII to SW op.mode: %#010x\n", result);
@@ -191,10 +190,9 @@ MIIBus::Read(uint16 miiRegister, uint16 *value, PHYIndex phyIndex /*= CurrPHY*/)
} }
// read register value // read register value
status_t op_result = gUSBModule->send_request(fDevice, status_t op_result = gUSBModule->send_request(fDevice, USB_REQTYPE_VENDOR
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN, | USB_REQTYPE_DEVICE_IN, READ_MII, phyId, miiRegister, sizeof(*value),
READ_MII, phyId, miiRegister, value, &actual_length);
sizeof(*value), value, &actual_length);
if (op_result != B_OK) { if (op_result != B_OK) {
TRACE_ALWAYS("Error of reading MII reg.%d at PHY%d:%#010x.\n", TRACE_ALWAYS("Error of reading MII reg.%d at PHY%d:%#010x.\n",
@@ -203,14 +201,13 @@ MIIBus::Read(uint16 miiRegister, uint16 *value, PHYIndex phyIndex /*= CurrPHY*/)
if (sizeof(*value) != actual_length) { if (sizeof(*value) != actual_length) {
TRACE_ALWAYS("Mismatch of reading MII reg.%d at PHY %d. " TRACE_ALWAYS("Mismatch of reading MII reg.%d at PHY %d. "
"Read %d bytes instead of %d.\n", "Read %d bytes instead of %d.\n", miiRegister, phyId,
miiRegister, phyId, actual_length, sizeof(*value)); actual_length, sizeof(*value));
} }
// switch to HW operation mode // switch to HW operation mode
result = gUSBModule->send_request(fDevice, result = gUSBModule->send_request(fDevice, USB_REQTYPE_VENDOR
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, | USB_REQTYPE_DEVICE_OUT, HW_MII_OP, 0, 0, 0, 0, &actual_length);
HW_MII_OP, 0, 0, 0, 0, &actual_length);
if (result != B_OK) { if (result != B_OK) {
TRACE_ALWAYS("Error of switching MII to HW op.mode: %#010x\n", result); TRACE_ALWAYS("Error of switching MII to HW op.mode: %#010x\n", result);
@@ -239,9 +236,8 @@ MIIBus::Write(uint16 miiRegister, uint16 value, PHYIndex phyIndex /*= CurrPHY*/)
uint16 phyId = PHYID(phyIndex); uint16 phyId = PHYID(phyIndex);
// switch to SW operation mode // switch to SW operation mode
result = gUSBModule->send_request(fDevice, result = gUSBModule->send_request(fDevice, USB_REQTYPE_VENDOR
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, | USB_REQTYPE_DEVICE_OUT, SW_MII_OP, 0, 0, 0, 0, &actual_length);
SW_MII_OP, 0, 0, 0, 0, &actual_length);
if (result != B_OK) { if (result != B_OK) {
TRACE_ALWAYS("Error of switching MII to SW op.mode: %#010x\n", result); TRACE_ALWAYS("Error of switching MII to SW op.mode: %#010x\n", result);
@@ -249,10 +245,9 @@ MIIBus::Write(uint16 miiRegister, uint16 value, PHYIndex phyIndex /*= CurrPHY*/)
} }
// write register value // write register value
status_t op_result = gUSBModule->send_request(fDevice, status_t op_result = gUSBModule->send_request(fDevice, USB_REQTYPE_VENDOR
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, | USB_REQTYPE_DEVICE_OUT, WRITE_MII, phyId, miiRegister, sizeof(value),
WRITE_MII, phyId, miiRegister, &value, &actual_length);
sizeof(value), &value, &actual_length);
if (op_result != B_OK) { if (op_result != B_OK) {
TRACE_ALWAYS("Error of writing MII reg.%d at PHY %d:%#010x.\n", TRACE_ALWAYS("Error of writing MII reg.%d at PHY %d:%#010x.\n",
@@ -261,14 +256,13 @@ MIIBus::Write(uint16 miiRegister, uint16 value, PHYIndex phyIndex /*= CurrPHY*/)
if (sizeof(value) != actual_length) { if (sizeof(value) != actual_length) {
TRACE_ALWAYS("Mismatch of writing MII reg.%d at PHY %d." TRACE_ALWAYS("Mismatch of writing MII reg.%d at PHY %d."
"Write %d bytes instead of %d.\n", "Write %d bytes instead of %d.\n", miiRegister, phyId,
miiRegister, phyId, actual_length, sizeof(value)); actual_length, sizeof(value));
} }
// switch to HW operation mode // switch to HW operation mode
result = gUSBModule->send_request(fDevice, result = gUSBModule->send_request(fDevice, USB_REQTYPE_VENDOR
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, | USB_REQTYPE_DEVICE_OUT, HW_MII_OP, 0, 0, 0, 0, &actual_length);
HW_MII_OP, 0, 0, 0, 0, &actual_length);
if (result != B_OK) { if (result != B_OK) {
TRACE_ALWAYS("Error of switching MII to HW op.mode: %#010x\n", result); TRACE_ALWAYS("Error of switching MII to HW op.mode: %#010x\n", result);
@@ -312,17 +306,15 @@ MIIBus::Dump()
return result; return result;
} }
uint8 regs[] = { MII_BMCR, MII_BMSR, uint8 regs[] = { MII_BMCR, MII_BMSR, MII_PHYID0,
MII_PHYID0, MII_PHYID1, MII_PHYID1, MII_ANAR, MII_ANLPAR/*, MII_ANER*/};
MII_ANAR, MII_ANLPAR/*, MII_ANER*/};
uint16 value = 0; uint16 value = 0;
for (size_t i = 0; i < sizeof(regs)/ sizeof(regs[0]); i++) { for (size_t i = 0; i < sizeof(regs)/ sizeof(regs[0]); i++) {
// read register value // read register value
status_t op_result = gUSBModule->send_request(fDevice, status_t op_result = gUSBModule->send_request(fDevice,
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN, USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_IN, READ_MII, phyId,
READ_MII, phyId, regs[i], regs[i], sizeof(value), &value, &actual_length);
sizeof(value), &value, &actual_length);
if (op_result != B_OK) { if (op_result != B_OK) {
TRACE_ALWAYS("Error of reading MII reg.%d at PHY%d:%#010x.\n", TRACE_ALWAYS("Error of reading MII reg.%d at PHY%d:%#010x.\n",
@@ -331,17 +323,16 @@ MIIBus::Dump()
if (sizeof(value) != actual_length) { if (sizeof(value) != actual_length) {
TRACE_ALWAYS("Mismatch of reading MII reg.%d at PHY%d." TRACE_ALWAYS("Mismatch of reading MII reg.%d at PHY%d."
" Read %d bytes instead of %d.\n", " Read %d bytes instead of %d.\n", regs[i], phyId,
regs[i], phyId, actual_length, sizeof(value)); actual_length, sizeof(value));
} }
TRACE_ALWAYS("MII reg: %d has %#04x\n", regs[i], value); TRACE_ALWAYS("MII reg: %d has %#04x\n", regs[i], value);
} }
// switch to HW operation mode // switch to HW operation mode
result = gUSBModule->send_request(fDevice, result = gUSBModule->send_request(fDevice, USB_REQTYPE_VENDOR
USB_REQTYPE_VENDOR | USB_REQTYPE_DEVICE_OUT, | USB_REQTYPE_DEVICE_OUT, HW_MII_OP, 0, 0, 0, 0, &actual_length);
HW_MII_OP, 0, 0, 0, 0, &actual_length);
if (result != B_OK) { if (result != B_OK) {
TRACE_ALWAYS("Error of switching MII to HW op.mode: %#010x\n", result); TRACE_ALWAYS("Error of switching MII to HW op.mode: %#010x\n", result);
@@ -350,4 +341,3 @@ MIIBus::Dump()
return result; return result;
} }
@@ -96,8 +96,7 @@ void usb_asix_trace(bool force, const char* func, const char *fmt, ...)
bigtime_t time = system_time(); bigtime_t time = system_time();
uint32 msec = time / 1000; uint32 msec = time / 1000;
uint32 sec = msec / 1000; uint32 sec = msec / 1000;
sprintf(buf_ptr, "%02ld.%02ld.%03ld:", sprintf(buf_ptr, "%02ld.%02ld.%03ld:", sec / 60, sec % 60, msec % 1000);
sec / 60, sec % 60, msec % 1000);
buf_ptr += strlen(buf_ptr); buf_ptr += strlen(buf_ptr);
} }
@@ -123,4 +122,3 @@ void usb_asix_trace(bool force, const char* func, const char *fmt, ...)
} }
mutex_unlock(&gLogLock); mutex_unlock(&gLogLock);
} }