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

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

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

+82 -72
+82 -72
drivers/usb/core/devices.c
··· 89 static const char *format_bandwidth = 90 /* B: Alloc=ddd/ddd us (xx%), #Int=ddd, #Iso=ddd */ 91 "B: Alloc=%3d/%3d us (%2d%%), #Int=%3d, #Iso=%3d\n"; 92 - 93 static const char *format_device1 = 94 /* D: Ver=xx.xx Cls=xx(sssss) Sub=xx Prot=xx MxPS=dd #Cfgs=dd */ 95 "D: Ver=%2x.%02x Cls=%02x(%-5s) Sub=%02x Prot=%02x MxPS=%2d #Cfgs=%3d\n"; ··· 101 static const char *format_config = 102 /* C: #Ifs=dd Cfg#=dd Atr=xx MPwr=dddmA */ 103 "C:%c #Ifs=%2d Cfg#=%2d Atr=%02x MxPwr=%3dmA\n"; 104 - 105 static const char *format_iad = 106 /* A: FirstIf#=dd IfCount=dd Cls=xx(sssss) Sub=xx Prot=xx */ 107 "A: FirstIf#=%2d IfCount=%2d Cls=%02x(%-5s) Sub=%02x Prot=%02x\n"; ··· 122 */ 123 124 static DECLARE_WAIT_QUEUE_HEAD(deviceconndiscwq); 125 - static unsigned int conndiscevcnt = 0; 126 127 /* this struct stores the poll state for <mountpoint>/devices pollers */ 128 struct usb_device_status { ··· 172 return clas_info[ix].class_name; 173 } 174 175 - static char *usb_dump_endpoint_descriptor( 176 - int speed, 177 - char *start, 178 - char *end, 179 - const struct usb_endpoint_descriptor *desc 180 - ) 181 { 182 char dir, unit, *type; 183 unsigned interval, bandwidth = 1; ··· 231 232 start += sprintf(start, format_endpt, desc->bEndpointAddress, dir, 233 desc->bmAttributes, type, 234 - (le16_to_cpu(desc->wMaxPacketSize) & 0x07ff) * bandwidth, 235 interval, unit); 236 return start; 237 } 238 239 static char *usb_dump_interface_descriptor(char *start, char *end, 240 - const struct usb_interface_cache *intfc, 241 - const struct usb_interface *iface, 242 - int setno) 243 { 244 - const struct usb_interface_descriptor *desc = &intfc->altsetting[setno].desc; 245 const char *driver_name = ""; 246 int active = 0; 247 248 if (start > end) 249 return start; 250 if (iface) { 251 driver_name = (iface->dev.driver 252 ? iface->dev.driver->name ··· 268 return start; 269 } 270 271 - static char *usb_dump_interface( 272 - int speed, 273 - char *start, 274 - char *end, 275 - const struct usb_interface_cache *intfc, 276 - const struct usb_interface *iface, 277 - int setno 278 - ) { 279 const struct usb_host_interface *desc = &intfc->altsetting[setno]; 280 int i; 281 ··· 286 } 287 288 static char *usb_dump_iad_descriptor(char *start, char *end, 289 - const struct usb_interface_assoc_descriptor *iad) 290 { 291 if (start > end) 292 return start; ··· 305 * 1. marking active interface altsettings (code lists all, but should mark 306 * which ones are active, if any) 307 */ 308 - 309 - static char *usb_dump_config_descriptor(char *start, char *end, const struct usb_config_descriptor *desc, int active) 310 { 311 if (start > end) 312 return start; 313 start += sprintf(start, format_config, 314 - active ? '*' : ' ', /* mark active/actual/current cfg. */ 315 desc->bNumInterfaces, 316 desc->bConfigurationValue, 317 desc->bmAttributes, ··· 321 return start; 322 } 323 324 - static char *usb_dump_config ( 325 - int speed, 326 - char *start, 327 - char *end, 328 - const struct usb_host_config *config, 329 - int active 330 - ) 331 { 332 int i, j; 333 struct usb_interface_cache *intfc; ··· 330 331 if (start > end) 332 return start; 333 - if (!config) /* getting these some in 2.3.7; none in 2.3.6 */ 334 return start + sprintf(start, "(null Cfg. desc.)\n"); 335 start = usb_dump_config_descriptor(start, end, &config->desc, active); 336 for (i = 0; i < USB_MAXIADS; i++) { ··· 356 /* 357 * Dump the different USB descriptors. 358 */ 359 - static char *usb_dump_device_descriptor(char *start, char *end, const struct usb_device_descriptor *desc) 360 { 361 u16 bcdUSB = le16_to_cpu(desc->bcdUSB); 362 u16 bcdDevice = le16_to_cpu(desc->bcdDevice); ··· 367 start += sprintf(start, format_device1, 368 bcdUSB >> 8, bcdUSB & 0xff, 369 desc->bDeviceClass, 370 - class_decode (desc->bDeviceClass), 371 desc->bDeviceSubClass, 372 desc->bDeviceProtocol, 373 desc->bMaxPacketSize0, ··· 384 /* 385 * Dump the different strings that this device holds. 386 */ 387 - static char *usb_dump_device_strings(char *start, char *end, struct usb_device *dev) 388 { 389 if (start > end) 390 return start; 391 if (dev->manufacturer) 392 - start += sprintf(start, format_string_manufacturer, dev->manufacturer); 393 if (start > end) 394 goto out; 395 if (dev->product) ··· 400 goto out; 401 #ifdef ALLOW_SERIAL_NUMBER 402 if (dev->serial) 403 - start += sprintf(start, format_string_serialnumber, dev->serial); 404 #endif 405 out: 406 return start; ··· 413 414 if (start > end) 415 return start; 416 - 417 start = usb_dump_device_descriptor(start, end, &dev->descriptor); 418 419 if (start > end) 420 return start; 421 - 422 start = usb_dump_device_strings(start, end, dev); 423 424 for (i = 0; i < dev->descriptor.bNumConfigurations; i++) { ··· 435 436 #ifdef PROC_EXTRA /* TBD: may want to add this code later */ 437 438 - static char *usb_dump_hub_descriptor(char *start, char *end, const struct usb_hub_descriptor * desc) 439 { 440 int leng = USB_DT_HUB_NONVAR_SIZE; 441 unsigned char *ptr = (unsigned char *)desc; ··· 452 return start; 453 } 454 455 - static char *usb_dump_string(char *start, char *end, const struct usb_device *dev, char *id, int index) 456 { 457 if (start > end) 458 return start; 459 start += sprintf(start, "Interface:"); 460 - if (index <= dev->maxstring && dev->stringindex && dev->stringindex[index]) 461 - start += sprintf(start, "%s: %.100s ", id, dev->stringindex[index]); 462 return start; 463 } 464 ··· 476 * file_offset - the offset into the devices file on completion 477 * The caller must own the device lock. 478 */ 479 - static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes, loff_t *skip_bytes, loff_t *file_offset, 480 - struct usb_device *usbdev, struct usb_bus *bus, int level, int index, int count) 481 { 482 int chix; 483 int ret, cnt = 0; ··· 487 char *pages_start, *data_end, *speed; 488 unsigned int length; 489 ssize_t total_written = 0; 490 - 491 /* don't bother with anything else if we're not writing any data */ 492 if (*nbytes <= 0) 493 return 0; 494 - 495 if (level > MAX_TOPO_LEVEL) 496 return 0; 497 - /* allocate 2^1 pages = 8K (on i386); should be more than enough for one device */ 498 - if (!(pages_start = (char*) __get_free_pages(GFP_KERNEL,1))) 499 - return -ENOMEM; 500 - 501 if (usbdev->parent && usbdev->parent->devnum != -1) 502 parent_devnum = usbdev->parent->devnum; 503 /* ··· 545 bus->bandwidth_allocated, max, 546 (100 * bus->bandwidth_allocated + max / 2) 547 / max, 548 - bus->bandwidth_int_reqs, 549 - bus->bandwidth_isoc_reqs); 550 - 551 } 552 - data_end = usb_dump_desc(data_end, pages_start + (2 * PAGE_SIZE) - 256, usbdev); 553 - 554 if (data_end > (pages_start + (2 * PAGE_SIZE) - 256)) 555 data_end += sprintf(data_end, "(truncated)\n"); 556 - 557 length = data_end - pages_start; 558 /* if we can start copying some data to the user */ 559 if (length > *skip_bytes) { ··· 572 *skip_bytes = 0; 573 } else 574 *skip_bytes -= length; 575 - 576 free_pages((unsigned long)pages_start, 1); 577 - 578 /* Now look at all of this device's children. */ 579 for (chix = 0; chix < usbdev->maxchild; chix++) { 580 struct usb_device *childdev = usbdev->children[chix]; 581 582 if (childdev) { 583 usb_lock_device(childdev); 584 - ret = usb_device_dump(buffer, nbytes, skip_bytes, file_offset, childdev, 585 - bus, level + 1, chix, ++cnt); 586 usb_unlock_device(childdev); 587 if (ret == -EFAULT) 588 return total_written; ··· 593 return total_written; 594 } 595 596 - static ssize_t usb_device_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) 597 { 598 struct usb_bus *bus; 599 ssize_t ret, total_written = 0; ··· 614 if (!bus->root_hub) 615 continue; 616 usb_lock_device(bus->root_hub); 617 - ret = usb_device_dump(&buf, &nbytes, &skip_bytes, ppos, bus->root_hub, bus, 0, 0, 0); 618 usb_unlock_device(bus->root_hub); 619 if (ret < 0) { 620 mutex_unlock(&usb_bus_list_lock); ··· 628 } 629 630 /* Kernel lock for "lastev" protection */ 631 - static unsigned int usb_device_poll(struct file *file, struct poll_table_struct *wait) 632 { 633 struct usb_device_status *st = file->private_data; 634 unsigned int mask = 0; ··· 638 if (!st) { 639 st = kmalloc(sizeof(struct usb_device_status), GFP_KERNEL); 640 641 - /* we may have dropped BKL - need to check for having lost the race */ 642 if (file->private_data) { 643 kfree(st); 644 st = file->private_data; ··· 662 } 663 lost_race: 664 if (file->f_mode & FMODE_READ) 665 - poll_wait(file, &deviceconndiscwq, wait); 666 if (st->lastev != conndiscevcnt) 667 mask |= POLLIN; 668 st->lastev = conndiscevcnt; ··· 672 673 static int usb_device_open(struct inode *inode, struct file *file) 674 { 675 - file->private_data = NULL; 676 - return 0; 677 } 678 679 static int usb_device_release(struct inode *inode, struct file *file) 680 { 681 kfree(file->private_data); 682 file->private_data = NULL; 683 - return 0; 684 } 685 686 - static loff_t usb_device_lseek(struct file * file, loff_t offset, int orig) 687 { 688 loff_t ret; 689
··· 89 static const char *format_bandwidth = 90 /* B: Alloc=ddd/ddd us (xx%), #Int=ddd, #Iso=ddd */ 91 "B: Alloc=%3d/%3d us (%2d%%), #Int=%3d, #Iso=%3d\n"; 92 + 93 static const char *format_device1 = 94 /* D: Ver=xx.xx Cls=xx(sssss) Sub=xx Prot=xx MxPS=dd #Cfgs=dd */ 95 "D: Ver=%2x.%02x Cls=%02x(%-5s) Sub=%02x Prot=%02x MxPS=%2d #Cfgs=%3d\n"; ··· 101 static const char *format_config = 102 /* C: #Ifs=dd Cfg#=dd Atr=xx MPwr=dddmA */ 103 "C:%c #Ifs=%2d Cfg#=%2d Atr=%02x MxPwr=%3dmA\n"; 104 + 105 static const char *format_iad = 106 /* A: FirstIf#=dd IfCount=dd Cls=xx(sssss) Sub=xx Prot=xx */ 107 "A: FirstIf#=%2d IfCount=%2d Cls=%02x(%-5s) Sub=%02x Prot=%02x\n"; ··· 122 */ 123 124 static DECLARE_WAIT_QUEUE_HEAD(deviceconndiscwq); 125 + static unsigned int conndiscevcnt; 126 127 /* this struct stores the poll state for <mountpoint>/devices pollers */ 128 struct usb_device_status { ··· 172 return clas_info[ix].class_name; 173 } 174 175 + static char *usb_dump_endpoint_descriptor(int speed, char *start, char *end, 176 + const struct usb_endpoint_descriptor *desc) 177 { 178 char dir, unit, *type; 179 unsigned interval, bandwidth = 1; ··· 235 236 start += sprintf(start, format_endpt, desc->bEndpointAddress, dir, 237 desc->bmAttributes, type, 238 + (le16_to_cpu(desc->wMaxPacketSize) & 0x07ff) * 239 + bandwidth, 240 interval, unit); 241 return start; 242 } 243 244 static char *usb_dump_interface_descriptor(char *start, char *end, 245 + const struct usb_interface_cache *intfc, 246 + const struct usb_interface *iface, 247 + int setno) 248 { 249 + const struct usb_interface_descriptor *desc; 250 const char *driver_name = ""; 251 int active = 0; 252 253 if (start > end) 254 return start; 255 + desc = &intfc->altsetting[setno].desc; 256 if (iface) { 257 driver_name = (iface->dev.driver 258 ? iface->dev.driver->name ··· 270 return start; 271 } 272 273 + static char *usb_dump_interface(int speed, char *start, char *end, 274 + const struct usb_interface_cache *intfc, 275 + const struct usb_interface *iface, int setno) 276 + { 277 const struct usb_host_interface *desc = &intfc->altsetting[setno]; 278 int i; 279 ··· 292 } 293 294 static char *usb_dump_iad_descriptor(char *start, char *end, 295 + const struct usb_interface_assoc_descriptor *iad) 296 { 297 if (start > end) 298 return start; ··· 311 * 1. marking active interface altsettings (code lists all, but should mark 312 * which ones are active, if any) 313 */ 314 + static char *usb_dump_config_descriptor(char *start, char *end, 315 + const struct usb_config_descriptor *desc, 316 + int active) 317 { 318 if (start > end) 319 return start; 320 start += sprintf(start, format_config, 321 + /* mark active/actual/current cfg. */ 322 + active ? '*' : ' ', 323 desc->bNumInterfaces, 324 desc->bConfigurationValue, 325 desc->bmAttributes, ··· 325 return start; 326 } 327 328 + static char *usb_dump_config(int speed, char *start, char *end, 329 + const struct usb_host_config *config, int active) 330 { 331 int i, j; 332 struct usb_interface_cache *intfc; ··· 339 340 if (start > end) 341 return start; 342 + if (!config) 343 + /* getting these some in 2.3.7; none in 2.3.6 */ 344 return start + sprintf(start, "(null Cfg. desc.)\n"); 345 start = usb_dump_config_descriptor(start, end, &config->desc, active); 346 for (i = 0; i < USB_MAXIADS; i++) { ··· 364 /* 365 * Dump the different USB descriptors. 366 */ 367 + static char *usb_dump_device_descriptor(char *start, char *end, 368 + const struct usb_device_descriptor *desc) 369 { 370 u16 bcdUSB = le16_to_cpu(desc->bcdUSB); 371 u16 bcdDevice = le16_to_cpu(desc->bcdDevice); ··· 374 start += sprintf(start, format_device1, 375 bcdUSB >> 8, bcdUSB & 0xff, 376 desc->bDeviceClass, 377 + class_decode(desc->bDeviceClass), 378 desc->bDeviceSubClass, 379 desc->bDeviceProtocol, 380 desc->bMaxPacketSize0, ··· 391 /* 392 * Dump the different strings that this device holds. 393 */ 394 + static char *usb_dump_device_strings(char *start, char *end, 395 + struct usb_device *dev) 396 { 397 if (start > end) 398 return start; 399 if (dev->manufacturer) 400 + start += sprintf(start, format_string_manufacturer, 401 + dev->manufacturer); 402 if (start > end) 403 goto out; 404 if (dev->product) ··· 405 goto out; 406 #ifdef ALLOW_SERIAL_NUMBER 407 if (dev->serial) 408 + start += sprintf(start, format_string_serialnumber, 409 + dev->serial); 410 #endif 411 out: 412 return start; ··· 417 418 if (start > end) 419 return start; 420 + 421 start = usb_dump_device_descriptor(start, end, &dev->descriptor); 422 423 if (start > end) 424 return start; 425 + 426 start = usb_dump_device_strings(start, end, dev); 427 428 for (i = 0; i < dev->descriptor.bNumConfigurations; i++) { ··· 439 440 #ifdef PROC_EXTRA /* TBD: may want to add this code later */ 441 442 + static char *usb_dump_hub_descriptor(char *start, char *end, 443 + const struct usb_hub_descriptor *desc) 444 { 445 int leng = USB_DT_HUB_NONVAR_SIZE; 446 unsigned char *ptr = (unsigned char *)desc; ··· 455 return start; 456 } 457 458 + static char *usb_dump_string(char *start, char *end, 459 + const struct usb_device *dev, char *id, int index) 460 { 461 if (start > end) 462 return start; 463 start += sprintf(start, "Interface:"); 464 + if (index <= dev->maxstring && dev->stringindex && 465 + dev->stringindex[index]) 466 + start += sprintf(start, "%s: %.100s ", id, 467 + dev->stringindex[index]); 468 return start; 469 } 470 ··· 476 * file_offset - the offset into the devices file on completion 477 * The caller must own the device lock. 478 */ 479 + static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes, 480 + loff_t *skip_bytes, loff_t *file_offset, 481 + struct usb_device *usbdev, struct usb_bus *bus, 482 + int level, int index, int count) 483 { 484 int chix; 485 int ret, cnt = 0; ··· 485 char *pages_start, *data_end, *speed; 486 unsigned int length; 487 ssize_t total_written = 0; 488 + 489 /* don't bother with anything else if we're not writing any data */ 490 if (*nbytes <= 0) 491 return 0; 492 + 493 if (level > MAX_TOPO_LEVEL) 494 return 0; 495 + /* allocate 2^1 pages = 8K (on i386); 496 + * should be more than enough for one device */ 497 + pages_start = (char *)__get_free_pages(GFP_KERNEL, 1); 498 + if (!pages_start) 499 + return -ENOMEM; 500 + 501 if (usbdev->parent && usbdev->parent->devnum != -1) 502 parent_devnum = usbdev->parent->devnum; 503 /* ··· 541 bus->bandwidth_allocated, max, 542 (100 * bus->bandwidth_allocated + max / 2) 543 / max, 544 + bus->bandwidth_int_reqs, 545 + bus->bandwidth_isoc_reqs); 546 + 547 } 548 + data_end = usb_dump_desc(data_end, pages_start + (2 * PAGE_SIZE) - 256, 549 + usbdev); 550 + 551 if (data_end > (pages_start + (2 * PAGE_SIZE) - 256)) 552 data_end += sprintf(data_end, "(truncated)\n"); 553 + 554 length = data_end - pages_start; 555 /* if we can start copying some data to the user */ 556 if (length > *skip_bytes) { ··· 567 *skip_bytes = 0; 568 } else 569 *skip_bytes -= length; 570 + 571 free_pages((unsigned long)pages_start, 1); 572 + 573 /* Now look at all of this device's children. */ 574 for (chix = 0; chix < usbdev->maxchild; chix++) { 575 struct usb_device *childdev = usbdev->children[chix]; 576 577 if (childdev) { 578 usb_lock_device(childdev); 579 + ret = usb_device_dump(buffer, nbytes, skip_bytes, 580 + file_offset, childdev, bus, 581 + level + 1, chix, ++cnt); 582 usb_unlock_device(childdev); 583 if (ret == -EFAULT) 584 return total_written; ··· 587 return total_written; 588 } 589 590 + static ssize_t usb_device_read(struct file *file, char __user *buf, 591 + size_t nbytes, loff_t *ppos) 592 { 593 struct usb_bus *bus; 594 ssize_t ret, total_written = 0; ··· 607 if (!bus->root_hub) 608 continue; 609 usb_lock_device(bus->root_hub); 610 + ret = usb_device_dump(&buf, &nbytes, &skip_bytes, ppos, 611 + bus->root_hub, bus, 0, 0, 0); 612 usb_unlock_device(bus->root_hub); 613 if (ret < 0) { 614 mutex_unlock(&usb_bus_list_lock); ··· 620 } 621 622 /* Kernel lock for "lastev" protection */ 623 + static unsigned int usb_device_poll(struct file *file, 624 + struct poll_table_struct *wait) 625 { 626 struct usb_device_status *st = file->private_data; 627 unsigned int mask = 0; ··· 629 if (!st) { 630 st = kmalloc(sizeof(struct usb_device_status), GFP_KERNEL); 631 632 + /* we may have dropped BKL - 633 + * need to check for having lost the race */ 634 if (file->private_data) { 635 kfree(st); 636 st = file->private_data; ··· 652 } 653 lost_race: 654 if (file->f_mode & FMODE_READ) 655 + poll_wait(file, &deviceconndiscwq, wait); 656 if (st->lastev != conndiscevcnt) 657 mask |= POLLIN; 658 st->lastev = conndiscevcnt; ··· 662 663 static int usb_device_open(struct inode *inode, struct file *file) 664 { 665 + file->private_data = NULL; 666 + return 0; 667 } 668 669 static int usb_device_release(struct inode *inode, struct file *file) 670 { 671 kfree(file->private_data); 672 file->private_data = NULL; 673 + return 0; 674 } 675 676 + static loff_t usb_device_lseek(struct file *file, loff_t offset, int orig) 677 { 678 loff_t ret; 679