aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/ehci-dbg.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/host/ehci-dbg.c')
-rw-r--r--drivers/usb/host/ehci-dbg.c56
1 files changed, 32 insertions, 24 deletions
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
index b0f8ed5a7fb9..0cb53ca8d343 100644
--- a/drivers/usb/host/ehci-dbg.c
+++ b/drivers/usb/host/ehci-dbg.c
@@ -358,7 +358,8 @@ struct debug_buffer {
358 struct usb_bus *bus; 358 struct usb_bus *bus;
359 struct mutex mutex; /* protect filling of buffer */ 359 struct mutex mutex; /* protect filling of buffer */
360 size_t count; /* number of characters filled into buffer */ 360 size_t count; /* number of characters filled into buffer */
361 char *page; 361 char *output_buf;
362 size_t alloc_size;
362}; 363};
363 364
364#define speed_char(info1) ({ char tmp; \ 365#define speed_char(info1) ({ char tmp; \
@@ -488,8 +489,8 @@ static ssize_t fill_async_buffer(struct debug_buffer *buf)
488 489
489 hcd = bus_to_hcd(buf->bus); 490 hcd = bus_to_hcd(buf->bus);
490 ehci = hcd_to_ehci (hcd); 491 ehci = hcd_to_ehci (hcd);
491 next = buf->page; 492 next = buf->output_buf;
492 size = PAGE_SIZE; 493 size = buf->alloc_size;
493 494
494 *next = 0; 495 *next = 0;
495 496
@@ -510,7 +511,7 @@ static ssize_t fill_async_buffer(struct debug_buffer *buf)
510 } 511 }
511 spin_unlock_irqrestore (&ehci->lock, flags); 512 spin_unlock_irqrestore (&ehci->lock, flags);
512 513
513 return strlen(buf->page); 514 return strlen(buf->output_buf);
514} 515}
515 516
516#define DBG_SCHED_LIMIT 64 517#define DBG_SCHED_LIMIT 64
@@ -531,8 +532,8 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf)
531 532
532 hcd = bus_to_hcd(buf->bus); 533 hcd = bus_to_hcd(buf->bus);
533 ehci = hcd_to_ehci (hcd); 534 ehci = hcd_to_ehci (hcd);
534 next = buf->page; 535 next = buf->output_buf;
535 size = PAGE_SIZE; 536 size = buf->alloc_size;
536 537
537 temp = scnprintf (next, size, "size = %d\n", ehci->periodic_size); 538 temp = scnprintf (next, size, "size = %d\n", ehci->periodic_size);
538 size -= temp; 539 size -= temp;
@@ -568,14 +569,16 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf)
568 for (temp = 0; temp < seen_count; temp++) { 569 for (temp = 0; temp < seen_count; temp++) {
569 if (seen [temp].ptr != p.ptr) 570 if (seen [temp].ptr != p.ptr)
570 continue; 571 continue;
571 if (p.qh->qh_next.ptr) 572 if (p.qh->qh_next.ptr) {
572 temp = scnprintf (next, size, 573 temp = scnprintf (next, size,
573 " ..."); 574 " ...");
574 p.ptr = NULL; 575 size -= temp;
576 next += temp;
577 }
575 break; 578 break;
576 } 579 }
577 /* show more info the first time around */ 580 /* show more info the first time around */
578 if (temp == seen_count && p.ptr) { 581 if (temp == seen_count) {
579 u32 scratch = hc32_to_cpup(ehci, 582 u32 scratch = hc32_to_cpup(ehci,
580 &p.qh->hw_info1); 583 &p.qh->hw_info1);
581 struct ehci_qtd *qtd; 584 struct ehci_qtd *qtd;
@@ -649,7 +652,7 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf)
649 spin_unlock_irqrestore (&ehci->lock, flags); 652 spin_unlock_irqrestore (&ehci->lock, flags);
650 kfree (seen); 653 kfree (seen);
651 654
652 return PAGE_SIZE - size; 655 return buf->alloc_size - size;
653} 656}
654#undef DBG_SCHED_LIMIT 657#undef DBG_SCHED_LIMIT
655 658
@@ -665,14 +668,14 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
665 668
666 hcd = bus_to_hcd(buf->bus); 669 hcd = bus_to_hcd(buf->bus);
667 ehci = hcd_to_ehci (hcd); 670 ehci = hcd_to_ehci (hcd);
668 next = buf->page; 671 next = buf->output_buf;
669 size = PAGE_SIZE; 672 size = buf->alloc_size;
670 673
671 spin_lock_irqsave (&ehci->lock, flags); 674 spin_lock_irqsave (&ehci->lock, flags);
672 675
673 if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { 676 if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) {
674 size = scnprintf (next, size, 677 size = scnprintf (next, size,
675 "bus %s, device %s (driver " DRIVER_VERSION ")\n" 678 "bus %s, device %s\n"
676 "%s\n" 679 "%s\n"
677 "SUSPENDED (no register access)\n", 680 "SUSPENDED (no register access)\n",
678 hcd->self.controller->bus->name, 681 hcd->self.controller->bus->name,
@@ -684,7 +687,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
684 /* Capability Registers */ 687 /* Capability Registers */
685 i = HC_VERSION(ehci_readl(ehci, &ehci->caps->hc_capbase)); 688 i = HC_VERSION(ehci_readl(ehci, &ehci->caps->hc_capbase));
686 temp = scnprintf (next, size, 689 temp = scnprintf (next, size,
687 "bus %s, device %s (driver " DRIVER_VERSION ")\n" 690 "bus %s, device %s\n"
688 "%s\n" 691 "%s\n"
689 "EHCI %x.%02x, hcd state %d\n", 692 "EHCI %x.%02x, hcd state %d\n",
690 hcd->self.controller->bus->name, 693 hcd->self.controller->bus->name,
@@ -808,7 +811,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
808done: 811done:
809 spin_unlock_irqrestore (&ehci->lock, flags); 812 spin_unlock_irqrestore (&ehci->lock, flags);
810 813
811 return PAGE_SIZE - size; 814 return buf->alloc_size - size;
812} 815}
813 816
814static struct debug_buffer *alloc_buffer(struct usb_bus *bus, 817static struct debug_buffer *alloc_buffer(struct usb_bus *bus,
@@ -822,6 +825,7 @@ static struct debug_buffer *alloc_buffer(struct usb_bus *bus,
822 buf->bus = bus; 825 buf->bus = bus;
823 buf->fill_func = fill_func; 826 buf->fill_func = fill_func;
824 mutex_init(&buf->mutex); 827 mutex_init(&buf->mutex);
828 buf->alloc_size = PAGE_SIZE;
825 } 829 }
826 830
827 return buf; 831 return buf;
@@ -831,10 +835,10 @@ static int fill_buffer(struct debug_buffer *buf)
831{ 835{
832 int ret = 0; 836 int ret = 0;
833 837
834 if (!buf->page) 838 if (!buf->output_buf)
835 buf->page = (char *)get_zeroed_page(GFP_KERNEL); 839 buf->output_buf = (char *)vmalloc(buf->alloc_size);
836 840
837 if (!buf->page) { 841 if (!buf->output_buf) {
838 ret = -ENOMEM; 842 ret = -ENOMEM;
839 goto out; 843 goto out;
840 } 844 }
@@ -867,7 +871,7 @@ static ssize_t debug_output(struct file *file, char __user *user_buf,
867 mutex_unlock(&buf->mutex); 871 mutex_unlock(&buf->mutex);
868 872
869 ret = simple_read_from_buffer(user_buf, len, offset, 873 ret = simple_read_from_buffer(user_buf, len, offset,
870 buf->page, buf->count); 874 buf->output_buf, buf->count);
871 875
872out: 876out:
873 return ret; 877 return ret;
@@ -879,8 +883,8 @@ static int debug_close(struct inode *inode, struct file *file)
879 struct debug_buffer *buf = file->private_data; 883 struct debug_buffer *buf = file->private_data;
880 884
881 if (buf) { 885 if (buf) {
882 if (buf->page) 886 if (buf->output_buf)
883 free_page((unsigned long)buf->page); 887 vfree(buf->output_buf);
884 kfree(buf); 888 kfree(buf);
885 } 889 }
886 890
@@ -895,10 +899,14 @@ static int debug_async_open(struct inode *inode, struct file *file)
895 899
896static int debug_periodic_open(struct inode *inode, struct file *file) 900static int debug_periodic_open(struct inode *inode, struct file *file)
897{ 901{
898 file->private_data = alloc_buffer(inode->i_private, 902 struct debug_buffer *buf;
899 fill_periodic_buffer); 903 buf = alloc_buffer(inode->i_private, fill_periodic_buffer);
904 if (!buf)
905 return -ENOMEM;
900 906
901 return file->private_data ? 0 : -ENOMEM; 907 buf->alloc_size = (sizeof(void *) == 4 ? 6 : 8)*PAGE_SIZE;
908 file->private_data = buf;
909 return 0;
902} 910}
903 911
904static int debug_registers_open(struct inode *inode, struct file *file) 912static int debug_registers_open(struct inode *inode, struct file *file)