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