USB: fix codingstyle issues in drivers/usb/core/message.c

Fixes a number of coding style issues in the message.c file.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

+199 -189
+199 -189
drivers/usb/core/message.c
··· 39 39 * own interruptible routines. 40 40 */ 41 41 static int usb_start_wait_urb(struct urb *urb, int timeout, int *actual_length) 42 - { 42 + { 43 43 struct api_context ctx; 44 44 unsigned long expire; 45 45 int retval; ··· 74 74 } 75 75 76 76 /*-------------------------------------------------------------------*/ 77 - // returns status (negative) or length (positive) 77 + /* returns status (negative) or length (positive) */ 78 78 static int usb_internal_control_msg(struct usb_device *usb_dev, 79 - unsigned int pipe, 79 + unsigned int pipe, 80 80 struct usb_ctrlrequest *cmd, 81 81 void *data, int len, int timeout) 82 82 { ··· 87 87 urb = usb_alloc_urb(0, GFP_NOIO); 88 88 if (!urb) 89 89 return -ENOMEM; 90 - 90 + 91 91 usb_fill_control_urb(urb, usb_dev, pipe, (unsigned char *)cmd, data, 92 92 len, usb_api_blocking_completion, NULL); 93 93 ··· 99 99 } 100 100 101 101 /** 102 - * usb_control_msg - Builds a control urb, sends it off and waits for completion 103 - * @dev: pointer to the usb device to send the message to 104 - * @pipe: endpoint "pipe" to send the message to 105 - * @request: USB message request value 106 - * @requesttype: USB message request type value 107 - * @value: USB message value 108 - * @index: USB message index value 109 - * @data: pointer to the data to send 110 - * @size: length in bytes of the data to send 111 - * @timeout: time in msecs to wait for the message to complete before 112 - * timing out (if 0 the wait is forever) 113 - * Context: !in_interrupt () 102 + * usb_control_msg - Builds a control urb, sends it off and waits for completion 103 + * @dev: pointer to the usb device to send the message to 104 + * @pipe: endpoint "pipe" to send the message to 105 + * @request: USB message request value 106 + * @requesttype: USB message request type value 107 + * @value: USB message value 108 + * @index: USB message index value 109 + * @data: pointer to the data to send 110 + * @size: length in bytes of the data to send 111 + * @timeout: time in msecs to wait for the message to complete before timing 112 + * out (if 0 the wait is forever) 114 113 * 115 - * This function sends a simple control message to a specified endpoint 116 - * and waits for the message to complete, or timeout. 117 - * 118 - * If successful, it returns the number of bytes transferred, otherwise a negative error number. 114 + * Context: !in_interrupt () 119 115 * 120 - * Don't use this function from within an interrupt context, like a 121 - * bottom half handler. If you need an asynchronous message, or need to send 122 - * a message from within interrupt context, use usb_submit_urb() 123 - * If a thread in your driver uses this call, make sure your disconnect() 124 - * method can wait for it to complete. Since you don't have a handle on 125 - * the URB used, you can't cancel the request. 116 + * This function sends a simple control message to a specified endpoint and 117 + * waits for the message to complete, or timeout. 118 + * 119 + * If successful, it returns the number of bytes transferred, otherwise a 120 + * negative error number. 121 + * 122 + * Don't use this function from within an interrupt context, like a bottom half 123 + * handler. If you need an asynchronous message, or need to send a message 124 + * from within interrupt context, use usb_submit_urb(). 125 + * If a thread in your driver uses this call, make sure your disconnect() 126 + * method can wait for it to complete. Since you don't have a handle on the 127 + * URB used, you can't cancel the request. 126 128 */ 127 - int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request, __u8 requesttype, 128 - __u16 value, __u16 index, void *data, __u16 size, int timeout) 129 + int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request, 130 + __u8 requesttype, __u16 value, __u16 index, void *data, 131 + __u16 size, int timeout) 129 132 { 130 - struct usb_ctrlrequest *dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_NOIO); 133 + struct usb_ctrlrequest *dr; 131 134 int ret; 132 - 135 + 136 + dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_NOIO); 133 137 if (!dr) 134 138 return -ENOMEM; 135 139 136 - dr->bRequestType= requesttype; 140 + dr->bRequestType = requesttype; 137 141 dr->bRequest = request; 138 142 dr->wValue = cpu_to_le16p(&value); 139 143 dr->wIndex = cpu_to_le16p(&index); 140 144 dr->wLength = cpu_to_le16p(&size); 141 145 142 - //dbg("usb_control_msg"); 146 + /* dbg("usb_control_msg"); */ 143 147 144 148 ret = usb_internal_control_msg(dev, pipe, dr, data, size, timeout); 145 149 ··· 159 155 * @pipe: endpoint "pipe" to send the message to 160 156 * @data: pointer to the data to send 161 157 * @len: length in bytes of the data to send 162 - * @actual_length: pointer to a location to put the actual length transferred in bytes 158 + * @actual_length: pointer to a location to put the actual length transferred 159 + * in bytes 163 160 * @timeout: time in msecs to wait for the message to complete before 164 161 * timing out (if 0 the wait is forever) 162 + * 165 163 * Context: !in_interrupt () 166 164 * 167 165 * This function sends a simple interrupt message to a specified endpoint and ··· 187 181 EXPORT_SYMBOL_GPL(usb_interrupt_msg); 188 182 189 183 /** 190 - * usb_bulk_msg - Builds a bulk urb, sends it off and waits for completion 191 - * @usb_dev: pointer to the usb device to send the message to 192 - * @pipe: endpoint "pipe" to send the message to 193 - * @data: pointer to the data to send 194 - * @len: length in bytes of the data to send 195 - * @actual_length: pointer to a location to put the actual length transferred in bytes 196 - * @timeout: time in msecs to wait for the message to complete before 197 - * timing out (if 0 the wait is forever) 198 - * Context: !in_interrupt () 184 + * usb_bulk_msg - Builds a bulk urb, sends it off and waits for completion 185 + * @usb_dev: pointer to the usb device to send the message to 186 + * @pipe: endpoint "pipe" to send the message to 187 + * @data: pointer to the data to send 188 + * @len: length in bytes of the data to send 189 + * @actual_length: pointer to a location to put the actual length transferred 190 + * in bytes 191 + * @timeout: time in msecs to wait for the message to complete before 192 + * timing out (if 0 the wait is forever) 199 193 * 200 - * This function sends a simple bulk message to a specified endpoint 201 - * and waits for the message to complete, or timeout. 202 - * 203 - * If successful, it returns 0, otherwise a negative error number. 204 - * The number of actual bytes transferred will be stored in the 205 - * actual_length paramater. 194 + * Context: !in_interrupt () 206 195 * 207 - * Don't use this function from within an interrupt context, like a 208 - * bottom half handler. If you need an asynchronous message, or need to 209 - * send a message from within interrupt context, use usb_submit_urb() 210 - * If a thread in your driver uses this call, make sure your disconnect() 211 - * method can wait for it to complete. Since you don't have a handle on 212 - * the URB used, you can't cancel the request. 196 + * This function sends a simple bulk message to a specified endpoint 197 + * and waits for the message to complete, or timeout. 213 198 * 214 - * Because there is no usb_interrupt_msg() and no USBDEVFS_INTERRUPT 215 - * ioctl, users are forced to abuse this routine by using it to submit 216 - * URBs for interrupt endpoints. We will take the liberty of creating 217 - * an interrupt URB (with the default interval) if the target is an 218 - * interrupt endpoint. 199 + * If successful, it returns 0, otherwise a negative error number. The number 200 + * of actual bytes transferred will be stored in the actual_length paramater. 201 + * 202 + * Don't use this function from within an interrupt context, like a bottom half 203 + * handler. If you need an asynchronous message, or need to send a message 204 + * from within interrupt context, use usb_submit_urb() If a thread in your 205 + * driver uses this call, make sure your disconnect() method can wait for it to 206 + * complete. Since you don't have a handle on the URB used, you can't cancel 207 + * the request. 208 + * 209 + * Because there is no usb_interrupt_msg() and no USBDEVFS_INTERRUPT ioctl, 210 + * users are forced to abuse this routine by using it to submit URBs for 211 + * interrupt endpoints. We will take the liberty of creating an interrupt URB 212 + * (with the default interval) if the target is an interrupt endpoint. 219 213 */ 220 - int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe, 221 - void *data, int len, int *actual_length, int timeout) 214 + int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe, 215 + void *data, int len, int *actual_length, int timeout) 222 216 { 223 217 struct urb *urb; 224 218 struct usb_host_endpoint *ep; ··· 248 242 249 243 /*-------------------------------------------------------------------*/ 250 244 251 - static void sg_clean (struct usb_sg_request *io) 245 + static void sg_clean(struct usb_sg_request *io) 252 246 { 253 247 if (io->urbs) { 254 248 while (io->entries--) 255 - usb_free_urb (io->urbs [io->entries]); 256 - kfree (io->urbs); 249 + usb_free_urb(io->urbs [io->entries]); 250 + kfree(io->urbs); 257 251 io->urbs = NULL; 258 252 } 259 253 if (io->dev->dev.dma_mask != NULL) 260 - usb_buffer_unmap_sg (io->dev, usb_pipein(io->pipe), 261 - io->sg, io->nents); 254 + usb_buffer_unmap_sg(io->dev, usb_pipein(io->pipe), 255 + io->sg, io->nents); 262 256 io->dev = NULL; 263 257 } 264 258 265 - static void sg_complete (struct urb *urb) 259 + static void sg_complete(struct urb *urb) 266 260 { 267 - struct usb_sg_request *io = urb->context; 261 + struct usb_sg_request *io = urb->context; 268 262 int status = urb->status; 269 263 270 - spin_lock (&io->lock); 264 + spin_lock(&io->lock); 271 265 272 266 /* In 2.5 we require hcds' endpoint queues not to progress after fault 273 267 * reports, until the completion callback (this!) returns. That lets ··· 283 277 && (io->status != -ECONNRESET 284 278 || status != -ECONNRESET) 285 279 && urb->actual_length) { 286 - dev_err (io->dev->bus->controller, 280 + dev_err(io->dev->bus->controller, 287 281 "dev %s ep%d%s scatterlist error %d/%d\n", 288 282 io->dev->devpath, 289 283 usb_endpoint_num(&urb->ep->desc), 290 284 usb_urb_dir_in(urb) ? "in" : "out", 291 285 status, io->status); 292 - // BUG (); 286 + /* BUG (); */ 293 287 } 294 288 295 289 if (io->status == 0 && status && status != -ECONNRESET) { ··· 301 295 * unlink pending urbs so they won't rx/tx bad data. 302 296 * careful: unlink can sometimes be synchronous... 303 297 */ 304 - spin_unlock (&io->lock); 298 + spin_unlock(&io->lock); 305 299 for (i = 0, found = 0; i < io->entries; i++) { 306 300 if (!io->urbs [i] || !io->urbs [i]->dev) 307 301 continue; 308 302 if (found) { 309 - retval = usb_unlink_urb (io->urbs [i]); 303 + retval = usb_unlink_urb(io->urbs [i]); 310 304 if (retval != -EINPROGRESS && 311 305 retval != -ENODEV && 312 306 retval != -EBUSY) 313 - dev_err (&io->dev->dev, 307 + dev_err(&io->dev->dev, 314 308 "%s, unlink --> %d\n", 315 309 __FUNCTION__, retval); 316 310 } else if (urb == io->urbs [i]) 317 311 found = 1; 318 312 } 319 - spin_lock (&io->lock); 313 + spin_lock(&io->lock); 320 314 } 321 315 urb->dev = NULL; 322 316 ··· 324 318 io->bytes += urb->actual_length; 325 319 io->count--; 326 320 if (!io->count) 327 - complete (&io->complete); 321 + complete(&io->complete); 328 322 329 - spin_unlock (&io->lock); 323 + spin_unlock(&io->lock); 330 324 } 331 325 332 326 ··· 355 349 * The request may be canceled with usb_sg_cancel(), either before or after 356 350 * usb_sg_wait() is called. 357 351 */ 358 - int usb_sg_init ( 359 - struct usb_sg_request *io, 360 - struct usb_device *dev, 361 - unsigned pipe, 362 - unsigned period, 363 - struct scatterlist *sg, 364 - int nents, 365 - size_t length, 366 - gfp_t mem_flags 367 - ) 352 + int usb_sg_init(struct usb_sg_request *io, struct usb_device *dev, 353 + unsigned pipe, unsigned period, struct scatterlist *sg, 354 + int nents, size_t length, gfp_t mem_flags) 368 355 { 369 - int i; 370 - int urb_flags; 371 - int dma; 356 + int i; 357 + int urb_flags; 358 + int dma; 372 359 373 360 if (!io || !dev || !sg 374 - || usb_pipecontrol (pipe) 375 - || usb_pipeisoc (pipe) 361 + || usb_pipecontrol(pipe) 362 + || usb_pipeisoc(pipe) 376 363 || nents <= 0) 377 364 return -EINVAL; 378 365 379 - spin_lock_init (&io->lock); 366 + spin_lock_init(&io->lock); 380 367 io->dev = dev; 381 368 io->pipe = pipe; 382 369 io->sg = sg; ··· 381 382 dma = (dev->dev.dma_mask != NULL); 382 383 if (dma) 383 384 io->entries = usb_buffer_map_sg(dev, usb_pipein(pipe), 384 - sg, nents); 385 + sg, nents); 385 386 else 386 387 io->entries = nents; 387 388 ··· 390 391 return io->entries; 391 392 392 393 io->count = io->entries; 393 - io->urbs = kmalloc (io->entries * sizeof *io->urbs, mem_flags); 394 + io->urbs = kmalloc(io->entries * sizeof *io->urbs, mem_flags); 394 395 if (!io->urbs) 395 396 goto nomem; 396 397 397 398 urb_flags = URB_NO_TRANSFER_DMA_MAP | URB_NO_INTERRUPT; 398 - if (usb_pipein (pipe)) 399 + if (usb_pipein(pipe)) 399 400 urb_flags |= URB_SHORT_NOT_OK; 400 401 401 402 for (i = 0; i < io->entries; i++) { 402 - unsigned len; 403 + unsigned len; 403 404 404 - io->urbs [i] = usb_alloc_urb (0, mem_flags); 405 - if (!io->urbs [i]) { 405 + io->urbs[i] = usb_alloc_urb(0, mem_flags); 406 + if (!io->urbs[i]) { 406 407 io->entries = i; 407 408 goto nomem; 408 409 } 409 410 410 - io->urbs [i]->dev = NULL; 411 - io->urbs [i]->pipe = pipe; 412 - io->urbs [i]->interval = period; 413 - io->urbs [i]->transfer_flags = urb_flags; 411 + io->urbs[i]->dev = NULL; 412 + io->urbs[i]->pipe = pipe; 413 + io->urbs[i]->interval = period; 414 + io->urbs[i]->transfer_flags = urb_flags; 414 415 415 - io->urbs [i]->complete = sg_complete; 416 - io->urbs [i]->context = io; 416 + io->urbs[i]->complete = sg_complete; 417 + io->urbs[i]->context = io; 417 418 418 419 /* 419 420 * Some systems need to revert to PIO when DMA is temporarily ··· 432 433 * to prevent stale pointers and to help spot bugs. 433 434 */ 434 435 if (dma) { 435 - io->urbs [i]->transfer_dma = sg_dma_address (sg + i); 436 - len = sg_dma_len (sg + i); 436 + io->urbs[i]->transfer_dma = sg_dma_address(sg + i); 437 + len = sg_dma_len(sg + i); 437 438 #if defined(CONFIG_HIGHMEM) || defined(CONFIG_GART_IOMMU) 438 439 io->urbs[i]->transfer_buffer = NULL; 439 440 #else ··· 441 442 #endif 442 443 } else { 443 444 /* hc may use _only_ transfer_buffer */ 444 - io->urbs [i]->transfer_buffer = sg_virt(&sg[i]); 445 - len = sg [i].length; 445 + io->urbs[i]->transfer_buffer = sg_virt(&sg[i]); 446 + len = sg[i].length; 446 447 } 447 448 448 449 if (length) { 449 - len = min_t (unsigned, len, length); 450 + len = min_t(unsigned, len, length); 450 451 length -= len; 451 452 if (length == 0) 452 453 io->entries = i + 1; 453 454 } 454 - io->urbs [i]->transfer_buffer_length = len; 455 + io->urbs[i]->transfer_buffer_length = len; 455 456 } 456 - io->urbs [--i]->transfer_flags &= ~URB_NO_INTERRUPT; 457 + io->urbs[--i]->transfer_flags &= ~URB_NO_INTERRUPT; 457 458 458 459 /* transaction state */ 459 460 io->status = 0; 460 461 io->bytes = 0; 461 - init_completion (&io->complete); 462 + init_completion(&io->complete); 462 463 return 0; 463 464 464 465 nomem: 465 - sg_clean (io); 466 + sg_clean(io); 466 467 return -ENOMEM; 467 468 } 468 469 EXPORT_SYMBOL_GPL(usb_sg_init); ··· 506 507 * speed interrupt endpoints, which allow at most one packet per millisecond, 507 508 * of at most 8 or 64 bytes (respectively). 508 509 */ 509 - void usb_sg_wait (struct usb_sg_request *io) 510 + void usb_sg_wait(struct usb_sg_request *io) 510 511 { 511 - int i, entries = io->entries; 512 + int i; 513 + int entries = io->entries; 512 514 513 515 /* queue the urbs. */ 514 - spin_lock_irq (&io->lock); 516 + spin_lock_irq(&io->lock); 515 517 i = 0; 516 518 while (i < entries && !io->status) { 517 - int retval; 519 + int retval; 518 520 519 - io->urbs [i]->dev = io->dev; 520 - retval = usb_submit_urb (io->urbs [i], GFP_ATOMIC); 521 + io->urbs[i]->dev = io->dev; 522 + retval = usb_submit_urb(io->urbs [i], GFP_ATOMIC); 521 523 522 524 /* after we submit, let completions or cancelations fire; 523 525 * we handshake using io->status. 524 526 */ 525 - spin_unlock_irq (&io->lock); 527 + spin_unlock_irq(&io->lock); 526 528 switch (retval) { 527 529 /* maybe we retrying will recover */ 528 - case -ENXIO: // hc didn't queue this one 530 + case -ENXIO: /* hc didn't queue this one */ 529 531 case -EAGAIN: 530 532 case -ENOMEM: 531 533 io->urbs[i]->dev = NULL; 532 534 retval = 0; 533 - yield (); 535 + yield(); 534 536 break; 535 537 536 538 /* no error? continue immediately. ··· 542 542 */ 543 543 case 0: 544 544 ++i; 545 - cpu_relax (); 545 + cpu_relax(); 546 546 break; 547 547 548 548 /* fail any uncompleted urbs */ 549 549 default: 550 - io->urbs [i]->dev = NULL; 551 - io->urbs [i]->status = retval; 552 - dev_dbg (&io->dev->dev, "%s, submit --> %d\n", 550 + io->urbs[i]->dev = NULL; 551 + io->urbs[i]->status = retval; 552 + dev_dbg(&io->dev->dev, "%s, submit --> %d\n", 553 553 __FUNCTION__, retval); 554 - usb_sg_cancel (io); 554 + usb_sg_cancel(io); 555 555 } 556 - spin_lock_irq (&io->lock); 556 + spin_lock_irq(&io->lock); 557 557 if (retval && (io->status == 0 || io->status == -ECONNRESET)) 558 558 io->status = retval; 559 559 } 560 560 io->count -= entries - i; 561 561 if (io->count == 0) 562 - complete (&io->complete); 563 - spin_unlock_irq (&io->lock); 562 + complete(&io->complete); 563 + spin_unlock_irq(&io->lock); 564 564 565 565 /* OK, yes, this could be packaged as non-blocking. 566 566 * So could the submit loop above ... but it's easier to 567 567 * solve neither problem than to solve both! 568 568 */ 569 - wait_for_completion (&io->complete); 569 + wait_for_completion(&io->complete); 570 570 571 - sg_clean (io); 571 + sg_clean(io); 572 572 } 573 573 EXPORT_SYMBOL_GPL(usb_sg_wait); 574 574 ··· 580 580 * It can also prevents one initialized by usb_sg_init() from starting, 581 581 * so that call just frees resources allocated to the request. 582 582 */ 583 - void usb_sg_cancel (struct usb_sg_request *io) 583 + void usb_sg_cancel(struct usb_sg_request *io) 584 584 { 585 - unsigned long flags; 585 + unsigned long flags; 586 586 587 - spin_lock_irqsave (&io->lock, flags); 587 + spin_lock_irqsave(&io->lock, flags); 588 588 589 589 /* shut everything down, if it didn't already */ 590 590 if (!io->status) { 591 - int i; 591 + int i; 592 592 593 593 io->status = -ECONNRESET; 594 - spin_unlock (&io->lock); 594 + spin_unlock(&io->lock); 595 595 for (i = 0; i < io->entries; i++) { 596 - int retval; 596 + int retval; 597 597 598 598 if (!io->urbs [i]->dev) 599 599 continue; 600 - retval = usb_unlink_urb (io->urbs [i]); 600 + retval = usb_unlink_urb(io->urbs [i]); 601 601 if (retval != -EINPROGRESS && retval != -EBUSY) 602 - dev_warn (&io->dev->dev, "%s, unlink --> %d\n", 602 + dev_warn(&io->dev->dev, "%s, unlink --> %d\n", 603 603 __FUNCTION__, retval); 604 604 } 605 - spin_lock (&io->lock); 605 + spin_lock(&io->lock); 606 606 } 607 - spin_unlock_irqrestore (&io->lock, flags); 607 + spin_unlock_irqrestore(&io->lock, flags); 608 608 } 609 609 EXPORT_SYMBOL_GPL(usb_sg_cancel); 610 610 ··· 632 632 * Returns the number of bytes received on success, or else the status code 633 633 * returned by the underlying usb_control_msg() call. 634 634 */ 635 - int usb_get_descriptor(struct usb_device *dev, unsigned char type, unsigned char index, void *buf, int size) 635 + int usb_get_descriptor(struct usb_device *dev, unsigned char type, 636 + unsigned char index, void *buf, int size) 636 637 { 637 638 int i; 638 639 int result; 639 - 640 - memset(buf,0,size); // Make sure we parse really received data 640 + 641 + memset(buf, 0, size); /* Make sure we parse really received data */ 641 642 642 643 for (i = 0; i < 3; ++i) { 643 644 /* retry on length 0 or error; some devices are flakey */ ··· 713 712 } 714 713 715 714 static int usb_string_sub(struct usb_device *dev, unsigned int langid, 716 - unsigned int index, unsigned char *buf) 715 + unsigned int index, unsigned char *buf) 717 716 { 718 717 int rc; 719 718 ··· 756 755 * @buf: where to put the string 757 756 * @size: how big is "buf"? 758 757 * Context: !in_interrupt () 759 - * 758 + * 760 759 * This converts the UTF-16LE encoded strings returned by devices, from 761 760 * usb_get_string_descriptor(), to null-terminated ISO-8859-1 encoded ones 762 761 * that are more usable in most kernel contexts. Note that all characters ··· 792 791 if (!dev->have_langid) { 793 792 err = usb_string_sub(dev, 0, 0, tbuf); 794 793 if (err < 0) { 795 - dev_err (&dev->dev, 794 + dev_err(&dev->dev, 796 795 "string descriptor 0 read error: %d\n", 797 796 err); 798 797 goto errout; 799 798 } else if (err < 4) { 800 - dev_err (&dev->dev, "string descriptor 0 too short\n"); 799 + dev_err(&dev->dev, "string descriptor 0 too short\n"); 801 800 err = -EINVAL; 802 801 goto errout; 803 802 } else { 804 803 dev->have_langid = 1; 805 - dev->string_langid = tbuf[2] | (tbuf[3]<< 8); 806 - /* always use the first langid listed */ 807 - dev_dbg (&dev->dev, "default language 0x%04x\n", 804 + dev->string_langid = tbuf[2] | (tbuf[3] << 8); 805 + /* always use the first langid listed */ 806 + dev_dbg(&dev->dev, "default language 0x%04x\n", 808 807 dev->string_langid); 809 808 } 810 809 } 811 - 810 + 812 811 err = usb_string_sub(dev, dev->string_langid, index, tbuf); 813 812 if (err < 0) 814 813 goto errout; ··· 826 825 err = idx; 827 826 828 827 if (tbuf[1] != USB_DT_STRING) 829 - dev_dbg(&dev->dev, "wrong descriptor type %02x for string %d (\"%s\")\n", tbuf[1], index, buf); 828 + dev_dbg(&dev->dev, 829 + "wrong descriptor type %02x for string %d (\"%s\")\n", 830 + tbuf[1], index, buf); 830 831 831 832 errout: 832 833 kfree(tbuf); ··· 850 847 char *smallbuf = NULL; 851 848 int len; 852 849 853 - if (index > 0 && (buf = kmalloc(256, GFP_KERNEL)) != NULL) { 854 - if ((len = usb_string(udev, index, buf, 256)) > 0) { 855 - if ((smallbuf = kmalloc(++len, GFP_KERNEL)) == NULL) 850 + if (index <= 0) 851 + return NULL; 852 + 853 + buf = kmalloc(256, GFP_KERNEL); 854 + if (buf) { 855 + len = usb_string(udev, index, buf, 256); 856 + if (len > 0) { 857 + smallbuf = kmalloc(++len, GFP_KERNEL); 858 + if (!smallbuf) 856 859 return buf; 857 860 memcpy(smallbuf, buf, len); 858 861 } ··· 897 888 return -ENOMEM; 898 889 899 890 ret = usb_get_descriptor(dev, USB_DT_DEVICE, 0, desc, size); 900 - if (ret >= 0) 891 + if (ret >= 0) 901 892 memcpy(&dev->descriptor, desc, size); 902 893 kfree(desc); 903 894 return ret; ··· 970 961 { 971 962 int result; 972 963 int endp = usb_pipeendpoint(pipe); 973 - 974 - if (usb_pipein (pipe)) 964 + 965 + if (usb_pipein(pipe)) 975 966 endp |= USB_DIR_IN; 976 967 977 968 /* we don't care if it wasn't halted first. in fact some devices ··· 1054 1045 } 1055 1046 } 1056 1047 1057 - /* 1048 + /** 1058 1049 * usb_disable_device - Disable all the endpoints for a USB device 1059 1050 * @dev: the device whose endpoints are being disabled 1060 1051 * @skip_ep0: 0 to disable endpoint 0, 1 to skip it. ··· 1069 1060 int i; 1070 1061 1071 1062 dev_dbg(&dev->dev, "%s nuking %s URBs\n", __FUNCTION__, 1072 - skip_ep0 ? "non-ep0" : "all"); 1063 + skip_ep0 ? "non-ep0" : "all"); 1073 1064 for (i = skip_ep0; i < 16; ++i) { 1074 1065 usb_disable_endpoint(dev, i); 1075 1066 usb_disable_endpoint(dev, i + USB_DIR_IN); ··· 1087 1078 interface = dev->actconfig->interface[i]; 1088 1079 if (!device_is_registered(&interface->dev)) 1089 1080 continue; 1090 - dev_dbg (&dev->dev, "unregistering interface %s\n", 1081 + dev_dbg(&dev->dev, "unregistering interface %s\n", 1091 1082 interface->dev.bus_id); 1092 1083 usb_remove_sysfs_intf_files(interface); 1093 - device_del (&interface->dev); 1084 + device_del(&interface->dev); 1094 1085 } 1095 1086 1096 1087 /* Now that the interfaces are unbound, nobody should 1097 1088 * try to access them. 1098 1089 */ 1099 1090 for (i = 0; i < dev->actconfig->desc.bNumInterfaces; i++) { 1100 - put_device (&dev->actconfig->interface[i]->dev); 1091 + put_device(&dev->actconfig->interface[i]->dev); 1101 1092 dev->actconfig->interface[i] = NULL; 1102 1093 } 1103 1094 dev->actconfig = NULL; ··· 1106 1097 } 1107 1098 } 1108 1099 1109 - 1110 - /* 1100 + /** 1111 1101 * usb_enable_endpoint - Enable an endpoint for USB communications 1112 1102 * @dev: the device whose interface is being enabled 1113 1103 * @ep: the endpoint ··· 1131 1123 ep->enabled = 1; 1132 1124 } 1133 1125 1134 - /* 1126 + /** 1135 1127 * usb_enable_interface - Enable all the endpoints for an interface 1136 1128 * @dev: the device whose interface is being enabled 1137 1129 * @intf: pointer to the interface descriptor ··· 1187 1179 struct usb_host_interface *alt; 1188 1180 int ret; 1189 1181 int manual = 0; 1182 + unsigned int epaddr; 1183 + unsigned int pipe; 1190 1184 1191 1185 if (dev->state == USB_STATE_SUSPENDED) 1192 1186 return -EHOSTUNREACH; ··· 1243 1233 int i; 1244 1234 1245 1235 for (i = 0; i < alt->desc.bNumEndpoints; i++) { 1246 - unsigned int epaddr = 1247 - alt->endpoint[i].desc.bEndpointAddress; 1248 - unsigned int pipe = 1249 - __create_pipe(dev, USB_ENDPOINT_NUMBER_MASK & epaddr) 1250 - | (usb_endpoint_out(epaddr) ? USB_DIR_OUT : USB_DIR_IN); 1236 + epaddr = alt->endpoint[i].desc.bEndpointAddress; 1237 + pipe = __create_pipe(dev, 1238 + USB_ENDPOINT_NUMBER_MASK & epaddr) | 1239 + (usb_endpoint_out(epaddr) ? 1240 + USB_DIR_OUT : USB_DIR_IN); 1251 1241 1252 1242 usb_clear_halt(dev, pipe); 1253 1243 } ··· 1376 1366 return -ENOMEM; 1377 1367 1378 1368 if (add_uevent_var(env, 1379 - "MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X", 1369 + "MODALIAS=usb:" 1370 + "v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X", 1380 1371 le16_to_cpu(usb_dev->descriptor.idVendor), 1381 1372 le16_to_cpu(usb_dev->descriptor.idProduct), 1382 1373 le16_to_cpu(usb_dev->descriptor.bcdDevice), ··· 1407 1396 }; 1408 1397 1409 1398 static struct usb_interface_assoc_descriptor *find_iad(struct usb_device *dev, 1410 - struct usb_host_config *config, 1411 - u8 inum) 1399 + struct usb_host_config *config, 1400 + u8 inum) 1412 1401 { 1413 1402 struct usb_interface_assoc_descriptor *retval = NULL; 1414 1403 struct usb_interface_assoc_descriptor *intf_assoc; ··· 1434 1423 1435 1424 return retval; 1436 1425 } 1437 - 1438 1426 1439 1427 /* 1440 1428 * usb_set_configuration - Makes a particular device setting be current ··· 1552 1542 * getting rid of old interfaces means unbinding their drivers. 1553 1543 */ 1554 1544 if (dev->state != USB_STATE_ADDRESS) 1555 - usb_disable_device (dev, 1); // Skip ep0 1545 + usb_disable_device(dev, 1); /* Skip ep0 */ 1556 1546 1557 - if ((ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 1558 - USB_REQ_SET_CONFIGURATION, 0, configuration, 0, 1559 - NULL, 0, USB_CTRL_SET_TIMEOUT)) < 0) { 1560 - 1547 + ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 1548 + USB_REQ_SET_CONFIGURATION, 0, configuration, 0, 1549 + NULL, 0, USB_CTRL_SET_TIMEOUT); 1550 + if (ret < 0) { 1561 1551 /* All the old state is gone, so what else can we do? 1562 1552 * The device is probably useless now anyway. 1563 1553 */ ··· 1604 1594 intf->dev.bus = &usb_bus_type; 1605 1595 intf->dev.type = &usb_if_device_type; 1606 1596 intf->dev.dma_mask = dev->dev.dma_mask; 1607 - device_initialize (&intf->dev); 1597 + device_initialize(&intf->dev); 1608 1598 mark_quiesced(intf); 1609 - sprintf (&intf->dev.bus_id[0], "%d-%s:%d.%d", 1610 - dev->bus->busnum, dev->devpath, 1611 - configuration, alt->desc.bInterfaceNumber); 1599 + sprintf(&intf->dev.bus_id[0], "%d-%s:%d.%d", 1600 + dev->bus->busnum, dev->devpath, 1601 + configuration, alt->desc.bInterfaceNumber); 1612 1602 } 1613 1603 kfree(new_interfaces); 1614 1604 ··· 1624 1614 for (i = 0; i < nintf; ++i) { 1625 1615 struct usb_interface *intf = cp->interface[i]; 1626 1616 1627 - dev_dbg (&dev->dev, 1617 + dev_dbg(&dev->dev, 1628 1618 "adding %s (config #%d, interface %d)\n", 1629 1619 intf->dev.bus_id, configuration, 1630 1620 intf->cur_altsetting->desc.bInterfaceNumber); 1631 - ret = device_add (&intf->dev); 1621 + ret = device_add(&intf->dev); 1632 1622 if (ret != 0) { 1633 1623 dev_err(&dev->dev, "device_add(%s) --> %d\n", 1634 1624 intf->dev.bus_id, ret);