[PATCH 4/4] usb: usbtest: support container id descriptor test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx>
---
 drivers/usb/misc/usbtest.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 9b99a42..5904ab6 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)
 	return 1;
 }
 
+static int is_good_con_id(struct usbtest_dev *tdev)
+{
+	struct usb_ss_container_id_descriptor *con_id;
+
+	con_id = (struct usb_ss_container_id_descriptor *) tdev->buf;
+
+	if (con_id->bLength != USB_DT_USB_SS_CONTN_ID_SIZE) {
+		ERROR(tdev, "bogus container id descriptor length\n");
+		return 0;
+	}
+
+	if (con_id->bReserved) {	/* reserved == 0 */
+		ERROR(tdev, "reserved bits set\n");
+		return 0;
+	}
+
+	return 1;
+}
+
 /* sanity test for standard requests working with usb_control_mesg() and some
  * of the utility functions which use it.
  *
@@ -797,6 +816,12 @@ static int ch9_postconfig(struct usbtest_dev *dev)
 					return -EDOM;
 				}
 				break;
+			case CONTAINER_ID_TYPE:
+				if (!is_good_con_id(dev)) {
+					dev_err(&iface->dev, "bogus container id descriptor\n");
+					return -EDOM;
+				}
+				break;
 			default:
 				break;
 			}
-- 
1.7.11.7


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux