diff options
| -rw-r--r-- | drivers/staging/winbond/wb35tx.c | 89 |
1 files changed, 44 insertions, 45 deletions
diff --git a/drivers/staging/winbond/wb35tx.c b/drivers/staging/winbond/wb35tx.c index 0f870da125fc..a4074fd9d30b 100644 --- a/drivers/staging/winbond/wb35tx.c +++ b/drivers/staging/winbond/wb35tx.c | |||
| @@ -1,13 +1,13 @@ | |||
| 1 | //============================================================================ | 1 | /* |
| 2 | // Copyright (c) 1996-2002 Winbond Electronic Corporation | 2 | * Copyright (c) 1996-2002 Winbond Electronic Corporation |
| 3 | // | 3 | * |
| 4 | // Module Name: | 4 | * Module Name: |
| 5 | // Wb35Tx.c | 5 | * Wb35Tx.c |
| 6 | // | 6 | * |
| 7 | // Abstract: | 7 | * Abstract: |
| 8 | // Processing the Tx message and put into down layer | 8 | * Processing the Tx message and put into down layer |
| 9 | // | 9 | * |
| 10 | //============================================================================ | 10 | */ |
| 11 | #include <linux/usb.h> | 11 | #include <linux/usb.h> |
| 12 | #include <linux/gfp.h> | 12 | #include <linux/gfp.h> |
| 13 | 13 | ||
| @@ -33,20 +33,21 @@ static void Wb35Tx_complete(struct urb * pUrb) | |||
| 33 | struct wb35_mds *pMds = &adapter->Mds; | 33 | struct wb35_mds *pMds = &adapter->Mds; |
| 34 | 34 | ||
| 35 | printk("wb35: tx complete\n"); | 35 | printk("wb35: tx complete\n"); |
| 36 | // Variable setting | 36 | /* Variable setting */ |
| 37 | pWb35Tx->EP4vm_state = VM_COMPLETED; | 37 | pWb35Tx->EP4vm_state = VM_COMPLETED; |
| 38 | pWb35Tx->EP4VM_status = pUrb->status; //Store the last result of Irp | 38 | pWb35Tx->EP4VM_status = pUrb->status; /* Store the last result of Irp */ |
| 39 | pMds->TxOwner[ pWb35Tx->TxSendIndex ] = 0;// Set the owner. Free the owner bit always. | 39 | /* Set the owner. Free the owner bit always. */ |
| 40 | pMds->TxOwner[ pWb35Tx->TxSendIndex ] = 0; | ||
| 40 | pWb35Tx->TxSendIndex++; | 41 | pWb35Tx->TxSendIndex++; |
| 41 | pWb35Tx->TxSendIndex %= MAX_USB_TX_BUFFER_NUMBER; | 42 | pWb35Tx->TxSendIndex %= MAX_USB_TX_BUFFER_NUMBER; |
| 42 | 43 | ||
| 43 | if (pHwData->SurpriseRemove) // Let WbWlanHalt to handle surprise remove | 44 | if (pHwData->SurpriseRemove) /* Let WbWlanHalt to handle surprise remove */ |
| 44 | goto error; | 45 | goto error; |
| 45 | 46 | ||
| 46 | if (pWb35Tx->tx_halt) | 47 | if (pWb35Tx->tx_halt) |
| 47 | goto error; | 48 | goto error; |
| 48 | 49 | ||
| 49 | // The URB is completed, check the result | 50 | /* The URB is completed, check the result */ |
| 50 | if (pWb35Tx->EP4VM_status != 0) { | 51 | if (pWb35Tx->EP4VM_status != 0) { |
| 51 | printk("URB submission failed\n"); | 52 | printk("URB submission failed\n"); |
| 52 | pWb35Tx->EP4vm_state = VM_STOP; | 53 | pWb35Tx->EP4vm_state = VM_STOP; |
| @@ -79,15 +80,15 @@ static void Wb35Tx(struct wbsoft_priv *adapter) | |||
| 79 | if (pWb35Tx->tx_halt) | 80 | if (pWb35Tx->tx_halt) |
| 80 | goto cleanup; | 81 | goto cleanup; |
| 81 | 82 | ||
| 82 | // Ownership checking | 83 | /* Ownership checking */ |
| 83 | SendIndex = pWb35Tx->TxSendIndex; | 84 | SendIndex = pWb35Tx->TxSendIndex; |
| 84 | if (!pMds->TxOwner[SendIndex]) //No more data need to be sent, return immediately | 85 | /* No more data need to be sent, return immediately */ |
| 86 | if (!pMds->TxOwner[SendIndex]) | ||
| 85 | goto cleanup; | 87 | goto cleanup; |
| 86 | 88 | ||
| 87 | pTxBufferAddress = pWb35Tx->TxBuffer[SendIndex]; | 89 | pTxBufferAddress = pWb35Tx->TxBuffer[SendIndex]; |
| 88 | // | 90 | |
| 89 | // Issuing URB | 91 | /* Issuing URB */ |
| 90 | // | ||
| 91 | usb_fill_bulk_urb(pUrb, pHwData->udev, | 92 | usb_fill_bulk_urb(pUrb, pHwData->udev, |
| 92 | usb_sndbulkpipe(pHwData->udev, 4), | 93 | usb_sndbulkpipe(pHwData->udev, 4), |
| 93 | pTxBufferAddress, pMds->TxBufferSize[ SendIndex ], | 94 | pTxBufferAddress, pMds->TxBufferSize[ SendIndex ], |
| @@ -100,7 +101,7 @@ static void Wb35Tx(struct wbsoft_priv *adapter) | |||
| 100 | goto cleanup; | 101 | goto cleanup; |
| 101 | } | 102 | } |
| 102 | 103 | ||
| 103 | // Check if driver needs issue Irp for EP2 | 104 | /* Check if driver needs issue Irp for EP2 */ |
| 104 | pWb35Tx->TxFillCount += pMds->TxCountInBuffer[SendIndex]; | 105 | pWb35Tx->TxFillCount += pMds->TxCountInBuffer[SendIndex]; |
| 105 | if (pWb35Tx->TxFillCount > 12) | 106 | if (pWb35Tx->TxFillCount > 12) |
| 106 | Wb35Tx_EP2VM_start(adapter); | 107 | Wb35Tx_EP2VM_start(adapter); |
| @@ -118,7 +119,7 @@ void Wb35Tx_start(struct wbsoft_priv *adapter) | |||
| 118 | struct hw_data * pHwData = &adapter->sHwData; | 119 | struct hw_data * pHwData = &adapter->sHwData; |
| 119 | struct wb35_tx *pWb35Tx = &pHwData->Wb35Tx; | 120 | struct wb35_tx *pWb35Tx = &pHwData->Wb35Tx; |
| 120 | 121 | ||
| 121 | // Allow only one thread to run into function | 122 | /* Allow only one thread to run into function */ |
| 122 | if (atomic_inc_return(&pWb35Tx->TxFireCounter) == 1) { | 123 | if (atomic_inc_return(&pWb35Tx->TxFireCounter) == 1) { |
| 123 | pWb35Tx->EP4vm_state = VM_RUNNING; | 124 | pWb35Tx->EP4vm_state = VM_RUNNING; |
| 124 | Wb35Tx(adapter); | 125 | Wb35Tx(adapter); |
| @@ -144,32 +145,32 @@ unsigned char Wb35Tx_initial(struct hw_data * pHwData) | |||
| 144 | return true; | 145 | return true; |
| 145 | } | 146 | } |
| 146 | 147 | ||
| 147 | //====================================================== | ||
| 148 | void Wb35Tx_stop(struct hw_data * pHwData) | 148 | void Wb35Tx_stop(struct hw_data * pHwData) |
| 149 | { | 149 | { |
| 150 | struct wb35_tx *pWb35Tx = &pHwData->Wb35Tx; | 150 | struct wb35_tx *pWb35Tx = &pHwData->Wb35Tx; |
| 151 | 151 | ||
| 152 | // Try to cancel the Trp of EP2 | 152 | /* Try to cancel the Trp of EP2 */ |
| 153 | if (pWb35Tx->EP2vm_state == VM_RUNNING) | 153 | if (pWb35Tx->EP2vm_state == VM_RUNNING) |
| 154 | usb_unlink_urb( pWb35Tx->Tx2Urb ); // Only use unlink, let Wb35Tx_destroy to free them | 154 | /* Only use unlink, let Wb35Tx_destroy to free them */ |
| 155 | usb_unlink_urb( pWb35Tx->Tx2Urb ); | ||
| 155 | pr_debug("EP2 Tx stop\n"); | 156 | pr_debug("EP2 Tx stop\n"); |
| 156 | 157 | ||
| 157 | // Try to cancel the Irp of EP4 | 158 | /* Try to cancel the Irp of EP4 */ |
| 158 | if (pWb35Tx->EP4vm_state == VM_RUNNING) | 159 | if (pWb35Tx->EP4vm_state == VM_RUNNING) |
| 159 | usb_unlink_urb( pWb35Tx->Tx4Urb ); // Only use unlink, let Wb35Tx_destroy to free them | 160 | /* Only use unlink, let Wb35Tx_destroy to free them */ |
| 161 | usb_unlink_urb( pWb35Tx->Tx4Urb ); | ||
| 160 | pr_debug("EP4 Tx stop\n"); | 162 | pr_debug("EP4 Tx stop\n"); |
| 161 | } | 163 | } |
| 162 | 164 | ||
| 163 | //====================================================== | ||
| 164 | void Wb35Tx_destroy(struct hw_data * pHwData) | 165 | void Wb35Tx_destroy(struct hw_data * pHwData) |
| 165 | { | 166 | { |
| 166 | struct wb35_tx *pWb35Tx = &pHwData->Wb35Tx; | 167 | struct wb35_tx *pWb35Tx = &pHwData->Wb35Tx; |
| 167 | 168 | ||
| 168 | // Wait for VM stop | 169 | /* Wait for VM stop */ |
| 169 | do { | 170 | do { |
| 170 | msleep(10); // Delay for waiting function enter 940623.1.a | 171 | msleep(10); /* Delay for waiting function enter 940623.1.a */ |
| 171 | } while( (pWb35Tx->EP2vm_state != VM_STOP) && (pWb35Tx->EP4vm_state != VM_STOP) ); | 172 | } while( (pWb35Tx->EP2vm_state != VM_STOP) && (pWb35Tx->EP4vm_state != VM_STOP) ); |
| 172 | msleep(10); // Delay for waiting function enter 940623.1.b | 173 | msleep(10); /* Delay for waiting function enter 940623.1.b */ |
| 173 | 174 | ||
| 174 | if (pWb35Tx->Tx4Urb) | 175 | if (pWb35Tx->Tx4Urb) |
| 175 | usb_free_urb( pWb35Tx->Tx4Urb ); | 176 | usb_free_urb( pWb35Tx->Tx4Urb ); |
| @@ -210,34 +211,34 @@ static void Wb35Tx_EP2VM_complete(struct urb * pUrb) | |||
| 210 | u16 InterruptInLength; | 211 | u16 InterruptInLength; |
| 211 | 212 | ||
| 212 | 213 | ||
| 213 | // Variable setting | 214 | /* Variable setting */ |
| 214 | pWb35Tx->EP2vm_state = VM_COMPLETED; | 215 | pWb35Tx->EP2vm_state = VM_COMPLETED; |
| 215 | pWb35Tx->EP2VM_status = pUrb->status; | 216 | pWb35Tx->EP2VM_status = pUrb->status; |
| 216 | 217 | ||
| 217 | // For Linux 2.4. Interrupt will always trigger | 218 | /* For Linux 2.4. Interrupt will always trigger */ |
| 218 | if (pHwData->SurpriseRemove) // Let WbWlanHalt to handle surprise remove | 219 | if (pHwData->SurpriseRemove) /* Let WbWlanHalt to handle surprise remove */ |
| 219 | goto error; | 220 | goto error; |
| 220 | 221 | ||
| 221 | if (pWb35Tx->tx_halt) | 222 | if (pWb35Tx->tx_halt) |
| 222 | goto error; | 223 | goto error; |
| 223 | 224 | ||
| 224 | //The Urb is completed, check the result | 225 | /* The Urb is completed, check the result */ |
| 225 | if (pWb35Tx->EP2VM_status != 0) { | 226 | if (pWb35Tx->EP2VM_status != 0) { |
| 226 | printk("EP2 IoCompleteRoutine return error\n"); | 227 | printk("EP2 IoCompleteRoutine return error\n"); |
| 227 | pWb35Tx->EP2vm_state= VM_STOP; | 228 | pWb35Tx->EP2vm_state= VM_STOP; |
| 228 | goto error; | 229 | goto error; |
| 229 | } | 230 | } |
| 230 | 231 | ||
| 231 | // Update the Tx result | 232 | /* Update the Tx result */ |
| 232 | InterruptInLength = pUrb->actual_length; | 233 | InterruptInLength = pUrb->actual_length; |
| 233 | // Modify for minimum memory access and DWORD alignment. | 234 | /* Modify for minimum memory access and DWORD alignment. */ |
| 234 | T02.value = cpu_to_le32(pltmp[0]) >> 8; // [31:8] -> [24:0] | 235 | T02.value = cpu_to_le32(pltmp[0]) >> 8; /* [31:8] -> [24:0] */ |
| 235 | InterruptInLength -= 1;// 20051221.1.c Modify the follow for more stable | 236 | InterruptInLength -= 1; /* 20051221.1.c Modify the follow for more stable */ |
| 236 | InterruptInLength >>= 2; // InterruptInLength/4 | 237 | InterruptInLength >>= 2; /* InterruptInLength/4 */ |
| 237 | for (i = 1; i <= InterruptInLength; i++) { | 238 | for (i = 1; i <= InterruptInLength; i++) { |
| 238 | T02.value |= ((cpu_to_le32(pltmp[i]) & 0xff) << 24); | 239 | T02.value |= ((cpu_to_le32(pltmp[i]) & 0xff) << 24); |
| 239 | 240 | ||
| 240 | TSTATUS.value = T02.value; //20061009 anson's endian | 241 | TSTATUS.value = T02.value; /* 20061009 anson's endian */ |
| 241 | Mds_SendComplete( adapter, &TSTATUS ); | 242 | Mds_SendComplete( adapter, &TSTATUS ); |
| 242 | T02.value = cpu_to_le32(pltmp[i]) >> 8; | 243 | T02.value = cpu_to_le32(pltmp[i]) >> 8; |
| 243 | } | 244 | } |
| @@ -262,9 +263,7 @@ static void Wb35Tx_EP2VM(struct wbsoft_priv *adapter) | |||
| 262 | if (pWb35Tx->tx_halt) | 263 | if (pWb35Tx->tx_halt) |
| 263 | goto error; | 264 | goto error; |
| 264 | 265 | ||
| 265 | // | 266 | /* Issuing URB */ |
| 266 | // Issuing URB | ||
| 267 | // | ||
| 268 | usb_fill_int_urb( pUrb, pHwData->udev, usb_rcvintpipe(pHwData->udev,2), | 267 | usb_fill_int_urb( pUrb, pHwData->udev, usb_rcvintpipe(pHwData->udev,2), |
| 269 | pltmp, MAX_INTERRUPT_LENGTH, Wb35Tx_EP2VM_complete, adapter, 32); | 268 | pltmp, MAX_INTERRUPT_LENGTH, Wb35Tx_EP2VM_complete, adapter, 32); |
| 270 | 269 | ||
| @@ -287,7 +286,7 @@ void Wb35Tx_EP2VM_start(struct wbsoft_priv *adapter) | |||
| 287 | struct hw_data * pHwData = &adapter->sHwData; | 286 | struct hw_data * pHwData = &adapter->sHwData; |
| 288 | struct wb35_tx *pWb35Tx = &pHwData->Wb35Tx; | 287 | struct wb35_tx *pWb35Tx = &pHwData->Wb35Tx; |
| 289 | 288 | ||
| 290 | // Allow only one thread to run into function | 289 | /* Allow only one thread to run into function */ |
| 291 | if (atomic_inc_return(&pWb35Tx->TxResultCount) == 1) { | 290 | if (atomic_inc_return(&pWb35Tx->TxResultCount) == 1) { |
| 292 | pWb35Tx->EP2vm_state = VM_RUNNING; | 291 | pWb35Tx->EP2vm_state = VM_RUNNING; |
| 293 | Wb35Tx_EP2VM(adapter); | 292 | Wb35Tx_EP2VM(adapter); |
