- usb_fill_bulk_urb (urb, udev, pipe, 0, bytes, simple_callback, 0);
+ usb_fill_bulk_urb (urb, udev, pipe, NULL, bytes, simple_callback, NULL);
- sg [i].page = virt_to_page (buf);
- sg [i].offset = offset_in_page (buf);
- sg [i].length = size;
+ sg_init_one(&sg[i], buf, size);
+
+ switch (pattern) {
+ case 0:
+ /* already zeroed */
+ break;
+ case 1:
+ for (j = 0; j < size; j++)
+ *buf++ = (u8) (j % 63);
+ break;
+ }
-static int realworld = 1;
-MODULE_PARM (realworld, "i");
-MODULE_PARM_DESC (realworld, "clear to demand stricter ch9 compliance");
+static unsigned realworld = 1;
+module_param (realworld, uint, 0);
+MODULE_PARM_DESC (realworld, "clear to demand stricter spec compliance");
retval = usb_control_msg (udev, usb_rcvctrlpipe (udev, 0),
USB_REQ_GET_INTERFACE, USB_DIR_IN|USB_RECIP_INTERFACE,
0, iface->altsetting [0].desc.bInterfaceNumber,
retval = usb_control_msg (udev, usb_rcvctrlpipe (udev, 0),
USB_REQ_GET_INTERFACE, USB_DIR_IN|USB_RECIP_INTERFACE,
0, iface->altsetting [0].desc.bInterfaceNumber,
retval = usb_control_msg (udev, usb_rcvctrlpipe (udev, 0),
USB_REQ_GET_CONFIGURATION,
USB_DIR_IN | USB_RECIP_DEVICE,
retval = usb_control_msg (udev, usb_rcvctrlpipe (udev, 0),
USB_REQ_GET_CONFIGURATION,
USB_DIR_IN | USB_RECIP_DEVICE,
- 0, 0, dev->buf, 1, HZ * USB_CTRL_GET_TIMEOUT);
+ 0, 0, dev->buf, 1, USB_CTRL_GET_TIMEOUT);
- dev_dbg (&iface->dev,
- "get config --> %d (%d)\n", retval,
- expected);
+ dev_dbg (&iface->dev, "get config --> %d %d (1 %d)\n",
+ retval, dev->buf[0], expected);
- if (udev->descriptor.bcdUSB == 0x0200) { /* pre-swapped */
- struct usb_qualifier_descriptor *d = 0;
+ if (le16_to_cpu(udev->descriptor.bcdUSB) == 0x0200) {
+ struct usb_qualifier_descriptor *d = NULL;
/* device qualifier [9.6.2] */
retval = usb_get_descriptor (udev,
/* device qualifier [9.6.2] */
retval = usb_get_descriptor (udev,
if ((status = usb_submit_urb (urb, SLAB_ATOMIC)) != 0) {
dbg ("can't resubmit ctrl %02x.%02x, err %d",
reqp->bRequestType, reqp->bRequest, status);
if ((status = usb_submit_urb (urb, SLAB_ATOMIC)) != 0) {
dbg ("can't resubmit ctrl %02x.%02x, err %d",
reqp->bRequestType, reqp->bRequest, status);
* as with bulk/intr sglists, sglen is the queue depth; it also
* controls which subtests run (more tests than sglen) or rerun.
*/
* as with bulk/intr sglists, sglen is the queue depth; it also
* controls which subtests run (more tests than sglen) or rerun.
*/
for (i = 0; i < param->sglen; i++) {
int pipe = usb_rcvctrlpipe (udev, 0);
unsigned len;
for (i = 0; i < param->sglen; i++) {
int pipe = usb_rcvctrlpipe (udev, 0);
unsigned len;
case 13: // short read, resembling case 10
req.wValue = cpu_to_le16 ((USB_DT_CONFIG << 8) | 0);
// last data packet "should" be DATA1, not DATA0
case 13: // short read, resembling case 10
req.wValue = cpu_to_le16 ((USB_DT_CONFIG << 8) | 0);
// last data packet "should" be DATA1, not DATA0
expected = -EREMOTEIO;
break;
case 14: // short read; try to fill the last packet
req.wValue = cpu_to_le16 ((USB_DT_DEVICE << 8) | 0);
// device descriptor size == 18 bytes
expected = -EREMOTEIO;
break;
case 14: // short read; try to fill the last packet
req.wValue = cpu_to_le16 ((USB_DT_DEVICE << 8) | 0);
// device descriptor size == 18 bytes
reqp->number = i % NUM_SUBCASES;
reqp->expected = expected;
u->setup_packet = (char *) &reqp->setup;
reqp->number = i % NUM_SUBCASES;
reqp->expected = expected;
u->setup_packet = (char *) &reqp->setup;
* hcd states and code paths, even with little other system load.
*/
msleep (jiffies % (2 * INTERRUPT_RATE));
* hcd states and code paths, even with little other system load.
*/
msleep (jiffies % (2 * INTERRUPT_RATE));
- retval = usb_unlink_urb (urb);
- if (retval == -EBUSY || retval == -EIDRM) {
- /* we can't unlink urbs while they're completing.
- * or if they've completed, and we haven't resubmitted.
- * "normal" drivers would prevent resubmission, but
- * since we're testing unlink paths, we can't.
- */
- dev_dbg (&dev->intf->dev, "unlink retry\n");
- goto retry;
- }
+ retval = usb_unlink_urb (urb);
+ if (retval == -EBUSY || retval == -EIDRM) {
+ /* we can't unlink urbs while they're completing.
+ * or if they've completed, and we haven't resubmitted.
+ * "normal" drivers would prevent resubmission, but
+ * since we're testing unlink paths, we can't.
+ */
+ dev_dbg (&dev->intf->dev, "unlink retry\n");
+ goto retry;
+ }
+ } else
+ usb_kill_urb (urb);
if (!(retval == 0 || retval == -EINPROGRESS)) {
dev_dbg (&dev->intf->dev, "unlink fail %d\n", retval);
return retval;
if (!(retval == 0 || retval == -EINPROGRESS)) {
dev_dbg (&dev->intf->dev, "unlink fail %d\n", retval);
return retval;
retval = usb_control_msg (urb->dev, usb_sndctrlpipe (urb->dev, 0),
USB_REQ_SET_FEATURE, USB_RECIP_ENDPOINT,
USB_ENDPOINT_HALT, ep,
retval = usb_control_msg (urb->dev, usb_sndctrlpipe (urb->dev, 0),
USB_REQ_SET_FEATURE, USB_RECIP_ENDPOINT,
USB_ENDPOINT_HALT, ep,
if (retval < 0) {
dbg ("ep %02x couldn't set halt, %d", ep, retval);
return retval;
if (retval < 0) {
dbg ("ep %02x couldn't set halt, %d", ep, retval);
return retval;
static int ctrl_out (struct usbtest_dev *dev,
unsigned count, unsigned length, unsigned vary)
{
static int ctrl_out (struct usbtest_dev *dev,
unsigned count, unsigned length, unsigned vary)
{
buf [j] = i + j;
retval = usb_control_msg (udev, usb_sndctrlpipe (udev,0),
0x5b, USB_DIR_OUT|USB_TYPE_VENDOR,
buf [j] = i + j;
retval = usb_control_msg (udev, usb_sndctrlpipe (udev,0),
0x5b, USB_DIR_OUT|USB_TYPE_VENDOR,
- 0, 0, buf, len, HZ * USB_CTRL_SET_TIMEOUT);
+ 0, 0, buf, len, USB_CTRL_SET_TIMEOUT);
break;
}
/* read it back -- assuming nothing intervened!! */
retval = usb_control_msg (udev, usb_rcvctrlpipe (udev,0),
0x5c, USB_DIR_IN|USB_TYPE_VENDOR,
break;
}
/* read it back -- assuming nothing intervened!! */
retval = usb_control_msg (udev, usb_rcvctrlpipe (udev,0),
0x5c, USB_DIR_IN|USB_TYPE_VENDOR,
- 0, 0, buf, len, HZ * USB_CTRL_GET_TIMEOUT);
+ 0, 0, buf, len, USB_CTRL_GET_TIMEOUT);
- "iso test, %lu errors\n",
- ctx->errors);
+ "iso test, %lu errors out of %lu\n",
+ ctx->errors, ctx->packet_count);
- return 0;
- maxp = 0x7ff & desc->wMaxPacketSize;
- maxp *= 1 + (0x3 & (desc->wMaxPacketSize >> 11));
+ return NULL;
+ maxp = 0x7ff & le16_to_cpu(desc->wMaxPacketSize);
+ maxp *= 1 + (0x3 & (le16_to_cpu(desc->wMaxPacketSize) >> 11));
packets = (bytes + maxp - 1) / maxp;
urb = usb_alloc_urb (packets, SLAB_KERNEL);
packets = (bytes + maxp - 1) / maxp;
urb = usb_alloc_urb (packets, SLAB_KERNEL);
}
memset (urb->transfer_buffer, 0, bytes);
for (i = 0; i < packets; i++) {
}
memset (urb->transfer_buffer, 0, bytes);
for (i = 0; i < packets; i++) {
"... iso period %d %sframes, wMaxPacket %04x\n",
1 << (desc->bInterval - 1),
(udev->speed == USB_SPEED_HIGH) ? "micro" : "",
"... iso period %d %sframes, wMaxPacket %04x\n",
1 << (desc->bInterval - 1),
(udev->speed == USB_SPEED_HIGH) ? "micro" : "",
for (i = 0; i < param->sglen; i++) {
urbs [i] = iso_alloc_urb (udev, pipe, desc,
for (i = 0; i < param->sglen; i++) {
urbs [i] = iso_alloc_urb (udev, pipe, desc,
status = usb_submit_urb (urbs [i], SLAB_ATOMIC);
if (status < 0) {
ERROR (dev, "submit iso[%d], error %d\n", i, status);
status = usb_submit_urb (urbs [i], SLAB_ATOMIC);
if (status < 0) {
ERROR (dev, "submit iso[%d], error %d\n", i, status);
+
+ /*
+ * Isochronous transfers are expected to fail sometimes. As an
+ * arbitrary limit, we will report an error if any submissions
+ * fail or if the transfer failure rate is > 10%.
+ */
+ if (status != 0)
+ ;
+ else if (context.submit_error)
+ status = -EACCES;
+ else if (context.errors > context.packet_count / 10)
+ status = -EIO;
+ return status;
/* some devices, like ez-usb default devices, need a non-default
* altsetting to have any active endpoints. some tests change
* altsettings; force a default so most tests don't need to check.
/* some devices, like ez-usb default devices, need a non-default
* altsetting to have any active endpoints. some tests change
* altsettings; force a default so most tests don't need to check.
- dev_dbg (&intf->dev, "TEST 14: %d ep0out, 0..%d vary %d\n",
- param->iterations, param->length, param->vary);
+ dev_dbg (&intf->dev, "TEST 14: %d ep0out, %d..%d vary %d\n",
+ param->iterations,
+ realworld ? 1 : 0, param->length,
+ param->vary);
retval = ctrl_out (dev, param->iterations,
param->length, param->vary);
break;
retval = ctrl_out (dev, param->iterations,
param->length, param->vary);
break;
-static int force_interrupt = 0;
-MODULE_PARM (force_interrupt, "i");
+static unsigned force_interrupt = 0;
+module_param (force_interrupt, uint, 0);
/* specify devices by module parameters? */
if (id->match_flags == 0) {
/* vendor match required, product match optional */
/* specify devices by module parameters? */
if (id->match_flags == 0) {
/* vendor match required, product match optional */
- udev->descriptor.idVendor,
- udev->descriptor.idProduct);
+ le16_to_cpu(udev->descriptor.idVendor),
+ le16_to_cpu(udev->descriptor.idProduct));
static void usbtest_disconnect (struct usb_interface *intf)
{
struct usbtest_dev *dev = usb_get_intfdata (intf);
static void usbtest_disconnect (struct usb_interface *intf)
{
struct usbtest_dev *dev = usb_get_intfdata (intf);
MODULE_DEVICE_TABLE (usb, id_table);
static struct usb_driver usbtest_driver = {
MODULE_DEVICE_TABLE (usb, id_table);
static struct usb_driver usbtest_driver = {