diff options
author | Huang Rui <ray.huang@amd.com> | 2013-10-29 23:27:39 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-10-30 12:57:21 -0400 |
commit | b8fef79518f6a6843e53a4d578c20873ce742a1f (patch) | |
tree | 018d7e60c45a0737d77a8a4b5d729ac07b142a30 /drivers | |
parent | 82f92672ac3e36458fdb298f798913da8460fce9 (diff) |
usb: usbtest: support superspeed device capbility descriptor test
In Test 9 of usbtest module, it is used for performing chapter 9 tests N
times.
SuperSpeed USB Device Capability descriptor is one of the generic
device-level capbility descriptors which added in section 9.6.2.2 of USB
3.0 spec.
This patch adds to support getting SuperSpeed USB Device Capability
descriptor test scenario for USB 3.0.
Signed-off-by: Huang Rui <ray.huang@amd.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/misc/usbtest.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index 1c78e747f72b..d6fcbc477fc5 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c | |||
@@ -628,6 +628,35 @@ static int is_good_ext(struct usbtest_dev *tdev, u8 *buf) | |||
628 | return 1; | 628 | return 1; |
629 | } | 629 | } |
630 | 630 | ||
631 | static int is_good_ss_cap(struct usbtest_dev *tdev, u8 *buf) | ||
632 | { | ||
633 | struct usb_ss_cap_descriptor *ss; | ||
634 | |||
635 | ss = (struct usb_ss_cap_descriptor *) buf; | ||
636 | |||
637 | if (ss->bLength != USB_DT_USB_SS_CAP_SIZE) { | ||
638 | ERROR(tdev, "bogus superspeed device capability descriptor length\n"); | ||
639 | return 0; | ||
640 | } | ||
641 | |||
642 | /* | ||
643 | * only bit[1] of bmAttributes is used for LTM and others are | ||
644 | * reserved | ||
645 | */ | ||
646 | if (ss->bmAttributes & ~0x02) { /* reserved == 0 */ | ||
647 | ERROR(tdev, "reserved bits set in bmAttributes\n"); | ||
648 | return 0; | ||
649 | } | ||
650 | |||
651 | /* bits[0:3] of wSpeedSupported is used and others are reserved */ | ||
652 | if (le16_to_cpu(ss->wSpeedSupported) & ~0x0f) { /* reserved == 0 */ | ||
653 | ERROR(tdev, "reserved bits set in wSpeedSupported\n"); | ||
654 | return 0; | ||
655 | } | ||
656 | |||
657 | return 1; | ||
658 | } | ||
659 | |||
631 | /* sanity test for standard requests working with usb_control_mesg() and some | 660 | /* sanity test for standard requests working with usb_control_mesg() and some |
632 | * of the utility functions which use it. | 661 | * of the utility functions which use it. |
633 | * | 662 | * |
@@ -773,6 +802,14 @@ static int ch9_postconfig(struct usbtest_dev *dev) | |||
773 | return -EDOM; | 802 | return -EDOM; |
774 | } | 803 | } |
775 | break; | 804 | break; |
805 | case USB_SS_CAP_TYPE: | ||
806 | if (buf + USB_DT_USB_SS_CAP_SIZE > | ||
807 | dev->buf + total || | ||
808 | !is_good_ss_cap(dev, buf)) { | ||
809 | dev_err(&iface->dev, "bogus superspeed device capability descriptor\n"); | ||
810 | return -EDOM; | ||
811 | } | ||
812 | break; | ||
776 | default: | 813 | default: |
777 | break; | 814 | break; |
778 | } | 815 | } |