diff options
author | Chris Frey <cdfrey@foursquare.net> | 2010-01-26 17:07:29 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-03-02 17:54:37 -0500 |
commit | 0880aef49e40abd1ed34ab713e8b024e8bc2021e (patch) | |
tree | 5a2a20e1c44dbbd4f1b13d4765a226d6c4589cbf | |
parent | 0978f8c55cdc7c06b2f1440b030e93fda2c53b2b (diff) |
USB: usbfs_snoop: add data logging back in
Uses the new snoop function from commit 4c6e8971cbe0148085,
but includes the buffer data where appropriate, as before.
Signed-off-by: Chris Frey <cdfrey@foursquare.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/usb/core/devio.c | 51 |
1 files changed, 38 insertions, 13 deletions
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index e59efea9410f..e909ff7b9094 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c | |||
@@ -310,7 +310,8 @@ static struct async *async_getpending(struct dev_state *ps, | |||
310 | 310 | ||
311 | static void snoop_urb(struct usb_device *udev, | 311 | static void snoop_urb(struct usb_device *udev, |
312 | void __user *userurb, int pipe, unsigned length, | 312 | void __user *userurb, int pipe, unsigned length, |
313 | int timeout_or_status, enum snoop_when when) | 313 | int timeout_or_status, enum snoop_when when, |
314 | unsigned char *data, unsigned data_len) | ||
314 | { | 315 | { |
315 | static const char *types[] = {"isoc", "int", "ctrl", "bulk"}; | 316 | static const char *types[] = {"isoc", "int", "ctrl", "bulk"}; |
316 | static const char *dirs[] = {"out", "in"}; | 317 | static const char *dirs[] = {"out", "in"}; |
@@ -344,6 +345,11 @@ static void snoop_urb(struct usb_device *udev, | |||
344 | "status %d\n", | 345 | "status %d\n", |
345 | ep, t, d, length, timeout_or_status); | 346 | ep, t, d, length, timeout_or_status); |
346 | } | 347 | } |
348 | |||
349 | if (data && data_len > 0) { | ||
350 | print_hex_dump(KERN_DEBUG, "data: ", DUMP_PREFIX_NONE, 32, 1, | ||
351 | data, data_len, 1); | ||
352 | } | ||
347 | } | 353 | } |
348 | 354 | ||
349 | #define AS_CONTINUATION 1 | 355 | #define AS_CONTINUATION 1 |
@@ -410,7 +416,9 @@ static void async_completed(struct urb *urb) | |||
410 | } | 416 | } |
411 | snoop(&urb->dev->dev, "urb complete\n"); | 417 | snoop(&urb->dev->dev, "urb complete\n"); |
412 | snoop_urb(urb->dev, as->userurb, urb->pipe, urb->actual_length, | 418 | snoop_urb(urb->dev, as->userurb, urb->pipe, urb->actual_length, |
413 | as->status, COMPLETE); | 419 | as->status, COMPLETE, |
420 | ((urb->transfer_flags & URB_DIR_MASK) == USB_DIR_OUT) ? | ||
421 | NULL : urb->transfer_buffer, urb->actual_length); | ||
414 | if (as->status < 0 && as->bulk_addr && as->status != -ECONNRESET && | 422 | if (as->status < 0 && as->bulk_addr && as->status != -ECONNRESET && |
415 | as->status != -ENOENT) | 423 | as->status != -ENOENT) |
416 | cancel_bulk_urbs(ps, as->bulk_addr); | 424 | cancel_bulk_urbs(ps, as->bulk_addr); |
@@ -774,6 +782,13 @@ static int proc_control(struct dev_state *ps, void __user *arg) | |||
774 | if (!tbuf) | 782 | if (!tbuf) |
775 | return -ENOMEM; | 783 | return -ENOMEM; |
776 | tmo = ctrl.timeout; | 784 | tmo = ctrl.timeout; |
785 | snoop(&dev->dev, "control urb: bRequestType=%02x " | ||
786 | "bRequest=%02x wValue=%04x " | ||
787 | "wIndex=%04x wLength=%04x\n", | ||
788 | ctrl.bRequestType, ctrl.bRequest, | ||
789 | __le16_to_cpup(&ctrl.wValue), | ||
790 | __le16_to_cpup(&ctrl.wIndex), | ||
791 | __le16_to_cpup(&ctrl.wLength)); | ||
777 | if (ctrl.bRequestType & 0x80) { | 792 | if (ctrl.bRequestType & 0x80) { |
778 | if (ctrl.wLength && !access_ok(VERIFY_WRITE, ctrl.data, | 793 | if (ctrl.wLength && !access_ok(VERIFY_WRITE, ctrl.data, |
779 | ctrl.wLength)) { | 794 | ctrl.wLength)) { |
@@ -781,15 +796,15 @@ static int proc_control(struct dev_state *ps, void __user *arg) | |||
781 | return -EINVAL; | 796 | return -EINVAL; |
782 | } | 797 | } |
783 | pipe = usb_rcvctrlpipe(dev, 0); | 798 | pipe = usb_rcvctrlpipe(dev, 0); |
784 | snoop_urb(dev, NULL, pipe, ctrl.wLength, tmo, SUBMIT); | 799 | snoop_urb(dev, NULL, pipe, ctrl.wLength, tmo, SUBMIT, NULL, 0); |
785 | 800 | ||
786 | usb_unlock_device(dev); | 801 | usb_unlock_device(dev); |
787 | i = usb_control_msg(dev, pipe, ctrl.bRequest, | 802 | i = usb_control_msg(dev, pipe, ctrl.bRequest, |
788 | ctrl.bRequestType, ctrl.wValue, ctrl.wIndex, | 803 | ctrl.bRequestType, ctrl.wValue, ctrl.wIndex, |
789 | tbuf, ctrl.wLength, tmo); | 804 | tbuf, ctrl.wLength, tmo); |
790 | usb_lock_device(dev); | 805 | usb_lock_device(dev); |
791 | snoop_urb(dev, NULL, pipe, max(i, 0), min(i, 0), COMPLETE); | 806 | snoop_urb(dev, NULL, pipe, max(i, 0), min(i, 0), COMPLETE, |
792 | 807 | tbuf, i); | |
793 | if ((i > 0) && ctrl.wLength) { | 808 | if ((i > 0) && ctrl.wLength) { |
794 | if (copy_to_user(ctrl.data, tbuf, i)) { | 809 | if (copy_to_user(ctrl.data, tbuf, i)) { |
795 | free_page((unsigned long)tbuf); | 810 | free_page((unsigned long)tbuf); |
@@ -804,14 +819,15 @@ static int proc_control(struct dev_state *ps, void __user *arg) | |||
804 | } | 819 | } |
805 | } | 820 | } |
806 | pipe = usb_sndctrlpipe(dev, 0); | 821 | pipe = usb_sndctrlpipe(dev, 0); |
807 | snoop_urb(dev, NULL, pipe, ctrl.wLength, tmo, SUBMIT); | 822 | snoop_urb(dev, NULL, pipe, ctrl.wLength, tmo, SUBMIT, |
823 | tbuf, ctrl.wLength); | ||
808 | 824 | ||
809 | usb_unlock_device(dev); | 825 | usb_unlock_device(dev); |
810 | i = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), ctrl.bRequest, | 826 | i = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), ctrl.bRequest, |
811 | ctrl.bRequestType, ctrl.wValue, ctrl.wIndex, | 827 | ctrl.bRequestType, ctrl.wValue, ctrl.wIndex, |
812 | tbuf, ctrl.wLength, tmo); | 828 | tbuf, ctrl.wLength, tmo); |
813 | usb_lock_device(dev); | 829 | usb_lock_device(dev); |
814 | snoop_urb(dev, NULL, pipe, max(i, 0), min(i, 0), COMPLETE); | 830 | snoop_urb(dev, NULL, pipe, max(i, 0), min(i, 0), COMPLETE, NULL, 0); |
815 | } | 831 | } |
816 | free_page((unsigned long)tbuf); | 832 | free_page((unsigned long)tbuf); |
817 | if (i < 0 && i != -EPIPE) { | 833 | if (i < 0 && i != -EPIPE) { |
@@ -857,12 +873,12 @@ static int proc_bulk(struct dev_state *ps, void __user *arg) | |||
857 | kfree(tbuf); | 873 | kfree(tbuf); |
858 | return -EINVAL; | 874 | return -EINVAL; |
859 | } | 875 | } |
860 | snoop_urb(dev, NULL, pipe, len1, tmo, SUBMIT); | 876 | snoop_urb(dev, NULL, pipe, len1, tmo, SUBMIT, NULL, 0); |
861 | 877 | ||
862 | usb_unlock_device(dev); | 878 | usb_unlock_device(dev); |
863 | i = usb_bulk_msg(dev, pipe, tbuf, len1, &len2, tmo); | 879 | i = usb_bulk_msg(dev, pipe, tbuf, len1, &len2, tmo); |
864 | usb_lock_device(dev); | 880 | usb_lock_device(dev); |
865 | snoop_urb(dev, NULL, pipe, len2, i, COMPLETE); | 881 | snoop_urb(dev, NULL, pipe, len2, i, COMPLETE, tbuf, len2); |
866 | 882 | ||
867 | if (!i && len2) { | 883 | if (!i && len2) { |
868 | if (copy_to_user(bulk.data, tbuf, len2)) { | 884 | if (copy_to_user(bulk.data, tbuf, len2)) { |
@@ -877,12 +893,12 @@ static int proc_bulk(struct dev_state *ps, void __user *arg) | |||
877 | return -EFAULT; | 893 | return -EFAULT; |
878 | } | 894 | } |
879 | } | 895 | } |
880 | snoop_urb(dev, NULL, pipe, len1, tmo, SUBMIT); | 896 | snoop_urb(dev, NULL, pipe, len1, tmo, SUBMIT, tbuf, len1); |
881 | 897 | ||
882 | usb_unlock_device(dev); | 898 | usb_unlock_device(dev); |
883 | i = usb_bulk_msg(dev, pipe, tbuf, len1, &len2, tmo); | 899 | i = usb_bulk_msg(dev, pipe, tbuf, len1, &len2, tmo); |
884 | usb_lock_device(dev); | 900 | usb_lock_device(dev); |
885 | snoop_urb(dev, NULL, pipe, len2, i, COMPLETE); | 901 | snoop_urb(dev, NULL, pipe, len2, i, COMPLETE, NULL, 0); |
886 | } | 902 | } |
887 | kfree(tbuf); | 903 | kfree(tbuf); |
888 | if (i < 0) | 904 | if (i < 0) |
@@ -1101,6 +1117,13 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
1101 | is_in = 0; | 1117 | is_in = 0; |
1102 | uurb->endpoint &= ~USB_DIR_IN; | 1118 | uurb->endpoint &= ~USB_DIR_IN; |
1103 | } | 1119 | } |
1120 | snoop(&ps->dev->dev, "control urb: bRequestType=%02x " | ||
1121 | "bRequest=%02x wValue=%04x " | ||
1122 | "wIndex=%04x wLength=%04x\n", | ||
1123 | dr->bRequestType, dr->bRequest, | ||
1124 | __le16_to_cpup(&dr->wValue), | ||
1125 | __le16_to_cpup(&dr->wIndex), | ||
1126 | __le16_to_cpup(&dr->wLength)); | ||
1104 | break; | 1127 | break; |
1105 | 1128 | ||
1106 | case USBDEVFS_URB_TYPE_BULK: | 1129 | case USBDEVFS_URB_TYPE_BULK: |
@@ -1244,7 +1267,9 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
1244 | } | 1267 | } |
1245 | } | 1268 | } |
1246 | snoop_urb(ps->dev, as->userurb, as->urb->pipe, | 1269 | snoop_urb(ps->dev, as->userurb, as->urb->pipe, |
1247 | as->urb->transfer_buffer_length, 0, SUBMIT); | 1270 | as->urb->transfer_buffer_length, 0, SUBMIT, |
1271 | is_in ? NULL : as->urb->transfer_buffer, | ||
1272 | uurb->buffer_length); | ||
1248 | async_newpending(as); | 1273 | async_newpending(as); |
1249 | 1274 | ||
1250 | if (usb_endpoint_xfer_bulk(&ep->desc)) { | 1275 | if (usb_endpoint_xfer_bulk(&ep->desc)) { |
@@ -1282,7 +1307,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, | |||
1282 | dev_printk(KERN_DEBUG, &ps->dev->dev, | 1307 | dev_printk(KERN_DEBUG, &ps->dev->dev, |
1283 | "usbfs: usb_submit_urb returned %d\n", ret); | 1308 | "usbfs: usb_submit_urb returned %d\n", ret); |
1284 | snoop_urb(ps->dev, as->userurb, as->urb->pipe, | 1309 | snoop_urb(ps->dev, as->userurb, as->urb->pipe, |
1285 | 0, ret, COMPLETE); | 1310 | 0, ret, COMPLETE, NULL, 0); |
1286 | async_removepending(as); | 1311 | async_removepending(as); |
1287 | free_async(as); | 1312 | free_async(as); |
1288 | return ret; | 1313 | return ret; |