summaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorHuang Rui <ray.huang@amd.com>2013-10-30 11:27:39 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-10-30 09:57:21 -0700
commitb8fef79518f6a6843e53a4d578c20873ce742a1f (patch)
tree018d7e60c45a0737d77a8a4b5d729ac07b142a30 /drivers/usb
parent82f92672ac3e36458fdb298f798913da8460fce9 (diff)
downloadop-kernel-dev-b8fef79518f6a6843e53a4d578c20873ce742a1f.zip
op-kernel-dev-b8fef79518f6a6843e53a4d578c20873ce742a1f.tar.gz
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/usb')
-rw-r--r--drivers/usb/misc/usbtest.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 1c78e74..d6fcbc4 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)
return 1;
}
+static int is_good_ss_cap(struct usbtest_dev *tdev, u8 *buf)
+{
+ struct usb_ss_cap_descriptor *ss;
+
+ ss = (struct usb_ss_cap_descriptor *) buf;
+
+ if (ss->bLength != USB_DT_USB_SS_CAP_SIZE) {
+ ERROR(tdev, "bogus superspeed device capability descriptor length\n");
+ return 0;
+ }
+
+ /*
+ * only bit[1] of bmAttributes is used for LTM and others are
+ * reserved
+ */
+ if (ss->bmAttributes & ~0x02) { /* reserved == 0 */
+ ERROR(tdev, "reserved bits set in bmAttributes\n");
+ return 0;
+ }
+
+ /* bits[0:3] of wSpeedSupported is used and others are reserved */
+ if (le16_to_cpu(ss->wSpeedSupported) & ~0x0f) { /* reserved == 0 */
+ ERROR(tdev, "reserved bits set in wSpeedSupported\n");
+ return 0;
+ }
+
+ return 1;
+}
+
/* sanity test for standard requests working with usb_control_mesg() and some
* of the utility functions which use it.
*
@@ -773,6 +802,14 @@ static int ch9_postconfig(struct usbtest_dev *dev)
return -EDOM;
}
break;
+ case USB_SS_CAP_TYPE:
+ if (buf + USB_DT_USB_SS_CAP_SIZE >
+ dev->buf + total ||
+ !is_good_ss_cap(dev, buf)) {
+ dev_err(&iface->dev, "bogus superspeed device capability descriptor\n");
+ return -EDOM;
+ }
+ break;
default:
break;
}
OpenPOWER on IntegriCloud