Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Staging: winbond: wb35rx.c Coding style fixes v2.

New patch that fixes an unclear comment too.

I fixed checkpatch issues except for long lines and printk:s.
I also removed version comments and the () in a return statement.
Generated .o is identical to master and i checked the code with
Dan Carpenters strip_whitespace.pl and diff.

Signed-off-by: Lars Lindley <lindley@coyote.org>
Acked-by: Dan Carpenter <error27@gmail.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Lars Lindley and committed by
Greg Kroah-Hartman
6112fd6e 42cb2945

+121 -133
+121 -133
drivers/staging/winbond/wb35rx.c
··· 1 - //============================================================================ 2 - // Copyright (c) 1996-2002 Winbond Electronic Corporation 3 - // 4 - // Module Name: 5 - // Wb35Rx.c 6 - // 7 - // Abstract: 8 - // Processing the Rx message from down layer 9 - // 10 - //============================================================================ 1 + /* 2 + * ============================================================================ 3 + * Copyright (c) 1996-2002 Winbond Electronic Corporation 4 + * 5 + * Module Name: 6 + * Wb35Rx.c 7 + * 8 + * Abstract: 9 + * Processing the Rx message from down layer 10 + * 11 + * ============================================================================ 12 + */ 11 13 #include <linux/usb.h> 12 14 #include <linux/slab.h> 13 15 ··· 32 30 return; 33 31 } 34 32 35 - memcpy(skb_put(skb, PacketSize), 36 - pRxBufferAddress, 37 - PacketSize); 38 - 39 - /* 40 - rx_status.rate = 10; 41 - rx_status.channel = 1; 42 - rx_status.freq = 12345; 43 - rx_status.phymode = MODE_IEEE80211B; 44 - */ 33 + memcpy(skb_put(skb, PacketSize), pRxBufferAddress, PacketSize); 45 34 46 35 memcpy(IEEE80211_SKB_RXCB(skb), &rx_status, sizeof(rx_status)); 47 36 ieee80211_rx_irqsafe(hw, skb); ··· 40 47 41 48 static void Wb35Rx_adjust(struct wb35_descriptor *pRxDes) 42 49 { 43 - u32 * pRxBufferAddress; 50 + u32 *pRxBufferAddress; 44 51 u32 DecryptionMethod; 45 52 u32 i; 46 53 u16 BufferSize; ··· 49 56 pRxBufferAddress = pRxDes->buffer_address[0]; 50 57 BufferSize = pRxDes->buffer_size[0]; 51 58 52 - // Adjust the last part of data. Only data left 53 - BufferSize -= 4; // For CRC-32 59 + /* Adjust the last part of data. Only data left */ 60 + BufferSize -= 4; /* For CRC-32 */ 54 61 if (DecryptionMethod) 55 62 BufferSize -= 4; 56 - if (DecryptionMethod == 3) // For CCMP 63 + if (DecryptionMethod == 3) /* For CCMP */ 57 64 BufferSize -= 4; 58 65 59 - // Adjust the IV field which after 802.11 header and ICV field. 60 - if (DecryptionMethod == 1) // For WEP 61 - { 62 - for( i=6; i>0; i-- ) 63 - pRxBufferAddress[i] = pRxBufferAddress[i-1]; 66 + /* Adjust the IV field which after 802.11 header and ICV field. */ 67 + if (DecryptionMethod == 1) { /* For WEP */ 68 + for (i = 6; i > 0; i--) 69 + pRxBufferAddress[i] = pRxBufferAddress[i - 1]; 64 70 pRxDes->buffer_address[0] = pRxBufferAddress + 1; 65 - BufferSize -= 4; // 4 byte for IV 66 - } 67 - else if( DecryptionMethod ) // For TKIP and CCMP 68 - { 69 - for (i=7; i>1; i--) 70 - pRxBufferAddress[i] = pRxBufferAddress[i-2]; 71 - pRxDes->buffer_address[0] = pRxBufferAddress + 2;//Update the descriptor, shift 8 byte 72 - BufferSize -= 8; // 8 byte for IV + ICV 71 + BufferSize -= 4; /* 4 byte for IV */ 72 + } else if (DecryptionMethod) { /* For TKIP and CCMP */ 73 + for (i = 7; i > 1; i--) 74 + pRxBufferAddress[i] = pRxBufferAddress[i - 2]; 75 + pRxDes->buffer_address[0] = pRxBufferAddress + 2; /* Update the descriptor, shift 8 byte */ 76 + BufferSize -= 8; /* 8 byte for IV + ICV */ 73 77 } 74 78 pRxDes->buffer_size[0] = BufferSize; 75 79 } 76 80 77 81 static u16 Wb35Rx_indicate(struct ieee80211_hw *hw) 78 82 { 79 - struct wbsoft_priv *priv = hw->priv; 80 - struct hw_data * pHwData = &priv->sHwData; 83 + struct wbsoft_priv *priv = hw->priv; 84 + struct hw_data *pHwData = &priv->sHwData; 81 85 struct wb35_descriptor RxDes; 82 - struct wb35_rx *pWb35Rx = &pHwData->Wb35Rx; 83 - u8 * pRxBufferAddress; 84 - u16 PacketSize; 85 - u16 stmp, BufferSize, stmp2 = 0; 86 - u32 RxBufferId; 86 + struct wb35_rx *pWb35Rx = &pHwData->Wb35Rx; 87 + u8 *pRxBufferAddress; 88 + u16 PacketSize; 89 + u16 stmp, BufferSize, stmp2 = 0; 90 + u32 RxBufferId; 87 91 88 - // Only one thread be allowed to run into the following 92 + /* Only one thread be allowed to run into the following */ 89 93 do { 90 94 RxBufferId = pWb35Rx->RxProcessIndex; 91 - if (pWb35Rx->RxOwner[ RxBufferId ]) //Owner by VM 95 + if (pWb35Rx->RxOwner[RxBufferId]) /* Owner by VM */ 92 96 break; 93 97 94 98 pWb35Rx->RxProcessIndex++; 95 99 pWb35Rx->RxProcessIndex %= MAX_USB_RX_BUFFER_NUMBER; 96 100 97 101 pRxBufferAddress = pWb35Rx->pDRx; 98 - BufferSize = pWb35Rx->RxBufferSize[ RxBufferId ]; 102 + BufferSize = pWb35Rx->RxBufferSize[RxBufferId]; 99 103 100 - // Parse the bulkin buffer 104 + /* Parse the bulkin buffer */ 101 105 while (BufferSize >= 4) { 102 - if ((cpu_to_le32(*(u32 *)pRxBufferAddress) & 0x0fffffff) == RX_END_TAG) //Is ending? 921002.9.a 106 + if ((cpu_to_le32(*(u32 *)pRxBufferAddress) & 0x0fffffff) == RX_END_TAG) /* Is ending? */ 103 107 break; 104 108 105 - // Get the R00 R01 first 109 + /* Get the R00 R01 first */ 106 110 RxDes.R00.value = le32_to_cpu(*(u32 *)pRxBufferAddress); 107 111 PacketSize = (u16)RxDes.R00.R00_receive_byte_count; 108 - RxDes.R01.value = le32_to_cpu(*((u32 *)(pRxBufferAddress+4))); 109 - // For new DMA 4k 112 + RxDes.R01.value = le32_to_cpu(*((u32 *)(pRxBufferAddress + 4))); 113 + /* For new DMA 4k */ 110 114 if ((PacketSize & 0x03) > 0) 111 115 PacketSize -= 4; 112 116 113 - // Basic check for Rx length. Is length valid? 117 + /* Basic check for Rx length. Is length valid? */ 114 118 if (PacketSize > MAX_PACKET_SIZE) { 115 - #ifdef _PE_RX_DUMP_ 119 + #ifdef _PE_RX_DUMP_ 116 120 printk("Serious ERROR : Rx data size too long, size =%d\n", PacketSize); 117 - #endif 121 + #endif 118 122 119 123 pWb35Rx->EP3vm_state = VM_STOP; 120 124 pWb35Rx->Ep3ErrorCount2++; 121 125 break; 122 126 } 123 127 124 - // Start to process Rx buffer 125 - // RxDes.Descriptor_ID = RxBufferId; // Due to synchronous indicate, the field doesn't necessary to use. 126 - BufferSize -= 8; //subtract 8 byte for 35's USB header length 128 + /* 129 + * Wb35Rx_indicate() is called synchronously so it isn't 130 + * necessary to set "RxDes.Desctriptor_ID = RxBufferID;" 131 + */ 132 + BufferSize -= 8; /* subtract 8 byte for 35's USB header length */ 127 133 pRxBufferAddress += 8; 128 134 129 135 RxDes.buffer_address[0] = pRxBufferAddress; ··· 134 142 135 143 packet_came(hw, pRxBufferAddress, PacketSize); 136 144 137 - // Move RxBuffer point to the next 145 + /* Move RxBuffer point to the next */ 138 146 stmp = PacketSize + 3; 139 - stmp &= ~0x03; // 4n alignment 147 + stmp &= ~0x03; /* 4n alignment */ 140 148 pRxBufferAddress += stmp; 141 149 BufferSize -= stmp; 142 150 stmp2 += stmp; 143 151 } 144 152 145 - // Reclaim resource 146 - pWb35Rx->RxOwner[ RxBufferId ] = 1; 153 + /* Reclaim resource */ 154 + pWb35Rx->RxOwner[RxBufferId] = 1; 147 155 } while (true); 148 - 149 156 return stmp2; 150 157 } 151 158 ··· 152 161 153 162 static void Wb35Rx_Complete(struct urb *urb) 154 163 { 155 - struct ieee80211_hw *hw = urb->context; 156 - struct wbsoft_priv *priv = hw->priv; 157 - struct hw_data * pHwData = &priv->sHwData; 158 - struct wb35_rx *pWb35Rx = &pHwData->Wb35Rx; 159 - u8 * pRxBufferAddress; 160 - u32 SizeCheck; 161 - u16 BulkLength; 162 - u32 RxBufferId; 163 - R00_DESCRIPTOR R00; 164 + struct ieee80211_hw *hw = urb->context; 165 + struct wbsoft_priv *priv = hw->priv; 166 + struct hw_data *pHwData = &priv->sHwData; 167 + struct wb35_rx *pWb35Rx = &pHwData->Wb35Rx; 168 + u8 *pRxBufferAddress; 169 + u32 SizeCheck; 170 + u16 BulkLength; 171 + u32 RxBufferId; 172 + R00_DESCRIPTOR R00; 164 173 165 - // Variable setting 174 + /* Variable setting */ 166 175 pWb35Rx->EP3vm_state = VM_COMPLETED; 167 - pWb35Rx->EP3VM_status = urb->status;//Store the last result of Irp 176 + pWb35Rx->EP3VM_status = urb->status; /* Store the last result of Irp */ 168 177 169 178 RxBufferId = pWb35Rx->CurrentRxBufferId; 170 179 171 180 pRxBufferAddress = pWb35Rx->pDRx; 172 181 BulkLength = (u16)urb->actual_length; 173 182 174 - // The IRP is completed 183 + /* The IRP is completed */ 175 184 pWb35Rx->EP3vm_state = VM_COMPLETED; 176 185 177 - if (pHwData->SurpriseRemove || pHwData->HwStop) // Must be here, or RxBufferId is invalid 186 + if (pHwData->SurpriseRemove || pHwData->HwStop) /* Must be here, or RxBufferId is invalid */ 178 187 goto error; 179 188 180 189 if (pWb35Rx->rx_halt) 181 190 goto error; 182 191 183 - // Start to process the data only in successful condition 184 - pWb35Rx->RxOwner[ RxBufferId ] = 0; // Set the owner to driver 192 + /* Start to process the data only in successful condition */ 193 + pWb35Rx->RxOwner[RxBufferId] = 0; /* Set the owner to driver */ 185 194 R00.value = le32_to_cpu(*(u32 *)pRxBufferAddress); 186 195 187 - // The URB is completed, check the result 196 + /* The URB is completed, check the result */ 188 197 if (pWb35Rx->EP3VM_status != 0) { 189 - #ifdef _PE_USB_STATE_DUMP_ 198 + #ifdef _PE_USB_STATE_DUMP_ 190 199 printk("EP3 IoCompleteRoutine return error\n"); 191 - #endif 200 + #endif 192 201 pWb35Rx->EP3vm_state = VM_STOP; 193 202 goto error; 194 203 } 195 204 196 - // 20060220 For recovering. check if operating in single USB mode 205 + /* For recovering. check if operating in single USB mode */ 197 206 if (!HAL_USB_MODE_BURST(pHwData)) { 198 - SizeCheck = R00.R00_receive_byte_count; //20060926 anson's endian 207 + SizeCheck = R00.R00_receive_byte_count; 199 208 if ((SizeCheck & 0x03) > 0) 200 209 SizeCheck -= 4; 201 210 SizeCheck = (SizeCheck + 3) & ~0x03; 202 - SizeCheck += 12; // 8 + 4 badbeef 211 + SizeCheck += 12; /* 8 + 4 badbeef */ 203 212 if ((BulkLength > 1600) || 204 213 (SizeCheck > 1600) || 205 214 (BulkLength != SizeCheck) || 206 - (BulkLength == 0)) { // Add for fail Urb 215 + (BulkLength == 0)) { /* Add for fail Urb */ 207 216 pWb35Rx->EP3vm_state = VM_STOP; 208 217 pWb35Rx->Ep3ErrorCount2++; 209 218 } 210 219 } 211 220 212 - // Indicating the receiving data 221 + /* Indicating the receiving data */ 213 222 pWb35Rx->ByteReceived += BulkLength; 214 - pWb35Rx->RxBufferSize[ RxBufferId ] = BulkLength; 223 + pWb35Rx->RxBufferSize[RxBufferId] = BulkLength; 215 224 216 - if (!pWb35Rx->RxOwner[ RxBufferId ]) 225 + if (!pWb35Rx->RxOwner[RxBufferId]) 217 226 Wb35Rx_indicate(hw); 218 227 219 228 kfree(pWb35Rx->pDRx); 220 - // Do the next receive 229 + /* Do the next receive */ 221 230 Wb35Rx(hw); 222 231 return; 223 232 224 233 error: 225 - pWb35Rx->RxOwner[ RxBufferId ] = 1; // Set the owner to hardware 234 + pWb35Rx->RxOwner[RxBufferId] = 1; /* Set the owner to hardware */ 226 235 atomic_dec(&pWb35Rx->RxFireCounter); 227 236 pWb35Rx->EP3vm_state = VM_STOP; 228 237 } 229 238 230 - // This function cannot reentrain 239 + /* This function cannot reentrain */ 231 240 static void Wb35Rx(struct ieee80211_hw *hw) 232 241 { 233 - struct wbsoft_priv *priv = hw->priv; 234 - struct hw_data * pHwData = &priv->sHwData; 235 - struct wb35_rx *pWb35Rx = &pHwData->Wb35Rx; 236 - u8 * pRxBufferAddress; 237 - struct urb *urb = pWb35Rx->RxUrb; 238 - int retv; 239 - u32 RxBufferId; 242 + struct wbsoft_priv *priv = hw->priv; 243 + struct hw_data *pHwData = &priv->sHwData; 244 + struct wb35_rx *pWb35Rx = &pHwData->Wb35Rx; 245 + u8 *pRxBufferAddress; 246 + struct urb *urb = pWb35Rx->RxUrb; 247 + int retv; 248 + u32 RxBufferId; 240 249 241 - // 242 - // Issuing URB 243 - // 250 + /* Issuing URB */ 244 251 if (pHwData->SurpriseRemove || pHwData->HwStop) 245 252 goto error; 246 253 247 254 if (pWb35Rx->rx_halt) 248 255 goto error; 249 256 250 - // Get RxBuffer's ID 257 + /* Get RxBuffer's ID */ 251 258 RxBufferId = pWb35Rx->RxBufferId; 252 259 if (!pWb35Rx->RxOwner[RxBufferId]) { 253 - // It's impossible to run here. 254 - #ifdef _PE_RX_DUMP_ 260 + /* It's impossible to run here. */ 261 + #ifdef _PE_RX_DUMP_ 255 262 printk("Rx driver fifo unavailable\n"); 256 - #endif 263 + #endif 257 264 goto error; 258 265 } 259 266 260 - // Update buffer point, then start to bulkin the data from USB 267 + /* Update buffer point, then start to bulkin the data from USB */ 261 268 pWb35Rx->RxBufferId++; 262 269 pWb35Rx->RxBufferId %= MAX_USB_RX_BUFFER_NUMBER; 263 270 ··· 284 295 return; 285 296 286 297 error: 287 - // VM stop 298 + /* VM stop */ 288 299 pWb35Rx->EP3vm_state = VM_STOP; 289 300 atomic_dec(&pWb35Rx->RxFireCounter); 290 301 } 291 302 292 303 void Wb35Rx_start(struct ieee80211_hw *hw) 293 304 { 294 - struct wbsoft_priv *priv = hw->priv; 295 - struct hw_data * pHwData = &priv->sHwData; 296 - struct wb35_rx *pWb35Rx = &pHwData->Wb35Rx; 305 + struct wbsoft_priv *priv = hw->priv; 306 + struct hw_data *pHwData = &priv->sHwData; 307 + struct wb35_rx *pWb35Rx = &pHwData->Wb35Rx; 297 308 298 - // Allow only one thread to run into the Wb35Rx() function 309 + /* Allow only one thread to run into the Wb35Rx() function */ 299 310 if (atomic_inc_return(&pWb35Rx->RxFireCounter) == 1) { 300 311 pWb35Rx->EP3vm_state = VM_RUNNING; 301 312 Wb35Rx(hw); ··· 303 314 atomic_dec(&pWb35Rx->RxFireCounter); 304 315 } 305 316 306 - //===================================================================================== 307 - static void Wb35Rx_reset_descriptor( struct hw_data * pHwData ) 317 + static void Wb35Rx_reset_descriptor(struct hw_data *pHwData) 308 318 { 309 - struct wb35_rx *pWb35Rx = &pHwData->Wb35Rx; 310 - u32 i; 319 + struct wb35_rx *pWb35Rx = &pHwData->Wb35Rx; 320 + u32 i; 311 321 312 322 pWb35Rx->ByteReceived = 0; 313 323 pWb35Rx->RxProcessIndex = 0; ··· 314 326 pWb35Rx->EP3vm_state = VM_STOP; 315 327 pWb35Rx->rx_halt = 0; 316 328 317 - // Initial the Queue. The last buffer is reserved for used if the Rx resource is unavailable. 318 - for( i=0; i<MAX_USB_RX_BUFFER_NUMBER; i++ ) 329 + /* Initial the Queue. The last buffer is reserved for used if the Rx resource is unavailable. */ 330 + for (i = 0; i < MAX_USB_RX_BUFFER_NUMBER; i++) 319 331 pWb35Rx->RxOwner[i] = 1; 320 332 } 321 333 322 - unsigned char Wb35Rx_initial(struct hw_data * pHwData) 334 + unsigned char Wb35Rx_initial(struct hw_data *pHwData) 323 335 { 324 336 struct wb35_rx *pWb35Rx = &pHwData->Wb35Rx; 325 337 326 - // Initial the Buffer Queue 327 - Wb35Rx_reset_descriptor( pHwData ); 338 + /* Initial the Buffer Queue */ 339 + Wb35Rx_reset_descriptor(pHwData); 328 340 329 341 pWb35Rx->RxUrb = usb_alloc_urb(0, GFP_ATOMIC); 330 - return (!!pWb35Rx->RxUrb); 342 + return !!pWb35Rx->RxUrb; 331 343 } 332 344 333 - void Wb35Rx_stop(struct hw_data * pHwData) 345 + void Wb35Rx_stop(struct hw_data *pHwData) 334 346 { 335 347 struct wb35_rx *pWb35Rx = &pHwData->Wb35Rx; 336 348 337 - // Canceling the Irp if already sends it out. 349 + /* Canceling the Irp if already sends it out. */ 338 350 if (pWb35Rx->EP3vm_state == VM_RUNNING) { 339 - usb_unlink_urb( pWb35Rx->RxUrb ); // Only use unlink, let Wb35Rx_destroy to free them 340 - #ifdef _PE_RX_DUMP_ 351 + usb_unlink_urb(pWb35Rx->RxUrb); /* Only use unlink, let Wb35Rx_destroy to free them */ 352 + #ifdef _PE_RX_DUMP_ 341 353 printk("EP3 Rx stop\n"); 342 - #endif 354 + #endif 343 355 } 344 356 } 345 357 346 - // Needs process context 347 - void Wb35Rx_destroy(struct hw_data * pHwData) 358 + /* Needs process context */ 359 + void Wb35Rx_destroy(struct hw_data *pHwData) 348 360 { 349 361 struct wb35_rx *pWb35Rx = &pHwData->Wb35Rx; 350 362 351 363 do { 352 - msleep(10); // Delay for waiting function enter 940623.1.a 364 + msleep(10); /* Delay for waiting function enter */ 353 365 } while (pWb35Rx->EP3vm_state != VM_STOP); 354 - msleep(10); // Delay for waiting function exit 940623.1.b 366 + msleep(10); /* Delay for waiting function exit */ 355 367 356 368 if (pWb35Rx->RxUrb) 357 - usb_free_urb( pWb35Rx->RxUrb ); 358 - #ifdef _PE_RX_DUMP_ 369 + usb_free_urb(pWb35Rx->RxUrb); 370 + #ifdef _PE_RX_DUMP_ 359 371 printk("Wb35Rx_destroy OK\n"); 360 - #endif 372 + #endif 361 373 } 362 374