aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2005-06-21 00:15:16 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-10-28 19:47:38 -0400
commite639dd3f4edd4847d160899b19e95ee1a06a6dcb (patch)
treec5d99cf857c77005af27b688d3935f90c3c8536a /drivers
parentd6e5bcf4a7ebbe258124a931f1449338340a99b5 (diff)
[PATCH] USB: add more snooping hooks in devio.c
Now we can log the urbs travelling through usbfs Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/core/devio.c55
1 files changed, 50 insertions, 5 deletions
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index befe0c7f63d1..6c15dabcfc0b 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -279,6 +279,28 @@ static inline struct async *async_getpending(struct dev_state *ps, void __user *
279 return NULL; 279 return NULL;
280} 280}
281 281
282static void snoop_urb(struct urb *urb, void __user *userurb)
283{
284 int j;
285 unsigned char *data = urb->transfer_buffer;
286
287 if (!usbfs_snoop)
288 return;
289
290 if (urb->pipe & USB_DIR_IN)
291 dev_info(&urb->dev->dev, "direction=IN\n");
292 else
293 dev_info(&urb->dev->dev, "direction=OUT\n");
294 dev_info(&urb->dev->dev, "userurb=%p\n", userurb);
295 dev_info(&urb->dev->dev, "transfer_buffer_length=%d\n",
296 urb->transfer_buffer_length);
297 dev_info(&urb->dev->dev, "actual_length=%d\n", urb->actual_length);
298 dev_info(&urb->dev->dev, "data: ");
299 for (j = 0; j < urb->transfer_buffer_length; ++j)
300 printk ("%02x ", data[j]);
301 printk("\n");
302}
303
282static void async_completed(struct urb *urb, struct pt_regs *regs) 304static void async_completed(struct urb *urb, struct pt_regs *regs)
283{ 305{
284 struct async *as = (struct async *)urb->context; 306 struct async *as = (struct async *)urb->context;
@@ -296,7 +318,9 @@ static void async_completed(struct urb *urb, struct pt_regs *regs)
296 kill_proc_info_as_uid(as->signr, &sinfo, as->pid, as->uid, 318 kill_proc_info_as_uid(as->signr, &sinfo, as->pid, as->uid,
297 as->euid); 319 as->euid);
298 } 320 }
299 wake_up(&ps->wait); 321 snoop(&urb->dev->dev, "urb complete\n");
322 snoop_urb(urb, as->userurb);
323 wake_up(&ps->wait);
300} 324}
301 325
302static void destroy_async (struct dev_state *ps, struct list_head *list) 326static void destroy_async (struct dev_state *ps, struct list_head *list)
@@ -601,7 +625,7 @@ static int proc_control(struct dev_state *ps, void __user *arg)
601 if (usbfs_snoop) { 625 if (usbfs_snoop) {
602 dev_info(&dev->dev, "control read: data "); 626 dev_info(&dev->dev, "control read: data ");
603 for (j = 0; j < i; ++j) 627 for (j = 0; j < i; ++j)
604 printk ("%02x ", (unsigned char)(tbuf)[j]); 628 printk("%02x ", (unsigned char)(tbuf)[j]);
605 printk("\n"); 629 printk("\n");
606 } 630 }
607 if (copy_to_user(ctrl.data, tbuf, i)) { 631 if (copy_to_user(ctrl.data, tbuf, i)) {
@@ -624,7 +648,7 @@ static int proc_control(struct dev_state *ps, void __user *arg)
624 if (usbfs_snoop) { 648 if (usbfs_snoop) {
625 dev_info(&dev->dev, "control write: data: "); 649 dev_info(&dev->dev, "control write: data: ");
626 for (j = 0; j < ctrl.wLength; ++j) 650 for (j = 0; j < ctrl.wLength; ++j)
627 printk ("%02x ", (unsigned char)(tbuf)[j]); 651 printk("%02x ", (unsigned char)(tbuf)[j]);
628 printk("\n"); 652 printk("\n");
629 } 653 }
630 usb_unlock_device(dev); 654 usb_unlock_device(dev);
@@ -649,7 +673,7 @@ static int proc_bulk(struct dev_state *ps, void __user *arg)
649 unsigned int tmo, len1, pipe; 673 unsigned int tmo, len1, pipe;
650 int len2; 674 int len2;
651 unsigned char *tbuf; 675 unsigned char *tbuf;
652 int i, ret; 676 int i, j, ret;
653 677
654 if (copy_from_user(&bulk, arg, sizeof(bulk))) 678 if (copy_from_user(&bulk, arg, sizeof(bulk)))
655 return -EFAULT; 679 return -EFAULT;
@@ -674,10 +698,18 @@ static int proc_bulk(struct dev_state *ps, void __user *arg)
674 kfree(tbuf); 698 kfree(tbuf);
675 return -EINVAL; 699 return -EINVAL;
676 } 700 }
701 snoop(&dev->dev, "bulk read: len=0x%02x timeout=%04d\n",
702 bulk.len, bulk.timeout);
677 usb_unlock_device(dev); 703 usb_unlock_device(dev);
678 i = usb_bulk_msg(dev, pipe, tbuf, len1, &len2, tmo); 704 i = usb_bulk_msg(dev, pipe, tbuf, len1, &len2, tmo);
679 usb_lock_device(dev); 705 usb_lock_device(dev);
680 if (!i && len2) { 706 if (!i && len2) {
707 if (usbfs_snoop) {
708 dev_info(&dev->dev, "bulk read: data ");
709 for (j = 0; j < len2; ++j)
710 printk("%02x ", (unsigned char)(tbuf)[j]);
711 printk("\n");
712 }
681 if (copy_to_user(bulk.data, tbuf, len2)) { 713 if (copy_to_user(bulk.data, tbuf, len2)) {
682 kfree(tbuf); 714 kfree(tbuf);
683 return -EFAULT; 715 return -EFAULT;
@@ -690,6 +722,14 @@ static int proc_bulk(struct dev_state *ps, void __user *arg)
690 return -EFAULT; 722 return -EFAULT;
691 } 723 }
692 } 724 }
725 snoop(&dev->dev, "bulk write: len=0x%02x timeout=%04d\n",
726 bulk.len, bulk.timeout);
727 if (usbfs_snoop) {
728 dev_info(&dev->dev, "bulk write: data: ");
729 for (j = 0; j < len1; ++j)
730 printk("%02x ", (unsigned char)(tbuf)[j]);
731 printk("\n");
732 }
693 usb_unlock_device(dev); 733 usb_unlock_device(dev);
694 i = usb_bulk_msg(dev, pipe, tbuf, len1, &len2, tmo); 734 i = usb_bulk_msg(dev, pipe, tbuf, len1, &len2, tmo);
695 usb_lock_device(dev); 735 usb_lock_device(dev);
@@ -835,7 +875,6 @@ static int proc_setconfig(struct dev_state *ps, void __user *arg)
835 return status; 875 return status;
836} 876}
837 877
838
839static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, 878static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
840 struct usbdevfs_iso_packet_desc __user *iso_frame_desc, 879 struct usbdevfs_iso_packet_desc __user *iso_frame_desc,
841 void __user *arg) 880 void __user *arg)
@@ -896,6 +935,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
896 kfree(dr); 935 kfree(dr);
897 return -EFAULT; 936 return -EFAULT;
898 } 937 }
938 snoop(&ps->dev->dev, "control urb\n");
899 break; 939 break;
900 940
901 case USBDEVFS_URB_TYPE_BULK: 941 case USBDEVFS_URB_TYPE_BULK:
@@ -910,6 +950,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
910 return -EINVAL; 950 return -EINVAL;
911 if (!access_ok((uurb->endpoint & USB_DIR_IN) ? VERIFY_WRITE : VERIFY_READ, uurb->buffer, uurb->buffer_length)) 951 if (!access_ok((uurb->endpoint & USB_DIR_IN) ? VERIFY_WRITE : VERIFY_READ, uurb->buffer, uurb->buffer_length))
912 return -EFAULT; 952 return -EFAULT;
953 snoop(&ps->dev->dev, "bulk urb\n");
913 break; 954 break;
914 955
915 case USBDEVFS_URB_TYPE_ISO: 956 case USBDEVFS_URB_TYPE_ISO:
@@ -939,6 +980,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
939 return -EINVAL; 980 return -EINVAL;
940 } 981 }
941 uurb->buffer_length = totlen; 982 uurb->buffer_length = totlen;
983 snoop(&ps->dev->dev, "iso urb\n");
942 break; 984 break;
943 985
944 case USBDEVFS_URB_TYPE_INTERRUPT: 986 case USBDEVFS_URB_TYPE_INTERRUPT:
@@ -954,6 +996,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
954 return -EINVAL; 996 return -EINVAL;
955 if (!access_ok((uurb->endpoint & USB_DIR_IN) ? VERIFY_WRITE : VERIFY_READ, uurb->buffer, uurb->buffer_length)) 997 if (!access_ok((uurb->endpoint & USB_DIR_IN) ? VERIFY_WRITE : VERIFY_READ, uurb->buffer, uurb->buffer_length))
956 return -EFAULT; 998 return -EFAULT;
999 snoop(&ps->dev->dev, "interrupt urb\n");
957 break; 1000 break;
958 1001
959 default: 1002 default:
@@ -1003,6 +1046,8 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
1003 return -EFAULT; 1046 return -EFAULT;
1004 } 1047 }
1005 } 1048 }
1049 snoop(&as->urb->dev->dev, "submit urb\n");
1050 snoop_urb(as->urb, as->userurb);
1006 async_newpending(as); 1051 async_newpending(as);
1007 if ((ret = usb_submit_urb(as->urb, GFP_KERNEL))) { 1052 if ((ret = usb_submit_urb(as->urb, GFP_KERNEL))) {
1008 dev_printk(KERN_DEBUG, &ps->dev->dev, "usbfs: usb_submit_urb returned %d\n", ret); 1053 dev_printk(KERN_DEBUG, &ps->dev->dev, "usbfs: usb_submit_urb returned %d\n", ret);