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,12 +35,11 @@ void Wb35Rx( phw_data_t pHwData )
//
// Issuing URB
//
do {
if (pHwData->SurpriseRemove || pHwData->HwStop)
break;
goto error;
if (pWb35Rx->rx_halt)
break;
goto error;
// Get RxBuffer's ID
RxBufferId = pWb35Rx->RxBufferId;
......@@ -49,7 +48,7 @@ void Wb35Rx( phw_data_t pHwData )
#ifdef _PE_RX_DUMP_
WBDEBUG(("Rx driver fifo unavailable\n"));
#endif
break;
goto error;
}
// Update buffer point, then start to bulkin the data from USB
......@@ -60,7 +59,7 @@ void Wb35Rx( phw_data_t pHwData )
if (1 != OS_MEMORY_ALLOC((void* *)&pWb35Rx->pDRx, MAX_USB_RX_BUFFER)) {
printk("w35und: Rx memory alloc failed\n");
break;
goto error;
}
pRxBufferAddress = pWb35Rx->pDRx;
......@@ -75,11 +74,11 @@ void Wb35Rx( phw_data_t pHwData )
if (retv != 0) {
printk("Rx URB sending error\n");
break;
goto error;
}
return;
} while(FALSE);
error:
// VM stop
pWb35Rx->EP3vm_state = VM_STOP;
OS_ATOMIC_DEC( pHwData->Adapter, &pWb35Rx->RxFireCounter );
......@@ -99,7 +98,6 @@ void Wb35Rx_Complete(PURB pUrb)
pWb35Rx->EP3vm_state = VM_COMPLETED;
pWb35Rx->EP3VM_status = pUrb->status;//Store the last result of Irp
do {
RxBufferId = pWb35Rx->CurrentRxBufferId;
pRxBufferAddress = pWb35Rx->pDRx;
......@@ -109,10 +107,10 @@ void Wb35Rx_Complete(PURB pUrb)
pWb35Rx->EP3vm_state = VM_COMPLETED;
if (pHwData->SurpriseRemove || pHwData->HwStop) // Must be here, or RxBufferId is invalid
break;
goto error;
if (pWb35Rx->rx_halt)
break;
goto error;
// Start to process the data only in successful condition
pWb35Rx->RxOwner[ RxBufferId ] = 0; // Set the owner to driver
......@@ -125,7 +123,7 @@ void Wb35Rx_Complete(PURB pUrb)
DebugUsbdStatusInformation( pWb35Rx->EP3VM_status );
#endif
pWb35Rx->EP3vm_state = VM_STOP;
break;
goto error;
}
// 20060220 For recovering. check if operating in single USB mode
......@@ -156,8 +154,7 @@ void Wb35Rx_Complete(PURB pUrb)
Wb35Rx(pHwData);
return;
} while(FALSE);
error:
pWb35Rx->RxOwner[ RxBufferId ] = 1; // Set the owner to hardware
OS_ATOMIC_DEC( pHwData->Adapter, &pWb35Rx->RxFireCounter );
pWb35Rx->EP3vm_state = VM_STOP;
......
......@@ -100,25 +100,24 @@ void Wb35Tx_complete(struct urb * pUrb)
pWb35Tx->TxSendIndex++;
pWb35Tx->TxSendIndex %= MAX_USB_TX_BUFFER_NUMBER;
do {
if (pHwData->SurpriseRemove || pHwData->HwStop) // Let WbWlanHalt to handle surprise remove
break;
goto error;
if (pWb35Tx->tx_halt)
break;
goto error;
// The URB is completed, check the result
if (pWb35Tx->EP4VM_status != 0) {
printk("URB submission failed\n");
pWb35Tx->EP4vm_state = VM_STOP;
break; // Exit while(FALSE);
goto error;
}
Mds_Tx(Adapter);
Wb35Tx(pHwData);
return;
} while(FALSE);
error:
OS_ATOMIC_DEC( pHwData->Adapter, &pWb35Tx->TxFireCounter );
pWb35Tx->EP4vm_state = VM_STOP;
}
......@@ -228,12 +227,11 @@ void Wb35Tx_EP2VM(phw_data_t pHwData)
u32 * pltmp = (u32 *)pWb35Tx->EP2_buf;
int retv;
do {
if (pHwData->SurpriseRemove || pHwData->HwStop)
break;
goto error;
if (pWb35Tx->tx_halt)
break;
goto error;
//
// Issuing URB
......@@ -244,17 +242,15 @@ void Wb35Tx_EP2VM(phw_data_t pHwData)
pWb35Tx->EP2vm_state = VM_RUNNING;
retv = wb_usb_submit_urb( pUrb );
if(retv < 0) {
if (retv < 0) {
#ifdef _PE_TX_DUMP_
WBDEBUG(("EP2 Tx Irp sending error\n"));
#endif
break;
goto error;
}
return;
} while(FALSE);
error:
pWb35Tx->EP2vm_state = VM_STOP;
OS_ATOMIC_DEC( pHwData->Adapter, &pWb35Tx->TxResultCount );
}
......@@ -275,19 +271,18 @@ void Wb35Tx_EP2VM_complete(struct urb * pUrb)
pWb35Tx->EP2vm_state = VM_COMPLETED;
pWb35Tx->EP2VM_status = pUrb->status;
do {
// For Linux 2.4. Interrupt will always trigger
if( pHwData->SurpriseRemove || pHwData->HwStop ) // Let WbWlanHalt to handle surprise remove
break;
if (pHwData->SurpriseRemove || pHwData->HwStop) // Let WbWlanHalt to handle surprise remove
goto error;
if( pWb35Tx->tx_halt )
break;
if (pWb35Tx->tx_halt)
goto error;
//The Urb is completed, check the result
if (pWb35Tx->EP2VM_status != 0) {
WBDEBUG(("EP2 IoCompleteRoutine return error\n"));
pWb35Tx->EP2vm_state= VM_STOP;
break; // Exit while(FALSE);
goto error;
}
// Update the Tx result
......@@ -296,7 +291,7 @@ void Wb35Tx_EP2VM_complete(struct urb * pUrb)
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++) {
for (i = 1; i <= InterruptInLength; i++) {
T02.value |= ((cpu_to_le32(pltmp[i]) & 0xff) << 24);
TSTATUS.value = T02.value; //20061009 anson's endian
......@@ -305,8 +300,7 @@ void Wb35Tx_EP2VM_complete(struct urb * pUrb)
}
return;
} while(FALSE);
error:
OS_ATOMIC_DEC( pHwData->Adapter, &pWb35Tx->TxResultCount );
pWb35Tx->EP2vm_state = VM_STOP;
}
......
......@@ -218,7 +218,6 @@ int wb35_probe(struct usb_interface *intf, const struct usb_device_id *id_table)
printk("[w35und]wb35_probe ->\n");
do {
for (i=0; i<(sizeof(Id_Table)/sizeof(struct usb_device_id)); i++ ) {
if ((udev->descriptor.idVendor == Id_Table[i].idVendor) &&
(udev->descriptor.idProduct == Id_Table[i].idProduct)) {
......@@ -226,6 +225,7 @@ int wb35_probe(struct usb_interface *intf, const struct usb_device_id *id_table)
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"));
......@@ -237,13 +237,12 @@ int wb35_probe(struct usb_interface *intf, const struct usb_device_id *id_table)
ret = usb_control_msg(udev, usb_rcvctrlpipe( udev, 0 ),
0x01, USB_TYPE_VENDOR|USB_RECIP_DEVICE|USB_DIR_IN,
0x0, 0x400, &ltmp, 4, HZ*100 );
if( ret < 0 )
break;
if (ret < 0)
goto error;
ltmp = cpu_to_le32(ltmp);
if (ltmp) // Is already initialized?
break;
goto error;
Adapter = kzalloc(sizeof(ADAPTER), GFP_KERNEL);
......@@ -262,7 +261,7 @@ int wb35_probe(struct usb_interface *intf, const struct usb_device_id *id_table)
if (!WbWLanInitialize(Adapter)) {
printk("[w35und]WbWLanInitialize fail\n");
break;
goto error;
}
{
......@@ -323,9 +322,7 @@ int wb35_probe(struct usb_interface *intf, const struct usb_device_id *id_table)
printk("[w35und] _probe OK\n");
return 0;
} while(FALSE);
error:
return -ENOMEM;
}
......
......@@ -147,7 +147,6 @@ WbWLanInitialize(PADAPTER Adapter)
u8 EEPROM_region;
u8 HwRadioOff;
do {
//
// Setting default value for Linux
//
......@@ -170,7 +169,7 @@ WbWLanInitialize(PADAPTER Adapter)
#ifdef _PE_USB_INI_DUMP_
WBDEBUG(("[w35und]WBNDIS initialization failed\n"));
#endif
break;
goto error;
}
// Initial Software variable
......@@ -185,7 +184,7 @@ WbWLanInitialize(PADAPTER Adapter)
InitStep = 1;
pHwData = &Adapter->sHwData;
if (!hal_init_hardware(pHwData, Adapter))
break;
goto error;
EEPROM_region = hal_get_region_from_EEPROM( pHwData );
if (EEPROM_region != REGION_AUTO)
......@@ -252,9 +251,8 @@ WbWLanInitialize(PADAPTER Adapter)
//set a tx power for reference.....
// sme_set_tx_power_level(Adapter, 12); FIXME?
return TRUE;
}
while(FALSE);
error:
switch (InitStep) {
case 5:
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