Commit dc7e04fe authored by Pekka Enberg's avatar Pekka Enberg Committed by Greg Kroah-Hartman

Staging: w35und: use gotos for error handling

The driver code uses do { } while (0) together with the break statement to
emulate gotos for error handling. Fix that up by using the goto statement
instead.
Acked-by: default avatarPavel Machek <pavel@suse.cz>
Signed-off-by: default avatarPekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent a1eb2ba6
...@@ -35,51 +35,50 @@ void Wb35Rx( phw_data_t pHwData ) ...@@ -35,51 +35,50 @@ void Wb35Rx( phw_data_t pHwData )
// //
// Issuing URB // Issuing URB
// //
do { if (pHwData->SurpriseRemove || pHwData->HwStop)
if (pHwData->SurpriseRemove || pHwData->HwStop) goto error;
break;
if (pWb35Rx->rx_halt) if (pWb35Rx->rx_halt)
break; goto error;
// Get RxBuffer's ID // Get RxBuffer's ID
RxBufferId = pWb35Rx->RxBufferId; RxBufferId = pWb35Rx->RxBufferId;
if (!pWb35Rx->RxOwner[RxBufferId]) { if (!pWb35Rx->RxOwner[RxBufferId]) {
// It's impossible to run here. // It's impossible to run here.
#ifdef _PE_RX_DUMP_ #ifdef _PE_RX_DUMP_
WBDEBUG(("Rx driver fifo unavailable\n")); WBDEBUG(("Rx driver fifo unavailable\n"));
#endif #endif
break; goto error;
} }
// Update buffer point, then start to bulkin the data from USB // Update buffer point, then start to bulkin the data from USB
pWb35Rx->RxBufferId++; pWb35Rx->RxBufferId++;
pWb35Rx->RxBufferId %= MAX_USB_RX_BUFFER_NUMBER; pWb35Rx->RxBufferId %= MAX_USB_RX_BUFFER_NUMBER;
pWb35Rx->CurrentRxBufferId = RxBufferId; pWb35Rx->CurrentRxBufferId = RxBufferId;
if (1 != OS_MEMORY_ALLOC((void* *)&pWb35Rx->pDRx, MAX_USB_RX_BUFFER)) { if (1 != OS_MEMORY_ALLOC((void* *)&pWb35Rx->pDRx, MAX_USB_RX_BUFFER)) {
printk("w35und: Rx memory alloc failed\n"); printk("w35und: Rx memory alloc failed\n");
break; goto error;
} }
pRxBufferAddress = pWb35Rx->pDRx; pRxBufferAddress = pWb35Rx->pDRx;
usb_fill_bulk_urb(pUrb, pHwData->WbUsb.udev, usb_fill_bulk_urb(pUrb, pHwData->WbUsb.udev,
usb_rcvbulkpipe(pHwData->WbUsb.udev, 3), usb_rcvbulkpipe(pHwData->WbUsb.udev, 3),
pRxBufferAddress, MAX_USB_RX_BUFFER, pRxBufferAddress, MAX_USB_RX_BUFFER,
Wb35Rx_Complete, pHwData); Wb35Rx_Complete, pHwData);
pWb35Rx->EP3vm_state = VM_RUNNING; pWb35Rx->EP3vm_state = VM_RUNNING;
retv = wb_usb_submit_urb(pUrb); retv = wb_usb_submit_urb(pUrb);
if (retv != 0) { if (retv != 0) {
printk("Rx URB sending error\n"); printk("Rx URB sending error\n");
break; goto error;
} }
return; return;
} while(FALSE);
error:
// VM stop // VM stop
pWb35Rx->EP3vm_state = VM_STOP; pWb35Rx->EP3vm_state = VM_STOP;
OS_ATOMIC_DEC( pHwData->Adapter, &pWb35Rx->RxFireCounter ); OS_ATOMIC_DEC( pHwData->Adapter, &pWb35Rx->RxFireCounter );
...@@ -99,65 +98,63 @@ void Wb35Rx_Complete(PURB pUrb) ...@@ -99,65 +98,63 @@ void Wb35Rx_Complete(PURB pUrb)
pWb35Rx->EP3vm_state = VM_COMPLETED; pWb35Rx->EP3vm_state = VM_COMPLETED;
pWb35Rx->EP3VM_status = pUrb->status;//Store the last result of Irp pWb35Rx->EP3VM_status = pUrb->status;//Store the last result of Irp
do { RxBufferId = pWb35Rx->CurrentRxBufferId;
RxBufferId = pWb35Rx->CurrentRxBufferId;
pRxBufferAddress = pWb35Rx->pDRx; pRxBufferAddress = pWb35Rx->pDRx;
BulkLength = (u16)pUrb->actual_length; BulkLength = (u16)pUrb->actual_length;
// The IRP is completed // The IRP is completed
pWb35Rx->EP3vm_state = VM_COMPLETED; pWb35Rx->EP3vm_state = VM_COMPLETED;
if (pHwData->SurpriseRemove || pHwData->HwStop) // Must be here, or RxBufferId is invalid if (pHwData->SurpriseRemove || pHwData->HwStop) // Must be here, or RxBufferId is invalid
break; goto error;
if (pWb35Rx->rx_halt) if (pWb35Rx->rx_halt)
break; goto error;
// Start to process the data only in successful condition // Start to process the data only in successful condition
pWb35Rx->RxOwner[ RxBufferId ] = 0; // Set the owner to driver pWb35Rx->RxOwner[ RxBufferId ] = 0; // Set the owner to driver
R00.value = le32_to_cpu(*(u32 *)pRxBufferAddress); R00.value = le32_to_cpu(*(u32 *)pRxBufferAddress);
// The URB is completed, check the result // The URB is completed, check the result
if (pWb35Rx->EP3VM_status != 0) { if (pWb35Rx->EP3VM_status != 0) {
#ifdef _PE_USB_STATE_DUMP_ #ifdef _PE_USB_STATE_DUMP_
WBDEBUG(("EP3 IoCompleteRoutine return error\n")); WBDEBUG(("EP3 IoCompleteRoutine return error\n"));
DebugUsbdStatusInformation( pWb35Rx->EP3VM_status ); DebugUsbdStatusInformation( pWb35Rx->EP3VM_status );
#endif #endif
pWb35Rx->EP3vm_state = VM_STOP; pWb35Rx->EP3vm_state = VM_STOP;
break; goto error;
} }
// 20060220 For recovering. check if operating in single USB mode // 20060220 For recovering. check if operating in single USB mode
if (!HAL_USB_MODE_BURST(pHwData)) { if (!HAL_USB_MODE_BURST(pHwData)) {
SizeCheck = R00.R00_receive_byte_count; //20060926 anson's endian SizeCheck = R00.R00_receive_byte_count; //20060926 anson's endian
if ((SizeCheck & 0x03) > 0) if ((SizeCheck & 0x03) > 0)
SizeCheck -= 4; SizeCheck -= 4;
SizeCheck = (SizeCheck + 3) & ~0x03; SizeCheck = (SizeCheck + 3) & ~0x03;
SizeCheck += 12; // 8 + 4 badbeef SizeCheck += 12; // 8 + 4 badbeef
if ((BulkLength > 1600) || if ((BulkLength > 1600) ||
(SizeCheck > 1600) || (SizeCheck > 1600) ||
(BulkLength != SizeCheck) || (BulkLength != SizeCheck) ||
(BulkLength == 0)) { // Add for fail Urb (BulkLength == 0)) { // Add for fail Urb
pWb35Rx->EP3vm_state = VM_STOP; pWb35Rx->EP3vm_state = VM_STOP;
pWb35Rx->Ep3ErrorCount2++; pWb35Rx->Ep3ErrorCount2++;
}
} }
}
// Indicating the receiving data // Indicating the receiving data
pWb35Rx->ByteReceived += BulkLength; pWb35Rx->ByteReceived += BulkLength;
pWb35Rx->RxBufferSize[ RxBufferId ] = BulkLength; pWb35Rx->RxBufferSize[ RxBufferId ] = BulkLength;
if (!pWb35Rx->RxOwner[ RxBufferId ])
Wb35Rx_indicate(pHwData);
kfree(pWb35Rx->pDRx); if (!pWb35Rx->RxOwner[ RxBufferId ])
// Do the next receive Wb35Rx_indicate(pHwData);
Wb35Rx(pHwData);
return;
} while(FALSE); kfree(pWb35Rx->pDRx);
// Do the next receive
Wb35Rx(pHwData);
return;
error:
pWb35Rx->RxOwner[ RxBufferId ] = 1; // Set the owner to hardware pWb35Rx->RxOwner[ RxBufferId ] = 1; // Set the owner to hardware
OS_ATOMIC_DEC( pHwData->Adapter, &pWb35Rx->RxFireCounter ); OS_ATOMIC_DEC( pHwData->Adapter, &pWb35Rx->RxFireCounter );
pWb35Rx->EP3vm_state = VM_STOP; pWb35Rx->EP3vm_state = VM_STOP;
......
...@@ -100,25 +100,24 @@ void Wb35Tx_complete(struct urb * pUrb) ...@@ -100,25 +100,24 @@ void Wb35Tx_complete(struct urb * pUrb)
pWb35Tx->TxSendIndex++; pWb35Tx->TxSendIndex++;
pWb35Tx->TxSendIndex %= MAX_USB_TX_BUFFER_NUMBER; pWb35Tx->TxSendIndex %= MAX_USB_TX_BUFFER_NUMBER;
do { if (pHwData->SurpriseRemove || pHwData->HwStop) // Let WbWlanHalt to handle surprise remove
if (pHwData->SurpriseRemove || pHwData->HwStop) // Let WbWlanHalt to handle surprise remove goto error;
break;
if (pWb35Tx->tx_halt) if (pWb35Tx->tx_halt)
break; goto error;
// The URB is completed, check the result // The URB is completed, check the result
if (pWb35Tx->EP4VM_status != 0) { if (pWb35Tx->EP4VM_status != 0) {
printk("URB submission failed\n"); printk("URB submission failed\n");
pWb35Tx->EP4vm_state = VM_STOP; pWb35Tx->EP4vm_state = VM_STOP;
break; // Exit while(FALSE); goto error;
} }
Mds_Tx(Adapter); Mds_Tx(Adapter);
Wb35Tx(pHwData); Wb35Tx(pHwData);
return; return;
} while(FALSE);
error:
OS_ATOMIC_DEC( pHwData->Adapter, &pWb35Tx->TxFireCounter ); OS_ATOMIC_DEC( pHwData->Adapter, &pWb35Tx->TxFireCounter );
pWb35Tx->EP4vm_state = VM_STOP; pWb35Tx->EP4vm_state = VM_STOP;
} }
...@@ -228,33 +227,30 @@ void Wb35Tx_EP2VM(phw_data_t pHwData) ...@@ -228,33 +227,30 @@ void Wb35Tx_EP2VM(phw_data_t pHwData)
u32 * pltmp = (u32 *)pWb35Tx->EP2_buf; u32 * pltmp = (u32 *)pWb35Tx->EP2_buf;
int retv; int retv;
do { if (pHwData->SurpriseRemove || pHwData->HwStop)
if (pHwData->SurpriseRemove || pHwData->HwStop) goto error;
break;
if (pWb35Tx->tx_halt)
break;
//
// Issuing URB
//
usb_fill_int_urb( pUrb, pHwData->WbUsb.udev, usb_rcvintpipe(pHwData->WbUsb.udev,2),
pltmp, MAX_INTERRUPT_LENGTH, Wb35Tx_EP2VM_complete, pHwData, 32);
pWb35Tx->EP2vm_state = VM_RUNNING; if (pWb35Tx->tx_halt)
retv = wb_usb_submit_urb( pUrb ); goto error;
if(retv < 0) { //
#ifdef _PE_TX_DUMP_ // Issuing URB
WBDEBUG(("EP2 Tx Irp sending error\n")); //
#endif usb_fill_int_urb( pUrb, pHwData->WbUsb.udev, usb_rcvintpipe(pHwData->WbUsb.udev,2),
break; pltmp, MAX_INTERRUPT_LENGTH, Wb35Tx_EP2VM_complete, pHwData, 32);
}
return; pWb35Tx->EP2vm_state = VM_RUNNING;
retv = wb_usb_submit_urb( pUrb );
} while(FALSE); if (retv < 0) {
#ifdef _PE_TX_DUMP_
WBDEBUG(("EP2 Tx Irp sending error\n"));
#endif
goto error;
}
return;
error:
pWb35Tx->EP2vm_state = VM_STOP; pWb35Tx->EP2vm_state = VM_STOP;
OS_ATOMIC_DEC( pHwData->Adapter, &pWb35Tx->TxResultCount ); OS_ATOMIC_DEC( pHwData->Adapter, &pWb35Tx->TxResultCount );
} }
...@@ -275,38 +271,36 @@ void Wb35Tx_EP2VM_complete(struct urb * pUrb) ...@@ -275,38 +271,36 @@ void Wb35Tx_EP2VM_complete(struct urb * pUrb)
pWb35Tx->EP2vm_state = VM_COMPLETED; pWb35Tx->EP2vm_state = VM_COMPLETED;
pWb35Tx->EP2VM_status = pUrb->status; pWb35Tx->EP2VM_status = pUrb->status;
do { // For Linux 2.4. Interrupt will always trigger
// For Linux 2.4. Interrupt will always trigger if (pHwData->SurpriseRemove || pHwData->HwStop) // Let WbWlanHalt to handle surprise remove
if( pHwData->SurpriseRemove || pHwData->HwStop ) // Let WbWlanHalt to handle surprise remove goto error;
break;
if (pWb35Tx->tx_halt)
if( pWb35Tx->tx_halt ) goto error;
break;
//The Urb is completed, check the result
//The Urb is completed, check the result if (pWb35Tx->EP2VM_status != 0) {
if (pWb35Tx->EP2VM_status != 0) { WBDEBUG(("EP2 IoCompleteRoutine return error\n"));
WBDEBUG(("EP2 IoCompleteRoutine return error\n")); pWb35Tx->EP2vm_state= VM_STOP;
pWb35Tx->EP2vm_state= VM_STOP; goto error;
break; // Exit while(FALSE); }
}
// Update the Tx result
InterruptInLength = pUrb->actual_length;
// Modify for minimum memory access and DWORD alignment.
T02.value = cpu_to_le32(pltmp[0]) >> 8; // [31:8] -> [24:0]
InterruptInLength -= 1;// 20051221.1.c Modify the follow for more stable
InterruptInLength >>= 2; // InterruptInLength/4
for (i=1; i<=InterruptInLength; i++) {
T02.value |= ((cpu_to_le32(pltmp[i]) & 0xff) << 24);
TSTATUS.value = T02.value; //20061009 anson's endian
Mds_SendComplete( Adapter, &TSTATUS );
T02.value = cpu_to_le32(pltmp[i]) >> 8;
}
return;
} while(FALSE);
// Update the Tx result
InterruptInLength = pUrb->actual_length;
// Modify for minimum memory access and DWORD alignment.
T02.value = cpu_to_le32(pltmp[0]) >> 8; // [31:8] -> [24:0]
InterruptInLength -= 1;// 20051221.1.c Modify the follow for more stable
InterruptInLength >>= 2; // InterruptInLength/4
for (i = 1; i <= InterruptInLength; i++) {
T02.value |= ((cpu_to_le32(pltmp[i]) & 0xff) << 24);
TSTATUS.value = T02.value; //20061009 anson's endian
Mds_SendComplete( Adapter, &TSTATUS );
T02.value = cpu_to_le32(pltmp[i]) >> 8;
}
return;
error:
OS_ATOMIC_DEC( pHwData->Adapter, &pWb35Tx->TxResultCount ); OS_ATOMIC_DEC( pHwData->Adapter, &pWb35Tx->TxResultCount );
pWb35Tx->EP2vm_state = VM_STOP; pWb35Tx->EP2vm_state = VM_STOP;
} }
......
...@@ -218,114 +218,111 @@ int wb35_probe(struct usb_interface *intf, const struct usb_device_id *id_table) ...@@ -218,114 +218,111 @@ int wb35_probe(struct usb_interface *intf, const struct usb_device_id *id_table)
printk("[w35und]wb35_probe ->\n"); printk("[w35und]wb35_probe ->\n");
do { for (i=0; i<(sizeof(Id_Table)/sizeof(struct usb_device_id)); i++ ) {
for (i=0; i<(sizeof(Id_Table)/sizeof(struct usb_device_id)); i++ ) { if ((udev->descriptor.idVendor == Id_Table[i].idVendor) &&
if ((udev->descriptor.idVendor == Id_Table[i].idVendor) && (udev->descriptor.idProduct == Id_Table[i].idProduct)) {
(udev->descriptor.idProduct == Id_Table[i].idProduct)) { printk("[w35und]Found supported hardware\n");
printk("[w35und]Found supported hardware\n"); break;
break;
}
}
if ((i == (sizeof(Id_Table)/sizeof(struct usb_device_id)))) {
#ifdef _PE_USB_INI_DUMP_
WBDEBUG(("[w35und] This is not the one we are interested about\n"));
#endif
return -ENODEV;
} }
}
// 20060630.2 Check the device if it already be opened if ((i == (sizeof(Id_Table)/sizeof(struct usb_device_id)))) {
ret = usb_control_msg(udev, usb_rcvctrlpipe( udev, 0 ), #ifdef _PE_USB_INI_DUMP_
0x01, USB_TYPE_VENDOR|USB_RECIP_DEVICE|USB_DIR_IN, WBDEBUG(("[w35und] This is not the one we are interested about\n"));
0x0, 0x400, &ltmp, 4, HZ*100 ); #endif
if( ret < 0 ) return -ENODEV;
break; }
ltmp = cpu_to_le32(ltmp); // 20060630.2 Check the device if it already be opened
if (ltmp) // Is already initialized? ret = usb_control_msg(udev, usb_rcvctrlpipe( udev, 0 ),
break; 0x01, USB_TYPE_VENDOR|USB_RECIP_DEVICE|USB_DIR_IN,
0x0, 0x400, &ltmp, 4, HZ*100 );
if (ret < 0)
goto error;
ltmp = cpu_to_le32(ltmp);
if (ltmp) // Is already initialized?
goto error;
Adapter = kzalloc(sizeof(ADAPTER), GFP_KERNEL); Adapter = kzalloc(sizeof(ADAPTER), GFP_KERNEL);
my_adapter = Adapter; my_adapter = Adapter;
pWbLinux = &Adapter->WbLinux; pWbLinux = &Adapter->WbLinux;
pWbUsb = &Adapter->sHwData.WbUsb; pWbUsb = &Adapter->sHwData.WbUsb;
pWbUsb->udev = udev; pWbUsb->udev = udev;
interface = intf->cur_altsetting; interface = intf->cur_altsetting;
endpoint = &interface->endpoint[0].desc; endpoint = &interface->endpoint[0].desc;
if (endpoint[2].wMaxPacketSize == 512) { if (endpoint[2].wMaxPacketSize == 512) {
printk("[w35und] Working on USB 2.0\n"); printk("[w35und] Working on USB 2.0\n");
pWbUsb->IsUsb20 = 1; pWbUsb->IsUsb20 = 1;
} }
if (!WbWLanInitialize(Adapter)) { if (!WbWLanInitialize(Adapter)) {
printk("[w35und]WbWLanInitialize fail\n"); printk("[w35und]WbWLanInitialize fail\n");
break; goto error;
} }
{ {
struct wbsoft_priv *priv; struct wbsoft_priv *priv;
struct ieee80211_hw *dev; struct ieee80211_hw *dev;
int res; int res;
dev = ieee80211_alloc_hw(sizeof(*priv), &wbsoft_ops); dev = ieee80211_alloc_hw(sizeof(*priv), &wbsoft_ops);
if (!dev) { if (!dev) {
printk("w35und: ieee80211 alloc failed\n" ); printk("w35und: ieee80211 alloc failed\n" );
BUG(); BUG();
} }
my_dev = dev; my_dev = dev;
SET_IEEE80211_DEV(dev, &udev->dev); SET_IEEE80211_DEV(dev, &udev->dev);
{ {
phw_data_t pHwData = &Adapter->sHwData; phw_data_t pHwData = &Adapter->sHwData;
unsigned char dev_addr[MAX_ADDR_LEN]; unsigned char dev_addr[MAX_ADDR_LEN];
hal_get_permanent_address(pHwData, dev_addr); hal_get_permanent_address(pHwData, dev_addr);
SET_IEEE80211_PERM_ADDR(dev, dev_addr); SET_IEEE80211_PERM_ADDR(dev, dev_addr);
} }
dev->extra_tx_headroom = 12; /* FIXME */ dev->extra_tx_headroom = 12; /* FIXME */
dev->flags = 0; dev->flags = 0;
dev->channel_change_time = 1000; dev->channel_change_time = 1000;
// dev->max_rssi = 100; // dev->max_rssi = 100;
dev->queues = 1; dev->queues = 1;
static struct ieee80211_supported_band band; static struct ieee80211_supported_band band;
band.channels = wbsoft_channels; band.channels = wbsoft_channels;
band.n_channels = ARRAY_SIZE(wbsoft_channels); band.n_channels = ARRAY_SIZE(wbsoft_channels);
band.bitrates = wbsoft_rates; band.bitrates = wbsoft_rates;
band.n_bitrates = ARRAY_SIZE(wbsoft_rates); band.n_bitrates = ARRAY_SIZE(wbsoft_rates);
dev->wiphy->bands[IEEE80211_BAND_2GHZ] = &band; dev->wiphy->bands[IEEE80211_BAND_2GHZ] = &band;
#if 0 #if 0
wbsoft_modes[0].num_channels = 1; wbsoft_modes[0].num_channels = 1;
wbsoft_modes[0].channels = wbsoft_channels; wbsoft_modes[0].channels = wbsoft_channels;
wbsoft_modes[0].mode = MODE_IEEE80211B; wbsoft_modes[0].mode = MODE_IEEE80211B;
wbsoft_modes[0].num_rates = ARRAY_SIZE(wbsoft_rates); wbsoft_modes[0].num_rates = ARRAY_SIZE(wbsoft_rates);
wbsoft_modes[0].rates = wbsoft_rates; wbsoft_modes[0].rates = wbsoft_rates;
res = ieee80211_register_hwmode(dev, &wbsoft_modes[0]); res = ieee80211_register_hwmode(dev, &wbsoft_modes[0]);
BUG_ON(res); BUG_ON(res);
#endif #endif
res = ieee80211_register_hw(dev); res = ieee80211_register_hw(dev);
BUG_ON(res); BUG_ON(res);
} }
usb_set_intfdata( intf, Adapter );
printk("[w35und] _probe OK\n");
return 0;
} while(FALSE); usb_set_intfdata( intf, Adapter );
printk("[w35und] _probe OK\n");
return 0;
error:
return -ENOMEM; return -ENOMEM;
} }
......
...@@ -147,114 +147,112 @@ WbWLanInitialize(PADAPTER Adapter) ...@@ -147,114 +147,112 @@ WbWLanInitialize(PADAPTER Adapter)
u8 EEPROM_region; u8 EEPROM_region;
u8 HwRadioOff; u8 HwRadioOff;
do { //
// // Setting default value for Linux
// Setting default value for Linux //
// Adapter->sLocalPara.region_INF = REGION_AUTO;
Adapter->sLocalPara.region_INF = REGION_AUTO; Adapter->sLocalPara.TxRateMode = RATE_AUTO;
Adapter->sLocalPara.TxRateMode = RATE_AUTO; psLOCAL->bMacOperationMode = MODE_802_11_BG; // B/G mode
psLOCAL->bMacOperationMode = MODE_802_11_BG; // B/G mode Adapter->Mds.TxRTSThreshold = DEFAULT_RTSThreshold;
Adapter->Mds.TxRTSThreshold = DEFAULT_RTSThreshold; Adapter->Mds.TxFragmentThreshold = DEFAULT_FRAGMENT_THRESHOLD;
Adapter->Mds.TxFragmentThreshold = DEFAULT_FRAGMENT_THRESHOLD; hal_set_phy_type( &Adapter->sHwData, RF_WB_242_1 );
hal_set_phy_type( &Adapter->sHwData, RF_WB_242_1 ); Adapter->sLocalPara.MTUsize = MAX_ETHERNET_PACKET_SIZE;
Adapter->sLocalPara.MTUsize = MAX_ETHERNET_PACKET_SIZE; psLOCAL->bPreambleMode = AUTO_MODE;
psLOCAL->bPreambleMode = AUTO_MODE; Adapter->sLocalPara.RadioOffStatus.boSwRadioOff = FALSE;
Adapter->sLocalPara.RadioOffStatus.boSwRadioOff = FALSE; pHwData = &Adapter->sHwData;
pHwData = &Adapter->sHwData; hal_set_phy_type( pHwData, RF_DECIDE_BY_INF );
hal_set_phy_type( pHwData, RF_DECIDE_BY_INF );
//
// // Initial each module and variable
// Initial each module and variable //
// if (!WBLINUX_Initial(Adapter)) {
if (!WBLINUX_Initial(Adapter)) {
#ifdef _PE_USB_INI_DUMP_ #ifdef _PE_USB_INI_DUMP_
WBDEBUG(("[w35und]WBNDIS initialization failed\n")); WBDEBUG(("[w35und]WBNDIS initialization failed\n"));
#endif #endif
break; goto error;
} }
// Initial Software variable // Initial Software variable
Adapter->sLocalPara.ShutDowned = FALSE; Adapter->sLocalPara.ShutDowned = FALSE;
//added by ws for wep key error detection //added by ws for wep key error detection
Adapter->sLocalPara.bWepKeyError= FALSE; Adapter->sLocalPara.bWepKeyError= FALSE;
Adapter->sLocalPara.bToSelfPacketReceived = FALSE; Adapter->sLocalPara.bToSelfPacketReceived = FALSE;
Adapter->sLocalPara.WepKeyDetectTimerCount= 2 * 100; /// 2 seconds Adapter->sLocalPara.WepKeyDetectTimerCount= 2 * 100; /// 2 seconds
// Initial USB hal // Initial USB hal
InitStep = 1; InitStep = 1;
pHwData = &Adapter->sHwData; pHwData = &Adapter->sHwData;
if (!hal_init_hardware(pHwData, Adapter)) if (!hal_init_hardware(pHwData, Adapter))
break; goto error;
EEPROM_region = hal_get_region_from_EEPROM( pHwData ); EEPROM_region = hal_get_region_from_EEPROM( pHwData );
if (EEPROM_region != REGION_AUTO) if (EEPROM_region != REGION_AUTO)
psLOCAL->region = EEPROM_region; psLOCAL->region = EEPROM_region;
else { else {
if (psLOCAL->region_INF != REGION_AUTO) if (psLOCAL->region_INF != REGION_AUTO)
psLOCAL->region = psLOCAL->region_INF; psLOCAL->region = psLOCAL->region_INF;
else else
psLOCAL->region = REGION_USA; //default setting psLOCAL->region = REGION_USA; //default setting
} }
// Get Software setting flag from hal // Get Software setting flag from hal
Adapter->sLocalPara.boAntennaDiversity = FALSE; Adapter->sLocalPara.boAntennaDiversity = FALSE;
if (hal_software_set(pHwData) & 0x00000001) if (hal_software_set(pHwData) & 0x00000001)
Adapter->sLocalPara.boAntennaDiversity = TRUE; Adapter->sLocalPara.boAntennaDiversity = TRUE;
// //
// For TS module // For TS module
// //
InitStep = 2; InitStep = 2;
// For MDS module // For MDS module
InitStep = 3; InitStep = 3;
Mds_initial(Adapter); Mds_initial(Adapter);
//======================================= //=======================================
// Initialize the SME, SCAN, MLME, ROAM // Initialize the SME, SCAN, MLME, ROAM
//======================================= //=======================================
InitStep = 4; InitStep = 4;
InitStep = 5; InitStep = 5;
InitStep = 6; InitStep = 6;
// If no user-defined address in the registry, use the addresss "burned" on the NIC instead. // If no user-defined address in the registry, use the addresss "burned" on the NIC instead.
pMacAddr = Adapter->sLocalPara.ThisMacAddress; pMacAddr = Adapter->sLocalPara.ThisMacAddress;
pMacAddr2 = Adapter->sLocalPara.PermanentAddress; pMacAddr2 = Adapter->sLocalPara.PermanentAddress;
hal_get_permanent_address( pHwData, Adapter->sLocalPara.PermanentAddress );// Reading ethernet address from EEPROM hal_get_permanent_address( pHwData, Adapter->sLocalPara.PermanentAddress );// Reading ethernet address from EEPROM
if (OS_MEMORY_COMPARE(pMacAddr, "\x00\x00\x00\x00\x00\x00", MAC_ADDR_LENGTH )) // Is equal if (OS_MEMORY_COMPARE(pMacAddr, "\x00\x00\x00\x00\x00\x00", MAC_ADDR_LENGTH )) // Is equal
{ {
memcpy( pMacAddr, pMacAddr2, MAC_ADDR_LENGTH ); memcpy( pMacAddr, pMacAddr2, MAC_ADDR_LENGTH );
} else { } else {
// Set the user define MAC address // Set the user define MAC address
hal_set_ethernet_address( pHwData, Adapter->sLocalPara.ThisMacAddress ); hal_set_ethernet_address( pHwData, Adapter->sLocalPara.ThisMacAddress );
} }
//get current antenna //get current antenna
psLOCAL->bAntennaNo = hal_get_antenna_number(pHwData); psLOCAL->bAntennaNo = hal_get_antenna_number(pHwData);
#ifdef _PE_STATE_DUMP_ #ifdef _PE_STATE_DUMP_
WBDEBUG(("Driver init, antenna no = %d\n", psLOCAL->bAntennaNo)); WBDEBUG(("Driver init, antenna no = %d\n", psLOCAL->bAntennaNo));
#endif #endif
hal_get_hw_radio_off( pHwData ); hal_get_hw_radio_off( pHwData );
// Waiting for HAL setting OK // Waiting for HAL setting OK
while (!hal_idle(pHwData)) while (!hal_idle(pHwData))
OS_SLEEP(10000); OS_SLEEP(10000);
MTO_Init(Adapter); MTO_Init(Adapter);
HwRadioOff = hal_get_hw_radio_off( pHwData ); HwRadioOff = hal_get_hw_radio_off( pHwData );
psLOCAL->RadioOffStatus.boHwRadioOff = !!HwRadioOff; psLOCAL->RadioOffStatus.boHwRadioOff = !!HwRadioOff;
hal_set_radio_mode( pHwData, (unsigned char)(psLOCAL->RadioOffStatus.boSwRadioOff || psLOCAL->RadioOffStatus.boHwRadioOff) ); hal_set_radio_mode( pHwData, (unsigned char)(psLOCAL->RadioOffStatus.boSwRadioOff || psLOCAL->RadioOffStatus.boHwRadioOff) );
hal_driver_init_OK(pHwData) = 1; // Notify hal that the driver is ready now. hal_driver_init_OK(pHwData) = 1; // Notify hal that the driver is ready now.
//set a tx power for reference..... //set a tx power for reference.....
// sme_set_tx_power_level(Adapter, 12); FIXME? // sme_set_tx_power_level(Adapter, 12); FIXME?
return TRUE; return TRUE;
}
while(FALSE);
error:
switch (InitStep) { switch (InitStep) {
case 5: case 5:
case 4: case 4:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment