aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/misc/usbtest.c
diff options
context:
space:
mode:
authorHuang Rui <ray.huang@amd.com>2013-10-29 23:27:40 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-10-30 13:15:41 -0400
commit8e29217f931dd8a76cdb8c88aa0975fa15f0f684 (patch)
treed0e44504fbf41dfd4a8ce93df658a12742a9a172 /drivers/usb/misc/usbtest.c
parentb8fef79518f6a6843e53a4d578c20873ce742a1f (diff)
usb: usbtest: support container id descriptor test
In Test 9 of usbtest module, it is used for performing chapter 9 tests N times. Container ID descriptor is one of the generic device-level capbility descriptors which added in section 9.6.2.3 of USB 3.0 spec. This patch adds to support getting Container ID 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/misc/usbtest.c')
-rw-r--r--drivers/usb/misc/usbtest.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index d6fcbc477fc5..b4152820d655 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -657,6 +657,25 @@ static int is_good_ss_cap(struct usbtest_dev *tdev, u8 *buf)
657 return 1; 657 return 1;
658} 658}
659 659
660static int is_good_con_id(struct usbtest_dev *tdev, u8 *buf)
661{
662 struct usb_ss_container_id_descriptor *con_id;
663
664 con_id = (struct usb_ss_container_id_descriptor *) buf;
665
666 if (con_id->bLength != USB_DT_USB_SS_CONTN_ID_SIZE) {
667 ERROR(tdev, "bogus container id descriptor length\n");
668 return 0;
669 }
670
671 if (con_id->bReserved) { /* reserved == 0 */
672 ERROR(tdev, "reserved bits set\n");
673 return 0;
674 }
675
676 return 1;
677}
678
660/* sanity test for standard requests working with usb_control_mesg() and some 679/* sanity test for standard requests working with usb_control_mesg() and some
661 * of the utility functions which use it. 680 * of the utility functions which use it.
662 * 681 *
@@ -810,6 +829,14 @@ static int ch9_postconfig(struct usbtest_dev *dev)
810 return -EDOM; 829 return -EDOM;
811 } 830 }
812 break; 831 break;
832 case CONTAINER_ID_TYPE:
833 if (buf + USB_DT_USB_SS_CONTN_ID_SIZE >
834 dev->buf + total ||
835 !is_good_con_id(dev, buf)) {
836 dev_err(&iface->dev, "bogus container id descriptor\n");
837 return -EDOM;
838 }
839 break;
813 default: 840 default:
814 break; 841 break;
815 } 842 }